yacc/bison help

T

thomas

hello I m writing a simple parser using bison. I just used someone's else
c++ grammar, to produce a code beutifier. The thing is , most of the actions
for productions would have form
{$$ = $1 + $2 + $3} and so forth depending on number of terminals in
production. Is it possible to set default action for all the productions
like the one above ? It is something strange to type this formula for over
200 productions.
 
W

Walter Roberson

hello I m writing a simple parser using bison. I just used someone's else
c++ grammar, to produce a code beutifier. The thing is , most of the actions
for productions would have form
{$$ = $1 + $2 + $3} and so forth depending on number of terminals in
production. Is it possible to set default action for all the productions
like the one above ? It is something strange to type this formula for over
200 productions.

In a spot-welding newsgroup, would you expect to be able to get
answers about how to drive your lawn-mower, just because the
lawn-mower happened to have some spot-welds?

There is a google group devoted to Lex and Yacc,
http://groups.google.ca/group/compcompilerslex-and-yacc
or you could try comp.compilers or comp.unix.programmer
 
F

Flash Gordon

thomas wrote, On 19/02/08 19:55:
hello I m writing a simple parser using bison. I just used someone's else

<snip>

Neither yacc nor bison are C, you might find comp.compilers a better
place to ask for help, but check their FAQ and a weeks worth of posting
first.
 
T

thomas

U¿ytkownik "Walter Roberson said:
In a spot-welding newsgroup, would you expect to be able to get
answers about how to drive your lawn-mower, just because the
lawn-mower happened to have some spot-welds?
Yeah you got right, but the group for lawn-mower is moderated, so the answer
about driving would be hard to get, but seriously lex/yacc are realy basis
of computer programing, so I think I will get an answer here.
 
C

Christopher Benson-Manica

[comp.lang.c] thomas said:
Yeah you got right, but the group for lawn-mower is moderated, so the answer
about driving would be hard to get, but seriously lex/yacc are realy basis
of computer programing, so I think I will get an answer here.

One could argue that keyboards, monitors, and hard drives are also
basic to computer programming, but no one asks about THEM here and
gets an answer. How about electrons? Pretty tough to program without
those, indeed, but yet again, they aren't discussed here.

Really, just head to the resources you were directed to.
 
C

CBFalconer

thomas said:
.... snip ...


Yeah you got right, but the group for lawn-mower is moderated,
so the answer about driving would be hard to get, but seriously
lex/yacc are realy basis of computer programing, so I think I
will get an answer here.

No you won't. lexx and yacc are not mentioned in any of the ISO
standards for C, and this newsgroup deals with the standard C
language, as defined in those standards. Thus you question is
off-topic. Now look at the groups previously recommended, repeated
below.
 
C

Chris Dollin

thomas said:
Yeah you got right, but the group for lawn-mower is moderated, so the answer
about driving would be hard to get,

It isn't (assumping we mean comp.compilers). Did you even try?
but seriously lex/yacc are realy basis
of computer programing,

They're not. They're not even "the basis" for lexing & parsing; they're
just traditional tools. Merely because they were written in C and produced
C code/tables doesn't make them topical here.
 
S

SM Ryan

# >>>hello I m writing a simple parser using bison. I just used someone's else
# >>>c++ grammar, to produce a code beutifier. The thing is , most of the
# >>>actions
# >>>for productions would have form
# >>>{$$ = $1 + $2 + $3} and so forth depending on number of terminals in
# >>>production. Is it possible to set default action for all the productions
# >>>like the one above ? It is something strange to type this formula for
# >>>over
# >>>200 productions.

There are number of preprocessors available that allow you
convert text from what you want to what yacc/bison/cc/etc wants.
Options include things c-preprocessor (cpp or cc -E usually),
and m5 if you want parameterised macros. If it just a simple
string substitution, you can use tools like sed, tcl, etc.

You can write a compiler compiler compiler: a yacc grammar that
accept the grammar form you want and writes the grammar yacc wants.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top