fix missing EOF token

This commit is contained in:
Oleg Sobolev 2025-12-25 18:01:59 +03:00
parent 320e446236
commit 05d670817e
3 changed files with 3 additions and 3 deletions

View file

@ -9,4 +9,4 @@ data Expr =
Unary Token Expr | Unary Token Expr |
Binary Expr Token Expr | Binary Expr Token Expr |
Grouping Expr Grouping Expr
deriving Show

View file

@ -1,5 +1,5 @@
module Lox.Parser ( module Lox.Parser (
expression parse
) where ) where
import Control.Monad import Control.Monad

View file

@ -43,7 +43,7 @@ scanTokensFromSource source = evalState scanTokens (emptyScannerState source)
scanTokens :: State ScannerState [Token] scanTokens :: State ScannerState [Token]
scanTokens = do scanTokens = do
atEnd <- isAtEnd atEnd <- isAtEnd
if atEnd then return [] else do if atEnd then return <$> addToken EOF else do
maybeToken <- scanToken maybeToken <- scanToken
case maybeToken of case maybeToken of
Nothing -> scanTokens Nothing -> scanTokens