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
GenLex stream parsers too eager?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-01-27 (18:27)
From: mattwb@v...
Subject: Re: GenLex stream parsers too eager?

>From: "David McClain" <>
>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 =
>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 =

I'd certainly suggest not using Genlex except for only the most trivial
things.  Ocamllex and ocamlyacc are not difficult and they're much more

>David McClain
>Sr. Scientist
>Raytheon Missile Systems Co.
>Tucson, AZ