I am still working on my simple language parser and I was wondering whether you could 'force' bison to parse from a certain line. By that I mean if there was some code such as:
int avar = 7
int bvar = 10
log avar
log bvar
I want bison to go and search through the lines and go to line 1 wherever it sees avar
mentioned or line 2 wherever it says bvar
mentioned. Obviously this is a very simple task with simple identifiers (and there are other ways to do this) but I was thinking whether it was possible for you to write a c function that can go to the line again. I would imagine that this would be useful in loops or user defined functions. Could you perhaps use another c function to go to the line by using the lineno variable from flex or is there an in built function. If you do have to use a c function, how would you go about telling bison to parse it again? Would it be by using the yyparse() and yylex() methods?
I imagine that the answer would be very simple but I am quite new to bison, flex and c programming so any help would be appreciated. Thank you in advance.
First Edit:
This is not part of my actual language which is still in a very early simple stage. I was just wondering whether it would be possible in the future to do this if my language progresses into the future stage. A better example by what I mean would be in this loop:
int x = 0
begin loop
x = x + 1
log x
end loop if x > 10
Would it be possible to reference yylex and yyparse for a certain line. For example the bison rule would be to do the statements and it would stop if the end if statement was true else it would go back to line 3 and it would continue doing that until the answer was correct. Would this be possible to implement?