i want to parse a string which i give in the main function iin yacc . i know tat this could be done by using yy_scan_string but i don't know how to use it. i even searched net and man pages but it is not clearly given so pls help me
A:
This works for me. I have this code in the subroutines section (i.e. the third section) of my Bison file:
struct eq_tree_node *parse_equation(char *str_input)
{
struct eq_tree_node *result;
yy_scan_string(str_input);
yyparse();
/* to avoid leakage */
yylex_destroy();
/* disregard this. it is the function that I defined to get
the result of the parsing. */
result = symtab_get_parse_result();
return result;
}
markonovak
2010-09-01 13:50:19