tags:

views:

585

answers:

3

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

+1  A: 

I always recommend this page to people who want to learn lex/yacc (or flex/bison)

iWerner
A: 

I've found and example here to myself. May it can be usefull for you:

http://osdir.com/ml/lex.flex.windows/2003-04/msg00008.html

Abud
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