Skip to content

Commit

Permalink
Merge pull request #401 from ydah/add-support-rhs
Browse files Browse the repository at this point in the history
Add support for RHS of user-defined parameterizing rules contain `symbol? `, `symbol+`, and `symbol*`
  • Loading branch information
yui-knk authored Apr 28, 2024
2 parents 2a0ac76 + 2800d94 commit 62a94f9
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 96 deletions.
142 changes: 71 additions & 71 deletions lib/lrama/parser.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ rule
builder.symbols << token
result = builder
}
| rule_rhs IDENTIFIER parameterizing_suffix
| rule_rhs symbol parameterizing_suffix
{
builder = val[0]
builder.symbols << Lrama::Lexer::Token::InstantiateRule.new(s_value: val[2], location: @lexer.location, args: [val[1]])
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/parameterizing_rules/user_defined_with_nest.y
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ static int yyerror(YYLTYPE *loc, const char *str);
| nested_multi_option(Y) X
;

%rule with_word_seps(X): /* empty */
| X ' '+
;

%%

program : option(number)
| multi_option(number, string)
| with_word_seps(string)
;

%%
Expand Down
Loading

0 comments on commit 62a94f9

Please sign in to comment.