I hate to keep dragging this out but this isnt helping me very much. I now
know that my syntax error is because of "unexpected $undefined, expecting
$end or '\n'", but adding a newline to my test_file doesn't fix this issue.
I'm not sure how my input does not conform to my grammar.
Thanks everyon
Aha!
$undefined means that the lexer returned a character value that you
are not prepared for, that is, it is not in a rule or %token in your
grammar file. Bison could have been a bit more cooperative by telling
you which character it is, but there you are.
Assuming the lexer is flex, %option d
Flex doesn't give me any output and looking online it looks like whitespace
wouldn't be causing this. For everything else I used the "." to have misc
things printed out.
So I'm not sure how thats possible or where its coming from. I attached the
file in case anyone feels like taking a look.
lexi
You didn't turn on debugging in flex, which is why it doesn't tell you
anything.
Assuming you don't care about whitespace, you need to split the rule
on line 39 into
[ \t\r] ;
[\n] {lexEcho("%s", yytext); return yytext[0];}
The default rule needs to return something
On 1 Sep 2010, at 07:01, Martin McDermott wrote:
I'm trying to write a simple grammar for propositional logic for a
project
of mine, with support for AND, OR, XOR, NOT. Nothing fancy, only I
cant seem
to come up with a correct grammar. My simple test cases all give me
syntax
errors.
Just
Your right, I undid one to many lines and killed it... Sorry about that.
At first I thought I understood the error, I thought it was a problem when
you have cases like 3 variables but 2 operations. The easier 2 variables and
1 op also fails, so now i"m not sure what its telling me. The output is
b
Unless you've changed the grammar, you are missing a rule to match
formulas followed by a new line.
formulas
: formula
| formulas '\n'
| formulas '\n' formula
;
j.
On 1 September 2010 11:11, Martin McDermott
wrote:
> Your right, I undid one to many lines and k