help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Grammars and jumps


From: Bruno Ribeiro
Subject: Grammars and jumps
Date: Tue, 25 Jun 2002 00:28:29 -0300
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3

Hello everybody!

I have two questions about bison grammars and jump implemention:

1) I have the following grammar (part of it):

program:    programbody
                 ;

programbody:    MODULE newline statementlist ENDMODULE
                        ;

statementlist:    statement
                      | statementlist newline statement
                      ;

statement:    vardecl
                  | single_command
                  | ifthen statementlist endif
                  | ifthen statementlist else statementlist endif

Well, everything is working properly when I use just one single_command per line. But I want to have things like:

A = B + C +
D + E

In other words, a newline ("\n") inside a single_command. But if I do this way, I have a parser error. So I try:

statementlist:    statement
                      | statementlist statement
                      ;

and I have a shift/reduce and reduce/reduce conflict in my grammar.

Conclusion: my only alternative is use just commands like A= B + C + D + E (everything in one line).

Does anybody knows how to implement newlines between commands?

2) I'm trying to implement a function like:

A = B + FAT(3) + C

But when I jump yyacc to the position of FAT(3), I have to know the return position (+ C). There's a way for retrieve the current position of yyin (before jump)?

Thanks very much for eveybody!

Bruno.

==================================
There are 10 types of people,
Those that understand binary,
and those that do not.
==================================







reply via email to

[Prev in Thread] Current Thread [Next in Thread]