Re: grammar for propositional logic

2010-09-01 Thread John P. Hartmann
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

Re: grammar for propositional logic

2010-09-01 Thread Martin McDermott
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

Re: grammar for propositional logic

2010-09-01 Thread Hans Aberg
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 e

Re: grammar for propositional logic

2010-09-01 Thread John P. Hartmann
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

Re: grammar for propositional logic

2010-09-01 Thread Martin McDermott
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

Re: grammar for propositional logic

2010-09-01 Thread John P. Hartmann
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

Re: grammar for propositional logic

2010-09-01 Thread Martin McDermott
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

Re: grammar for propositional logic

2010-08-31 Thread John P. Hartmann
Essentially, your input does not conform to your grammar (but you probably know that). %error-verbose will give you more information about where the grammar and your input disagree. Set yydebug=1 to get a trace of the parse. With that, inspect y.output for the failing state. j.

Re: grammar for propositional logic

2010-08-31 Thread John P. Hartmann
If you mean why do you get the shift/reduce errors, it is because your grammar is ambiguous. You can deal with the ambiguity in several ways, but %left to specify associativity and precedence as I said earlier seems like the easiest in your case. Doing that will remove all conflicts from your gra

Re: grammar for propositional logic

2010-08-31 Thread Martin McDermott
Any comments on why I would be getting a syntax error? On Wed, Sep 1, 2010 at 1:50 AM, John P. Hartmann wrote: > -- Forwarded message -- > From: John P. Hartmann > Date: 1 September 2010 07:49 > Subject: Re: grammar for propositional logic > To: Martin McDer

Fwd: grammar for propositional logic

2010-08-31 Thread John P. Hartmann
-- Forwarded message -- From: John P. Hartmann Date: 1 September 2010 07:49 Subject: Re: grammar for propositional logic To: Martin McDermott You should inspect the .output file to resolve your conflicts.  For something as simple as yours, you should have zero tolerance for

Re: grammar for propositional logic

2010-08-31 Thread Martin McDermott
Know that feeling alright... On Wed, Sep 1, 2010 at 1:13 AM, Alfonso Urdaneta wrote: > On 9/1/10 1:01 AM, 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 fan

Re: grammar for propositional logic

2010-08-31 Thread Alfonso Urdaneta
On 9/1/10 1:01 AM, 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. Anyone

grammar for propositional logic

2010-08-31 Thread Martin McDermott
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. Anyone mind taking a look at it? Thanks