Take the 2-minute tour ×

Hallo everybody, Can someone help me out of my situation, im searching for a instrucior that implements the JMP (Jump) instructior like in Assembler. I've found out that it could be withe the goto function of Flex/Bison but i have no really idea how to do. Have got anyone idea. Im very grateful of yours help. Thanks.

Here is an example how it looks like. with the JMP instructor, he goes to the label L1.

EVT 23;
WAIT 500 ms;
share|improve this question
Not too sure what you are talking about, but the while loop will nicely replace that bit of code you have there. –  slugster Apr 26 '10 at 11:02
Hallo slugster, what i ment was, its allround a syntactical analysis and i want that the interpreter i build should recognise the JMP Instructor, when i give an Input like at the top, and gives me back, that JMP was used und it jumped to the label L1. I've build a syntax tree where he can recognise the and while statement the operators and the bigger lower equal operators now i need the same for JMP, if you go to the question how do i implement a ifstatement in flex/bison there you find the code. look it out and if you have an idea i will be very grateful. –  Imran Apr 27 '10 at 6:58
add comment

1 Answer

To implement a jump instruction you need to add gramma support for the label

label: ':' NAME { /* code to store the label */ };

and some grammer to parse the jump command

jmp: JMP NAME { /* code to look-up label and go there */ };

Keep in mind, defer the checking of all jump targets till the end of the parsing, otherwise you not be able to jump ahead.

share|improve this answer
add comment

Your Answer


