List Info

Thread: "ocaml_beginners"::[] why map key words to upper case in lexer




"ocaml_beginners"::[] why map key words to upper case in lexer
country flaguser name
United States
2007-05-21 00:30:40

Basic question. Thanks.
why we map key words to upper case in lexer?
Other than use the original words?

like:
| "if"
| "then"

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] why map key words to upper case in lexer
country flaguser name
United States
2007-05-21 10:40:05

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

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] why map key words to upper case in lexer
country flaguser name
United States
2007-05-21 10:40:05

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

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )