|
Write a Scanner for the language J0! The token classes
are ident, number, and string plus the tokens
used explicitly in the grammar.
ident = letter { letter | digit }.
number = digit { digit }.
string = "\"" { stringchar } "\"".
where
stringchar = escapechar | plainchar.
escapechar = "\\" char.
plainchar = charNoQuote.
char = << any printable character >>.
charNoQuote = << any printable character except "\"" and "\\" >>.
letter = "a" | ... | "z" | "A" | ... | "Z" | "_".
digit = "0" | ... | "9".
Your scanner should be able to accept C++/Java-style comments; i.e. line
comments starting with // and ending at the end of the line
and comments enclosed in /* and */ .
|
|