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

Are the changes from #637 LR(1) compatible? #776

Closed
anba opened this Issue Jan 23, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@anba
Contributor

anba commented Jan 23, 2017

Has anyone checked if the grammar is still LR(1) with the changes from #637? When I use the following toy grammar to model the modifications from #637, I get shift/reduce and reduce/reduce conflicts.

%start module

%error-verbose

%token ID
%token EXPORT "export"
%token FROM "from"
%token AS "as"

%%

module : moduleItemList ;
moduleItemList : exportDeclaration | moduleItemList exportDeclaration ;

exportDeclaration : exportClause FROM ID | exportClause_local ;

exportClause : '{' exportSpecifier '}' ;
exportClause_local : '{' exportSpecifier_local '}' ;

exportSpecifier : ID | ID AS ID ;
exportSpecifier_local : identifierReference | identifierReference AS ID ;

identifierReference : ID ;

%%
@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Jan 23, 2017

Collaborator

(I tried to generate an LR automaton, but couldn't figure out how to incorporate lookahead-restrictions into the algorithm.)

Collaborator

jmdyck commented Jan 23, 2017

(I tried to generate an LR automaton, but couldn't figure out how to incorporate lookahead-restrictions into the algorithm.)

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Jan 23, 2017

Collaborator

Yeah, it seems to me that after seeing export { IdentifierName, the parser has a couple of reduce actions available (reduce to Identifier or to ExportSpecifier[~Local]), but the only basis for deciding between them is the presence or absence of a FromClause, which is arbitrarily far away.

Collaborator

jmdyck commented Jan 23, 2017

Yeah, it seems to me that after seeing export { IdentifierName, the parser has a couple of reduce actions available (reduce to Identifier or to ExportSpecifier[~Local]), but the only basis for deciding between them is the presence or absence of a FromClause, which is arbitrarily far away.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Jan 23, 2017

Contributor

Thanks for confirming @jmdyck!

Contributor

anba commented Jan 23, 2017

Thanks for confirming @jmdyck!

anba added a commit to anba/ecma262 that referenced this issue Feb 6, 2017

@bterlson bterlson closed this in #796 Feb 6, 2017

bterlson added a commit that referenced this issue Feb 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment