Skip to content

Commit

Permalink
detect keywords in the lookahead
Browse files Browse the repository at this point in the history
  • Loading branch information
krangelov committed Mar 8, 2024
1 parent 5a2e1a8 commit 518e571
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/compiler/api/GF/Grammar/Lexer.x
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,18 @@ start_of_tag s = isJust (match s)
matchIdent s
| BS.null s = Nothing
| BS.elem (BS.head s) init = matchRest (BS.tail s)
| BS.elem (BS.head s) init = matchRest s 1 (BS.tail s)
| otherwise = Nothing
matchRest s
| BS.null s = Just s
| BS.elem (BS.head s) rest = matchRest (BS.tail s)
| otherwise = Just s
matchRest s0 i s
| BS.null s = checkResWord (BS.take i s0) s
| BS.elem (BS.head s) rest = matchRest s0 (i+1) (BS.tail s)
| otherwise = checkResWord (BS.take i s0) s
checkResWord w s =
case Map.lookup (identC (rawIdentC w)) resWords of
Just t -> Nothing
Nothing -> Just s
getPosn :: P Posn
getPosn = P $ \ai2@(_,inp@(AI pos _ _)) -> POk ai2 pos
Expand Down

0 comments on commit 518e571

Please sign in to comment.