Skip to content

Commit

Permalink
Add support for Named Reference in parameterizing rules callers
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed May 4, 2024
1 parent 0e351db commit 2715342
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 64 deletions.
118 changes: 59 additions & 59 deletions lib/lrama/parser.rb

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

8 changes: 4 additions & 4 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,17 @@ rule
builder.add_rhs(token)
result = builder
}
| rhs symbol parameterizing_suffix tag_opt
| rhs symbol parameterizing_suffix named_ref_opt tag_opt
{
token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[2], location: @lexer.location, args: [val[1]], lhs_tag: val[3])
token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[2], alias_name: val[3], location: @lexer.location, args: [val[1]], lhs_tag: val[4])
builder = val[0]
builder.add_rhs(token)
builder.line = val[1].first_line
result = builder
}
| rhs IDENTIFIER "(" parameterizing_args ")" tag_opt
| rhs IDENTIFIER "(" parameterizing_args ")" named_ref_opt tag_opt
{
token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[1].s_value, location: @lexer.location, args: val[3], lhs_tag: val[5])
token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[1].s_value, alias_name: val[5], location: @lexer.location, args: val[3], lhs_tag: val[6])
builder = val[0]
builder.add_rhs(token)
builder.line = val[1].first_line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ stmts: separated_list(';', stmt)
;

stmt: pair(ODD, EVEN) <num> { printf("pair odd even: %d\n", $1); }
| pair(EVEN, ODD) <num> { printf("pair even odd: %d\n", $1); }
| pair(EVEN, ODD)[result] <num> { printf("pair even odd: %d\n", $result); }
;

%%
Expand Down

0 comments on commit 2715342

Please sign in to comment.