diff options
Diffstat (limited to 'tool/lrama/lib')
-rw-r--r-- | tool/lrama/lib/lrama/grammar/code/rule_action.rb | 20 | ||||
-rw-r--r-- | tool/lrama/lib/lrama/version.rb | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tool/lrama/lib/lrama/grammar/code/rule_action.rb b/tool/lrama/lib/lrama/grammar/code/rule_action.rb index 2c274c67ec..984c350b25 100644 --- a/tool/lrama/lib/lrama/grammar/code/rule_action.rb +++ b/tool/lrama/lib/lrama/grammar/code/rule_action.rb @@ -14,9 +14,23 @@ module Lrama # * ($1) yyvsp[i] # * (@1) yylsp[i] # + # + # Consider a rule like + # + # class: keyword_class { $1 } tSTRING { $2 + $3 } keyword_end { $class = $1 + $keyword_end } + # + # For the semantic action of original rule: + # + # "Rule" class: keyword_class { $1 } tSTRING { $2 + $3 } keyword_end { $class = $1 + $keyword_end } + # "Position in grammar" $1 $2 $3 $4 $5 $6 + # "Index for yyvsp" -4 -3 -2 -1 0 + # + # + # For the first midrule action: + # # "Rule" class: keyword_class { $1 } tSTRING { $2 + $3 } keyword_end { $class = $1 + $keyword_end } - # "Position in grammar" $1 $2 $3 $4 $5 $6 - # "Index for yyvsp" -4 -3 -2 -1 0 + # "Position in grammar" $1 + # "Index for yyvsp" 0 def reference_to_c(ref) case when ref.type == :dollar && ref.name == "$" # $$ @@ -45,10 +59,12 @@ module Lrama @rule.position_in_original_rule_rhs || @rule.rhs.count end + # If this is midrule action, RHS is a RHS of the original rule. def rhs (@rule.original_rule || @rule).rhs end + # Unlike `rhs`, LHS is always a LHS of the rule. def lhs @rule.lhs end diff --git a/tool/lrama/lib/lrama/version.rb b/tool/lrama/lib/lrama/version.rb index 42fb926aca..3e68736482 100644 --- a/tool/lrama/lib/lrama/version.rb +++ b/tool/lrama/lib/lrama/version.rb @@ -1,3 +1,3 @@ module Lrama - VERSION = "0.5.11".freeze + VERSION = "0.5.12".freeze end |