Drop useless comments
This commit is contained in:
parent
c16c48b22c
commit
c5f1ccc4dc
@ -6,7 +6,6 @@ import Text.Megaparsec.Char
|
|||||||
import Data.Void
|
import Data.Void
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
-- Lexer type and tokens
|
|
||||||
type Lexer = Parsec Void String
|
type Lexer = Parsec Void String
|
||||||
data LToken
|
data LToken
|
||||||
= LKeywordT
|
= LKeywordT
|
||||||
@ -21,7 +20,6 @@ data LToken
|
|||||||
| LNewline
|
| LNewline
|
||||||
deriving (Show, Eq, Ord)
|
deriving (Show, Eq, Ord)
|
||||||
|
|
||||||
-- Lexical rules
|
|
||||||
keywordT :: Lexer LToken
|
keywordT :: Lexer LToken
|
||||||
keywordT = string "t" *> notFollowedBy alphaNumChar *> pure LKeywordT
|
keywordT = string "t" *> notFollowedBy alphaNumChar *> pure LKeywordT
|
||||||
|
|
||||||
@ -65,11 +63,9 @@ closeBracket = char ']' *> pure LCloseBracket
|
|||||||
lnewline :: Lexer LToken
|
lnewline :: Lexer LToken
|
||||||
lnewline = char '\n' *> pure LNewline
|
lnewline = char '\n' *> pure LNewline
|
||||||
|
|
||||||
-- Whitespace consumer
|
|
||||||
sc :: Lexer ()
|
sc :: Lexer ()
|
||||||
sc = skipMany (char ' ' <|> char '\t')
|
sc = skipMany (char ' ' <|> char '\t')
|
||||||
|
|
||||||
-- Lexer definition
|
|
||||||
saplingLexer :: Lexer [LToken]
|
saplingLexer :: Lexer [LToken]
|
||||||
saplingLexer = many (sc *> choice
|
saplingLexer = many (sc *> choice
|
||||||
[ try identifier
|
[ try identifier
|
||||||
@ -84,7 +80,6 @@ saplingLexer = many (sc *> choice
|
|||||||
, lnewline
|
, lnewline
|
||||||
] <* sc) <* eof
|
] <* sc) <* eof
|
||||||
|
|
||||||
-- Lexing function with enhanced error handling
|
|
||||||
lexSapling :: String -> [LToken]
|
lexSapling :: String -> [LToken]
|
||||||
lexSapling input = case runParser saplingLexer "" input of
|
lexSapling input = case runParser saplingLexer "" input of
|
||||||
Left err -> error $ "Lexical error:\n" ++ errorBundlePretty err
|
Left err -> error $ "Lexical error:\n" ++ errorBundlePretty err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user