What to do with whitespace
From the grammar:
VarDecl = ( 'var' | Type ) id '=' Exp ';'
Exp = ...
id = alpha ( '_' | alphaNum )*
What do we do with input varavaravarava=123;
as a variable declaration:
- Variable name
avaravarava
and variable value123
? - "Parse" error, because we want an explicit
' '
betweenvar
and the variable name? - ...?
Arguably, both options have their merit. Depending on the type of 'peeking' (lookahead / lookbehind), the scanner can be either very simple or already look like a parser.
Also, what to do with other types of whitespace: \t
, \n
, \r
...