How can I implement a while loop using flex/bison? -
i simple scanner , parser using bison , flex simple calculator example can give input (to exe generated after compiling lex.yy.c , y.tab.c), 3+4*5, exe display result 23. don't know how following:
x = 0; while (x < 3) { print x; x = x + 1; }
using flex , bison. want exe generated print x, until while loop condition fails. how do that? in advance.
it appears trying build interpreter. need 1) implement symbol table , 2) define interpreter nodes derived common base class. each node have, e.g., "execute" method.
you'd use bison/yacc parser build node tree. "execute" root of tree.
Comments
Post a Comment