help-bison
[Top][All Lists]
Advanced

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

Re: goto/label


From: Hans Aberg
Subject: Re: goto/label
Date: Sat, 13 Mar 2004 15:31:40 +0100

At 16:10 +0000 2004/03/11, Miki Miki wrote:
>I was wondering if anyone could help me how to implement a grammar rule for
>GOTO statement
>and also how to allow the option that a label can be aded to any statement
>in the program.
>
>Essentially program should be able to jump to the label specified after GOTO
>statement and execute
>that part of code. see example.

You probably want to implement an interpreter that reads commands line by
line, which is slow and inefficient, so no-one does that today. You cannot
do that with Bison, as it generates a parser that will read the input file
in one go. Thus, you will have to build in the parser actions some code
that later can be executed, and emulates the code jumps. There are various
ways to do that. The newsgroup comp.compilers and its FAQ published there
monthly may give further leads, as it is a general question on how to build
compilers, and not a Help-Bison issue.

  Hans Aberg






reply via email to

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