cparsingbisonflex-lexer

Parser that controls is every { closed and matches the closest one


My scanner is works fine but i couldn't find whats wrong with my parser

semi: "{" vallist "}"
    | "{" "}""
    ;
val: tSTR
   | tInt
   ;
vallist: vallist , val
       | val
       ;

Solution

  • You have a number of problems, some of which are probably just typos in your copy-paste (what you have above will be rejected by bison).

    Your main problem is probably using " (double quotes) for your tokens, which for the most part doesn't do anything useful -- it creates a 'new' token that is not the same as the single character token your lexer probably returns.

    Instead, you want to use ' (single quotes):

    semi: '{' vallist '}'
        | '{' '}'
        ;
    val: tSTR
       | tInt
       | semi
       ;
    vallist: vallist ',' val
           | val
           ;