Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Faster parser driver for yacc?

0 views
Skip to first unread message

Kathy Harris

unread,
Oct 3, 1986, 6:14:18 PM10/3/86
to

Has anyone experimented with modifying or rewriting the "yaccpar"
file (the main driver of yacc generated parsers) in order to
create a faster parser in the resulting y.tab.c program?

Does anyone have any guidelines on how the structure of the input grammar
will affect the efficiency of the resulting parser (eg, number of
levels of non-terminal, etc.)?

Kathy Harris
Hewlett Packard Systems Software Operation
Ft. Collins, Colorado

Dale Worley

unread,
Oct 7, 1986, 11:56:12 AM10/7/86
to
> Does anyone have any guidelines on how the structure of the input grammar
> will affect the efficiency of the resulting parser (eg, number of
> levels of non-terminal, etc.)?

Avoid productions like

a : b ;

if possible. It helps to use precedence rules with an ambiguous
grammar. Thus you can write things like

expr : expr '+' expr
| expr '*' expr
| '-' expr
| '(' expr ')'
;

and use precedence rules to sort things out. This avoids alot of
nonterminals whose sole purpose is keeping the precedences straight.

Dale

D...@psuvma.bitnet

unread,
Oct 8, 1986, 4:00:57 PM10/8/86
to
Is the parser Yacc generates really the bottleneck? My understanding was that
it was one of the faster parts, so that any minor changes wouldn't effect
speed that much.


dave

D...@psuvma.bitnet

unread,
Oct 9, 1986, 1:16:29 PM10/9/86
to

Use left recursion over right recursion to speed it up.

dave

Kathy Harris

unread,
Oct 16, 1986, 5:18:26 PM10/16/86
to
/ hpfclq:net.lang / D...@PSUVMA.BITNET / 2:00 pm Oct 8, 1986 /

> dave
----------

It depends on what you want to use yacc for. In compilers, it's probably
true that the computation involved in code generation makes the parse
time less critical.

However, yacc can be useful as a parser for other types of input languages
where the computation task is not so great and so yacc becomes a large
part of the task. A more efficient yacc parser would make it feasible
to use yacc in more contexts than just compilers.

The application I've been looking at is an assembler that uses yacc to
parse the assembly source. Currently, yyparse is 25%+ of the user time.
I'm looking for ways to speed of the parse phase, and yet not sacrifice
the flexibility (eg, in adding support for new instructions and addressing
types) that is provided by yacc.

kathy harris
{hplabs | ihnp4}!hpfcla!kah

d...@psuvm.bitnet.uucp

unread,
Oct 20, 1986, 9:26:11 AM10/20/86
to

Good Point,
I was refering to Yacc in context to compiler's only.

dave

0 new messages