On Mon, 21 May 2007, LianYang wrote:
> Basic question. Thanks.
> why we map key words to upper case in lexer?
> Other than use the original words?
>
> like:
> | "if"
> | "then"
There are a couple of reasons for this. These "upper case words" are
OCaml variants, which are bundled into sets to form sets, e.g.
type weekday = Monday | Tuesday | Wednesday | Thursday | Friday
These are nice for a couple of reasons, including completeness checking of
patten matching. However, with lexers, one of the primary reasons we use
them is that the tokens that are decribed in an ocamlyacc grammar are
automatically converted to variants.
William D. Neumann
---
"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.
Tigers are noble and sleek; children are loud and messy."
-- Neko Case
Life is unfair. Kill yourself or get over it.
-- Black Box Recorder
.