Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] CFG's and OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-14 (00:58)
From: Erik de Castro Lopo <ocaml-erikd@m...>
Subject: Re: [Caml-list] CFG's and OCaml
On Sat, 14 Aug 2004 01:25:59 +0100
Jon Harrop <> wrote:

> I have some (probably trivial) questions about parsers:
> 1. Are most programming languages designed to be implementable using 
> lex and yacc?

Maybe not lex and yacc, but most are designed to be parsed by 
LALR(1) parsers.

Currently the most difficult to parse language seems to be C++.

> 2. If so, are their designs restricted by this?


> 3. If so, is the fact that most languages disallow "a<b<c" due to this?

This should be parsable by an LALR(1) parser.

Anyway, this is really just syntactic sugar for "a < b && b < c".

> 5. Is it productive to think in terms of coercing lex and yacc into doing as 
> much of the work as possible and then using postprocessing to do the rest 
> (e.g. this is the way I'd implement a<b<c)?

If a, b and c are ints, then the assember version of

       if a<b<c then ....

would be exactly the same as:

	if a < b && b < c then ....

  Erik de Castro Lopo (Yes it's valid)
"Anyone who considers arithmetical methods of producing random
digits is, of course, in a state of sin." - John Von Neumann (1951)

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: