help-bison
[Top][All Lists]
Advanced

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

statements 'if' 'while' && call function


From: Johann SAVALLE
Subject: statements 'if' 'while' && call function
Date: Fri, 21 Mar 2003 15:38:24 +0100 (MET)

I am working on logo interpreter project and i am looking 
for a way to implement the 'if' 'while' statement - mostly
which actions have to implement ... I use the C language not 
C++ so i cannot use objects . But I've seen some stuff
like 

-------------------------------------------
statement:
        .......
    |  
        IF '(' expr ')'
                  { P.start_if($3);  }
        command possible_else
                  { $$ = P.finish_if(); }         
    |   
        ....
;

possible_else:
        /* nothing */
        |
          ELSE command
              { /* do nothing */} 
;


command:
          statement
                      { P.add_statement(<Node> $1);}
        |
          block
                      { P.add_statement(<Node> $1);}
;   

block:
          '{'
              { P.start_block();  }
          statements '}'
              { $$ = P.finish_block(); }
;                                                                            

--------------------

in a previous post.
I could use a function to do it but, since 'command' and 'block' have
also to be interpreted I dunno how to do it properly ... maybe with
boolean variable and goto / label ... but it's pretty dirty and 
I am not sure it's going to work ;)

well ... any help, advices, would be really really apreciated .

thanks




reply via email to

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