fix missing EOF token
This commit is contained in:
parent
320e446236
commit
05d670817e
3 changed files with 3 additions and 3 deletions
|
|
@ -9,4 +9,4 @@ data Expr =
|
|||
Unary Token Expr |
|
||||
Binary Expr Token Expr |
|
||||
Grouping Expr
|
||||
|
||||
deriving Show
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
module Lox.Parser (
|
||||
expression
|
||||
parse
|
||||
) where
|
||||
|
||||
import Control.Monad
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ scanTokensFromSource source = evalState scanTokens (emptyScannerState source)
|
|||
scanTokens :: State ScannerState [Token]
|
||||
scanTokens = do
|
||||
atEnd <- isAtEnd
|
||||
if atEnd then return [] else do
|
||||
if atEnd then return <$> addToken EOF else do
|
||||
maybeToken <- scanToken
|
||||
case maybeToken of
|
||||
Nothing -> scanTokens
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue