GenLex stream parsers too eager?

From: David McClain (dmcclain@azstarnet.com)
Date: Tue Jan 26 1999 - 18:33:46 MET


From: "David McClain" <dmcclain@azstarnet.com>
To: "Liste CAML" <caml-list@inria.fr>
Subject: GenLex stream parsers too eager?
Date: Tue, 26 Jan 1999 10:33:46 -0700

This is a multi-part message in MIME format.

------=_NextPart_000_0009_01BE4917.5AA0B6B0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

It appears that the Genlex derived parsers always eagerly tokenize =
negaitve integer and float constants. This causes incorrect behavior in =
closely spaced code (no-spaces):

    a-2*c --> parses as "a", "-2" ,"*", "c" instead of =
"a","-","2","*","c"

So instead of getting one expression tree, I get two, with the first =
containing only "a".
Also, if the operator were exponentiation instead of multiplication, the =
second tree would incorrectly compute a (possibly) complex valued =
expression instead of a simple negative of a real expression.

I have tried various workarounds, but they really obfuscate the original =
recursive descent structure of parsers.

Any suggestions? (Perhaps I should be using OCAMLLEX and OCAMLYACC =
instead?)

David McClain
Sr. Scientist
Raytheon Missile Systems Co.
Tucson, AZ
http://www.azstarnet.com/~dmcclain/homepage.htm



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET