Unnecessary parenthesis

John F. Haugh II jfh at rpp386.UUCP
Tue Jul 12 15:17:05 AEST 1988


In article <1988Jul10.201845.27751 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>> ... this is a weakness of RD parsers: the amount of
>> work incurred by unnecessary parentheses is quite considerable, especially
>> in a language such as C, with 15 levels of operator precedence....
>
>Well, yes, *if* you implement the RD parser straight from the grammar and
>do no optimization.  One can do better, at the price of greater complexity,
>by explicitly looking for the simple cases.

one of the major strengths of r-d parsers is you can code the parser
straight from the grammar.  performing the transformations from left to
right recursion should be fairly automatic and is the only really
worthwhile (ease of coding, speed and complexity tradeoffs being
considered) optimization i can see.

the geneal case of trying to reduce the recursion present in the parser
would seem to require a potentially arbitrary amount of look ahead, or
as a minimum, the same amount of lookahead as the length of the shortest
sentence the parser is trying to recognize.  clarifications, henry?

>Anyone who buys Wisconsin cheese is  |  Henry Spencer @ U of Toronto Zoology
>a traitor to mankind.  --Pournelle   | {ihnp4,decvax,uunet!mnetor}!utzoo!henry

and what the hell does this mean???

- john.
-- 
John F. Haugh II                 +--------- Cute Chocolate Quote ---------
HASA, "S" Division               | "USENET should not be confused with
UUCP:   killer!rpp386!jfh        |  something that matters, like CHOCOLATE"
DOMAIN: jfh at rpp386.uucp          |             -- with my apologizes



More information about the Comp.lang.c mailing list