-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add != (not equal) to list of supported binops #34
Conversation
This looks good, but the yyscan_t thing is a bit fugly. The issue seems to be that we need This change to
If that works, we can ditch the |
I did a bit more investigating. It appears that the problem comes from the fact that the latest bison (2.6.2, possibly earlier) generates a prototype for yyparse() and puts it in parser.gen.h. Since we're using %parse-param to add a yyscan_t param, we've just created a circular dependency in the #includes. lexer.gen.h needs the token definitions from parser.gen.h, and parser.gen.h needs the yyscan_t definition from lexer.gen.h . I don't see a nice way out of this :( |
It's not like combining flex and bison is an unusual move, you'd think this stuff would be simpler. I think we can wrap the lexer parameter in a forward-declared struct, so %parse-param sees an opaque pointer to a struct we don't define until we #include lexer.gen.h. Try this (again, works on my flex/bison): https://gist.github.com/3940705 |
Also: docs and tests! You get away without writing docs this time, since apparently I've documented Tests are pretty easy: there's a file called testdata that contains a bunch of tests which consist of program, sample input and expected output. When you run |
The patch almost works, but I get "warning: 'struct lexer_param' declared inside parameter list " while trying to compile parser.gen.h from within lexer.l . (Because at this point the compiler hasn't seen any forward declaration for the struct). Adding an additional 'struct lexer_param;' to the top of lexer.l fixes that too. I'll add some tests for != . |
Cool. Adding another forward declaration |
This prevents the circuluar dependency between parser.gen.h and lexer.gen.h. Newer versions of bison add a prototype for yyparse() to parser.gen.h that include the as-yet-undeclared yyscan_t type.
I've added some tests cases and also pulled in your fix for the circular dependency problem. |
Add != (not equal) to list of supported binops
I was munging some data and needed to query "select (.some.json.field != 200)".
Not all versions of flex export the declaration of yyscan_t, so I had to add it by hand. Ugly, but "error: unknown type name 'yyscan_t'" is a common error message on Google.
Also committing the new output of lex/yacc.