parser improve error messages
This commit is contained in:
parent
f183b8b183
commit
9e6f31479f
@ -7,6 +7,7 @@ import Parser.Lexer
|
|||||||
%name parse
|
%name parse
|
||||||
%tokentype { Token }
|
%tokentype { Token }
|
||||||
%error { parseError }
|
%error { parseError }
|
||||||
|
%errorhandlertype explist
|
||||||
|
|
||||||
%token
|
%token
|
||||||
BOOLEAN { BOOLEAN }
|
BOOLEAN { BOOLEAN }
|
||||||
@ -368,7 +369,7 @@ data Declarator = Declarator Identifier (Maybe Expression)
|
|||||||
convertDeclarator :: DataType -> Declarator -> VariableDeclaration
|
convertDeclarator :: DataType -> Declarator -> VariableDeclaration
|
||||||
convertDeclarator dataType (Declarator id assigment) = VariableDeclaration dataType id assigment
|
convertDeclarator dataType (Declarator id assigment) = VariableDeclaration dataType id assigment
|
||||||
|
|
||||||
parseError :: [Token] -> a
|
parseError :: ([Token], [String]) -> a
|
||||||
parseError msg = error ("Parse error: " ++ show msg)
|
parseError (errortoken, expected) = error ("parse error on token: " ++ show errortoken ++ "\nexpected one of: " ++ show expected)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user