summaryrefslogtreecommitdiff
path: root/src/LambdaCube/Compiler/Lexer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LambdaCube/Compiler/Lexer.hs')
-rw-r--r--src/LambdaCube/Compiler/Lexer.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/LambdaCube/Compiler/Lexer.hs b/src/LambdaCube/Compiler/Lexer.hs
index c47ba1ce..fe3015a6 100644
--- a/src/LambdaCube/Compiler/Lexer.hs
+++ b/src/LambdaCube/Compiler/Lexer.hs
@@ -141,7 +141,16 @@ lexemeWithoutSpace p = do
141 141
142-- TODO?: eliminate; when eliminated, the SPos in parser state can be eliminated too 142-- TODO?: eliminate; when eliminated, the SPos in parser state can be eliminated too
143appRange :: Parse r w (SI -> a) -> Parse r w a 143appRange :: Parse r w (SI -> a) -> Parse r w a
144appRange p = (\fi p1 a p2 -> a $ RangeSI $ Range fi p1 p2) <$> asks fileInfo <*> getSPos <*> p <*> get 144appRange p = (\fi p1 a p2 -> a $ RangeSI $ Range fi p1 p2) <$> asks fileInfo <*> getSPos <*> p <*> getLexemeEnd
145
146getLexemeEnd = get
147
148noSpaceBefore p = try $ do
149 pos <- getLexemeEnd
150 x <- p
151 guard $ case sourceInfo x of
152 RangeSI (Range _ pos' _) -> pos == pos'
153 return x
145 154
146lexeme_ p = lexemeWithoutSpace p <* whiteSpace 155lexeme_ p = lexemeWithoutSpace p <* whiteSpace
147 156
@@ -224,9 +233,9 @@ upperLower = lowerCase <|> upperCase_ <|> parens symbols
224 233
225----------------------------------------------------------- operators and identifiers 234----------------------------------------------------------- operators and identifiers
226 235
227reservedOp name = lexeme $ try $ string name *> notFollowedBy opLetter 236reservedOp name = fst <$> lexeme_ (try $ string name *> notFollowedBy opLetter)
228 237
229reserved name = lexeme $ try $ string name *> notFollowedBy identLetter 238reserved name = fst <$> lexeme_ (try $ string name *> notFollowedBy identLetter)
230 239
231expect msg p i = i >>= \n -> if p n then unexpected (msg ++ " " ++ show n) else return n 240expect msg p i = i >>= \n -> if p n then unexpected (msg ++ " " ++ show n) else return n
232 241