Skip to content
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

Can't parse postgresql grammar and missing error location #68

Open
mingodad opened this issue Mar 22, 2022 · 2 comments
Open

Can't parse postgresql grammar and missing error location #68

mingodad opened this issue Mar 22, 2022 · 2 comments

Comments

@mingodad
Copy link

I'm testing jison with a naked postgresql-13.3 grammar generated by a modifed bison (see https://github.com/mingodad/lalr-parser-test) the naked grammar is parsed properly by bison and byacc see attached grammar
gram.y.naked.zip

The output:

$./node dist/cli-cjs-es5.js gram.y.naked
dist/cli-cjs-es5.js:19824
                throw err;
                ^

JisonParserError: 
You cannot specify a precedence override for an epsilon (a.k.a. empty) rule!
    
  Erroneous area:


    at Object.parseError (dist/cli-cjs-es5.js:14994:19)
    at Object.yyError (dist/cli-cjs-es5.js:15133:29)
    at Object.parser__PerformAction (dist/cli-cjs-es5.js:14637:34)
    at Object.parse (dist/cli-cjs-es5.js:16127:48)
    at Object.parse (dist/cli-cjs-es5.js:18717:23)
    at autodetectAndConvertToJSONformat (dist/cli-cjs-es5.js:19799:36)
    at new Jison_Generator (dist/cli-cjs-es5.js:25327:15)
    at Object.generateParserString (dist/cli-cjs-es5.js:25836:25)
    at processInputFile (dist/cli-cjs-es5.js:25751:30)
    at Object.cliMain [as main] (dist/cli-cjs-es5.js:25829:13)
@mingodad
Copy link
Author

Going through the stack trace and adding this line here (dist/cli-cjs-es5.js:14994:19) :

        if (!chk_g) {
            try {
                chk_g = ebnfParser.parse(grammar, options);
            } catch (e) {
                ...
                console.log(ebnfParser.bnf_parser.parser.__error_infos); ////!!!! inside here it's the  line: 4465
                throw err;
            }
        }

But probably there is a better way to show the offending line number.

@mingodad
Copy link
Author

Here is the original rule:

opt_existing_window_name:
	ColId	{ $opt_existing_window_name = $ColId; }
	| /*EMPTY*/				%prec Op	{ $opt_existing_window_name = NULL; }
		;

And here the naked rule:

opt_existing_window_name :
	ColId
	| %prec Op /*14L*/ /*empty*/
	;

Somehow byacc/bison manage to associate precedence to empty rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant