I've written a very simple parser in jison, but there seems to be an S/R conflict in this grammar:
/* lexical grammar */
%lex
%%
\s+ /* skip whitespace */
":" return ':'
"." return '.'
[a-zA-Z_][a-zA-Z0-9_]* return 'IDENTIFIER'
<<EOF>> return 'EOF'
. return 'INVALID'
/lex
/* operator associations and precedence */
%start expressions
%% /* language grammar */
expressions
: statements EOF
{return $1;}
;
statements: statements statement {$$ = [$1].concat($2);} | statement {$$ =
[$1];};
statement:
IDENTIFIER ":" grammar_and {[$$ = ["grammar_rule",$1,$3]]};
grammar_and:
grammar_and IDENTIFIER {$$= [$1,$2]} | IDENTIFIER;
It is intended to parse documents like this one, which consists of 4 statements:
first: this is a sentence
second: this is another sentence
something: more words here another: more words here
but it doesn't work as I intended:
Conflicts encountered:
Resolve S/R conflict (shift by default.)
(1,10, 2,4) -> 1,10
Is it possible to resolve this conflict without modifying the syntax of the language that is being parsed?