diff --git a/Gemfile b/Gemfile index b50b3b3be..f59ec2123 100644 --- a/Gemfile +++ b/Gemfile @@ -7,9 +7,10 @@ gemspec gem "memory_profiler" gem "pry" gem "racc", "1.8.1" -gem "railroad_diagrams", "0.3.0" +gem "railroad_diagrams", ">= 1.0.0" gem "rake" gem "rdoc" +gem "rexml", require: false gem "rspec" gem "simplecov", require: false gem "stackprof", platforms: [:ruby] # stackprof doesn't support Windows diff --git a/doc/Index.md b/doc/Index.md index 22bf0fdc0..3b36ff052 100644 --- a/doc/Index.md +++ b/doc/Index.md @@ -47,6 +47,20 @@ Enter the formula: => 9 ``` +### Syntax diagrams + +Install `railroad_diagrams` 1.0.0 or later to generate SVG diagrams with links to +referenced rules and links back to referencing rules: + +```shell +$ lrama --diagram=diagram.html -o calc.c sample/calc.y +``` + +Open `diagram.html` in a browser. Click a nonterminal symbol to visit its rule +or follow the referencing-rule links to navigate back. + +Midrule action symbols are omitted from diagrams. User-defined empty rules remain visible. + ## Supported Ruby version Lrama is executed with BASERUBY when building ruby from source code. Therefore Lrama needs to support BASERUBY, currently 3.1, or later version. diff --git a/lib/lrama/diagram.rb b/lib/lrama/diagram.rb index 985808933..f2c518bda 100644 --- a/lib/lrama/diagram.rb +++ b/lib/lrama/diagram.rb @@ -29,7 +29,6 @@ def initialize(out:, grammar:, template_name: 'diagram/diagram.html') # @rbs () -> void def render - RailroadDiagrams::TextDiagram.set_formatting(RailroadDiagrams::TextDiagram::PARTS_UNICODE) @out << ERB.render(template_file, output: self) end @@ -38,21 +37,19 @@ def default_style RailroadDiagrams::Style::default_style end - # @rbs () -> string - def diagrams - result = +'' - @grammar.unique_rule_s_values.each do |s_value| - diagrams = - @grammar.select_rules_by_s_value(s_value).map { |r| r.to_diagrams } - add_diagram( - s_value, - RailroadDiagrams::Diagram.new( - RailroadDiagrams::Choice.new(0, *diagrams), - ), - result - ) + # @rbs () -> Array[Hash[Symbol, (String | Array[String])]] + def linked_sections + document = RailroadDiagrams::Document.new(title: "Lrama syntax diagrams", theme: :default) + action_symbols = @grammar.rules.select(&:original_rule).map(&:lhs) + @grammar.rules.reject(&:original_rule).group_by { |rule| rule.lhs.id.s_value }.each do |name, rules| + alternatives = rules.map do |rule| + diagram_rule = rule.dup + diagram_rule.rhs = rule.rhs - action_symbols + diagram_rule.to_diagrams + end + document.add_rule(name, RailroadDiagrams::Choice.new(0, *alternatives)) end - result + document.rule_sections end private @@ -67,11 +64,5 @@ def template_file File.join(template_dir, @template_name) end - # @rbs (String name, RailroadDiagrams::Diagram diagram, String result) -> void - def add_diagram(name, diagram, result) - result << "\n

#{RailroadDiagrams.escape_html(name)}

" - diagram.write_svg(result.method(:<<)) - result << "\n" - end end end diff --git a/sample/diagram.html b/sample/diagram.html index 0eac74493..e50f1716e 100644 --- a/sample/diagram.html +++ b/sample/diagram.html @@ -1,8 +1,9 @@ - + + + Lrama syntax diagrams - - - - -

$accept

+ +

Lrama syntax diagrams

+
+

$accept

+
-program -END_OF_INPUT - -

$@1

- - - - - - -

option_terms

+program +END_OF_INPUT
+
+
+

option_terms

+
-terms - -

compstmt_top_stmts

+terms
+

Referenced by: + compstmt_top_stmts + compstmt_stmts + primary + opt_ensure +

+
+
+

compstmt_top_stmts

+
-top_stmts -option_terms - -

program

+top_stmts +option_terms
+

Referenced by: + program + begin_block +

+
+
+

program

+
- - -$@1 -compstmt_top_stmts - -

top_stmts

+ + +compstmt_top_stmts
+

Referenced by: + $accept +

+
+
+

top_stmts

+
-none +none -top_stmt +top_stmt -top_stmts -terms -top_stmt - -

top_stmt

+top_stmts +terms +top_stmt
+

Referenced by: + compstmt_top_stmts + top_stmts +

+
+
+

top_stmt

+
-stmt +stmt keyword_BEGIN -begin_block - -

block_open

+begin_block
+

Referenced by: + top_stmts +

+
+
+

block_open

+
-'{' - -

begin_block

+'{'
+

Referenced by: + begin_block +

+
+
+

begin_block

+
-block_open -compstmt_top_stmts -'}' - -

compstmt_stmts

+block_open +compstmt_top_stmts +'}'
+

Referenced by: + top_stmt + stmt_or_begin +

+
+
+

compstmt_stmts

+
-stmts -option_terms - -

$@2

- - - - - - -

$@3

- - - - - - -

bodystmt

- - - - - -compstmt_stmts -lex_ctxt -opt_rescue -k_else -$@2 -compstmt_stmts -$@3 -opt_ensure - -compstmt_stmts -lex_ctxt -opt_rescue -$@4 -opt_ensure - -

$@4

- - - - - - -

stmts

+stmts +option_terms
+

Referenced by: + bodystmt + stmt + primary + if_tail + opt_else + lambda_body + brace_body + case_body + p_case_body + opt_rescue + string_content +

+
+
+

bodystmt

+
+ + + + + +compstmt_stmts +lex_ctxt +opt_rescue +k_else +compstmt_stmts +opt_ensure + +compstmt_stmts +lex_ctxt +opt_rescue +opt_ensure
+

Referenced by: + primary + lambda_body + do_body +

+
+
+

stmts

+
-none +none -stmt_or_begin +stmt_or_begin -stmts -terms -stmt_or_begin - -

stmt_or_begin

+stmts +terms +stmt_or_begin
+

Referenced by: + compstmt_stmts + stmts + opt_ensure +

+
+
+

stmt_or_begin

+
- - -stmt - + + +stmt + keyword_BEGIN -$@5 -begin_block - -

$@5

- - - - - - -

allow_exits

+begin_block
+

Referenced by: + stmts +

+
+
+

allow_exits

+
- - -

k_END

+
+

Referenced by: + stmt + k_while + k_until + k_for + lambda + brace_body + do_body +

+
+
+

k_END

+
keyword_END -lex_ctxt - -

$@6

- - - - - - -

stmt

+lex_ctxt
+

Referenced by: + stmt +

+
+
+

stmt

+
- -keyword_alias -fitem -$@6 -fitem + +keyword_alias +fitem +fitem keyword_alias tGVAR @@ -296,629 +337,794 @@

stmt

tNTH_REF keyword_undef -undef_list +undef_list -stmt +stmt modifier_if -expr_value +expr_value -stmt +stmt modifier_unless -expr_value +expr_value -stmt +stmt modifier_while -expr_value +expr_value -stmt +stmt modifier_until -expr_value +expr_value -stmt +stmt modifier_rescue -after_rescue -stmt +after_rescue +stmt -k_END -allow_exits +k_END +allow_exits '{' -compstmt_stmts +compstmt_stmts '}' -command_asgn +command_asgn -mlhs +mlhs '=' -lex_ctxt -command_call_value +lex_ctxt +command_call_value -asgn_lhs_mrhs +asgn_lhs_mrhs -mlhs +mlhs '=' -lex_ctxt -mrhs_arg +lex_ctxt +mrhs_arg modifier_rescue -after_rescue -stmt +after_rescue +stmt -mlhs +mlhs '=' -lex_ctxt -mrhs_arg +lex_ctxt +mrhs_arg -expr +expr -YYerror - -

asgn_lhs_mrhs

+YYerror
+

Referenced by: + top_stmt + stmt_or_begin + stmt + command_rhs +

+
+
+

asgn_lhs_mrhs

+
-lhs +lhs '=' -lex_ctxt -mrhs - -

asgn_lhs_command_rhs

+lex_ctxt +mrhs
+

Referenced by: + stmt +

+
+
+

asgn_lhs_command_rhs

+
-lhs +lhs '=' -lex_ctxt -command_rhs - -

command_asgn

+lex_ctxt +command_rhs
+

Referenced by: + command_asgn +

+
+
+

command_asgn

+
-asgn_lhs_command_rhs +asgn_lhs_command_rhs -op_asgn_command_rhs +op_asgn_command_rhs -def_endless_method_endless_command - -

op_asgn_command_rhs

+def_endless_method_endless_command
+

Referenced by: + stmt + command_rhs +

+
+
+

op_asgn_command_rhs

+
-var_lhs +var_lhs tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -primary_value +primary_value '[' -opt_call_args -rbracket +opt_call_args +rbracket tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -primary_value -call_op +primary_value +call_op tIDENTIFIER tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -primary_value -call_op +primary_value +call_op tCONSTANT tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -primary_value +primary_value tCOLON2 tIDENTIFIER tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -primary_value +primary_value tCOLON2 tCONSTANT tOP_ASGN -lex_ctxt -command_rhs +lex_ctxt +command_rhs -backref +backref tOP_ASGN -lex_ctxt -command_rhs - -

def_endless_method_endless_command

+lex_ctxt +command_rhs
+

Referenced by: + command_asgn +

+
+
+

def_endless_method_endless_command

+
-defn_head -f_opt_paren_args +defn_head +f_opt_paren_args '=' -endless_command +endless_command -defs_head -f_opt_paren_args +defs_head +f_opt_paren_args '=' -endless_command - -

endless_command

+endless_command
+

Referenced by: + command_asgn +

+
+
+

endless_command

+
-command +command -endless_command +endless_command modifier_rescue -after_rescue -arg +after_rescue +arg keyword_not -option_'\n' -endless_command - -

option_'\n'

+option_'\n' +endless_command
+

Referenced by: + def_endless_method_endless_command + endless_command +

+
+
+

option_'\n'

+
-'\n' - -

command_rhs

+'\n'
+

Referenced by: + endless_command + expr + arg + endless_arg + primary + opt_bv_decl + rparen + rbracket + rbrace + trailer +

+
+
+

command_rhs

+
-command_call_value +command_call_value -command_call_value +command_call_value modifier_rescue -after_rescue -stmt +after_rescue +stmt -command_asgn - -

expr

- - - - - -command_call - -expr -keyword_and -expr - -expr -keyword_or -expr - -keyword_not -option_'\n' -expr - -'!' -command_call - -arg +command_asgn
+

Referenced by: + asgn_lhs_command_rhs + op_asgn_command_rhs +

+
+
+

expr

+
+ + + + + +command_call + +expr +keyword_and +expr + +expr +keyword_or +expr + +keyword_not +option_'\n' +expr + +'!' +command_call + +arg tASSOC -$@7 -p_in_kwarg -p_pvtbl -p_pktbl -p_top_expr_body - -arg +p_in_kwarg +p_pvtbl +p_pktbl +p_top_expr_body + +arg keyword_in -$@8 -p_in_kwarg -p_pvtbl -p_pktbl -p_top_expr_body - -arg - -

$@7

- - - - - - -

$@8

- - - - - - -

def_name

+p_in_kwarg +p_pvtbl +p_pktbl +p_top_expr_body + +arg
+

Referenced by: + stmt + expr + value_expr_expr + primary + singleton +

+
+
+

def_name

+
-fname - -

defn_head

+fname
+

Referenced by: + defn_head + defs_head +

+
+
+

defn_head

+
-k_def -def_name - -

$@9

- - - - - - -

defs_head

+k_def +def_name
+

Referenced by: + def_endless_method_endless_command + def_endless_method_endless_arg + primary +

+
+
+

defs_head

+
- - -k_def -singleton -dot_or_colon -$@9 -def_name - -

value_expr_expr

+ + +k_def +singleton +dot_or_colon +def_name
+

Referenced by: + def_endless_method_endless_command + def_endless_method_endless_arg + primary +

+
+
+

value_expr_expr

+
-expr - -

expr_value

+expr
+

Referenced by: + expr_value +

+
+
+

expr_value

+
-value_expr_expr +value_expr_expr -YYerror - -

$@10

- - - - - - -

$@11

- - - - - - -

expr_value_do

+YYerror
+

Referenced by: + stmt + expr_value_do + primary + if_tail + p_top_expr + p_expr_ref + superclass +

+
+
+

expr_value_do

+
- - -$@10 -expr_value -do -$@11 - -

command_call

+ + +expr_value +do
+

Referenced by: + primary +

+
+
+

command_call

+
-command +command -block_command - -

value_expr_command_call

+block_command
+

Referenced by: + expr + value_expr_command_call +

+
+
+

value_expr_command_call

+
-command_call - -

command_call_value

+command_call
+

Referenced by: + command_call_value +

+
+
+

command_call_value

+
-value_expr_command_call - -

block_command

+value_expr_command_call
+

Referenced by: + stmt + command_rhs +

+
+
+

block_command

+
-block_call +block_call -block_call -call_op2 -operation2 -command_args - -

cmd_brace_block

+block_call +call_op2 +operation2 +command_args
+

Referenced by: + command_call +

+
+
+

cmd_brace_block

+
tLBRACE_ARG -brace_body -'}' - -

fcall

+brace_body +'}'
+

Referenced by: + command +

+
+
+

fcall

+
-operation - -

command

+operation
+

Referenced by: + command + primary + method_call +

+
+
+

command

+
-fcall -command_args +fcall +command_args -fcall -command_args -cmd_brace_block +fcall +command_args +cmd_brace_block -primary_value -call_op -operation2 -command_args +primary_value +call_op +operation2 +command_args -primary_value -call_op -operation2 -command_args -cmd_brace_block +primary_value +call_op +operation2 +command_args +cmd_brace_block -primary_value +primary_value tCOLON2 -operation2 -command_args +operation2 +command_args -primary_value +primary_value tCOLON2 -operation2 -command_args -cmd_brace_block +operation2 +command_args +cmd_brace_block -primary_value +primary_value tCOLON2 tCONSTANT '{' -brace_body +brace_body '}' keyword_super -command_args +command_args -k_yield -command_args +k_yield +command_args -k_return -call_args +k_return +call_args keyword_break -call_args +call_args keyword_next -call_args - -

mlhs

+call_args
+

Referenced by: + endless_command + command_call + value_expr_command + block_call +

+
+
+

mlhs

+
-mlhs_basic +mlhs_basic tLPAREN -mlhs_inner -rparen - -

mlhs_inner

+mlhs_inner +rparen
+

Referenced by: + stmt + for_var +

+
+
+

mlhs_inner

+
-mlhs_basic +mlhs_basic tLPAREN -mlhs_inner -rparen - -

mlhs_basic

+mlhs_inner +rparen
+

Referenced by: + mlhs + mlhs_inner + mlhs_item +

+
+
+

mlhs_basic

+
-mlhs_head +mlhs_head -mlhs_head -mlhs_item +mlhs_head +mlhs_item -mlhs_head +mlhs_head tSTAR -mlhs_node +mlhs_node -mlhs_head +mlhs_head tSTAR -mlhs_node +mlhs_node ',' -mlhs_post +mlhs_post -mlhs_head +mlhs_head tSTAR -mlhs_head +mlhs_head tSTAR ',' -mlhs_post +mlhs_post tSTAR -mlhs_node +mlhs_node tSTAR -mlhs_node +mlhs_node ',' -mlhs_post +mlhs_post tSTAR tSTAR ',' -mlhs_post - -

mlhs_item

+mlhs_post
+

Referenced by: + mlhs + mlhs_inner +

+
+
+

mlhs_item

+
-mlhs_node +mlhs_node tLPAREN -mlhs_inner -rparen - -

mlhs_head

+mlhs_inner +rparen
+

Referenced by: + mlhs_basic + mlhs_head + mlhs_post +

+
+
+

mlhs_head

+
-mlhs_item +mlhs_item ',' -mlhs_head -mlhs_item -',' - -

mlhs_post

+mlhs_head +mlhs_item +','
+

Referenced by: + mlhs_basic + mlhs_head +

+
+
+

mlhs_post

+
-mlhs_item +mlhs_item -mlhs_post +mlhs_post ',' -mlhs_item - -

mlhs_node

+mlhs_item
+

Referenced by: + mlhs_basic + mlhs_post +

+
+
+

mlhs_node

+
-user_variable +user_variable -keyword_variable +keyword_variable -primary_value +primary_value '[' -opt_call_args -rbracket +opt_call_args +rbracket -primary_value -call_op +primary_value +call_op tIDENTIFIER -primary_value -call_op +primary_value +call_op tCONSTANT -primary_value +primary_value tCOLON2 tIDENTIFIER -primary_value +primary_value tCOLON2 tCONSTANT tCOLON3 tCONSTANT -backref - -

lhs

+backref
+

Referenced by: + mlhs_basic + mlhs_item +

+
+
+

lhs

+
-user_variable +user_variable -keyword_variable +keyword_variable -primary_value +primary_value '[' -opt_call_args -rbracket +opt_call_args +rbracket -primary_value -call_op +primary_value +call_op tIDENTIFIER -primary_value +primary_value tCOLON2 tIDENTIFIER -primary_value -call_op +primary_value +call_op tCONSTANT -primary_value +primary_value tCOLON2 tCONSTANT tCOLON3 tCONSTANT -backref - -

cname

+backref
+

Referenced by: + asgn_lhs_mrhs + asgn_lhs_command_rhs + asgn_lhs_arg_rhs + for_var + exc_var +

+
+
+

cname

+
@@ -926,24 +1132,35 @@

cname

tIDENTIFIER -tCONSTANT - -

cpath

+tCONSTANT
+

Referenced by: + cpath + p_const +

+
+
+

cpath

+
tCOLON3 -cname +cname -cname +cname -primary_value +primary_value tCOLON2 -cname - -

fname

+cname
+

Referenced by: + primary +

+
+
+

fname

+
@@ -955,41 +1172,52 @@

fname

tFID -op +op -reswords - -

fitem

+reswords
+

Referenced by: + def_name + fitem + sym +

+
+
+

fitem

+
-fname +fname -symbol - -

undef_list

+symbol
+

Referenced by: + stmt + undef_list +

+
+
+

undef_list

+
- - -fitem - -undef_list + + +fitem + +undef_list ',' -$@12 -fitem - -

$@12

- - - - - - -

op

+fitem
+

Referenced by: + stmt + undef_list +

+
+
+

op

+
@@ -1011,7 +1239,7 @@

op

tNMATCH -'>' +'>' tGEQ @@ -1053,9 +1281,16 @@

op

tASET
-'`'
- -

reswords

+'`'
+

Referenced by: + fname + operation2 + operation3 +

+
+
+

reswords

+
@@ -1141,949 +1376,1155 @@

reswords

keyword_while -keyword_until - -

asgn_lhs_arg_rhs

+keyword_until
+

Referenced by: + fname +

+
+
+

asgn_lhs_arg_rhs

+
-lhs +lhs '=' -lex_ctxt -arg_rhs - -

arg

+lex_ctxt +arg_rhs
+

Referenced by: + arg +

+
+
+

arg

+
-asgn_lhs_arg_rhs +asgn_lhs_arg_rhs -op_asgn_arg_rhs +op_asgn_arg_rhs tCOLON3 tCONSTANT tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -arg +arg tDOT2 -arg +arg -arg +arg tDOT3 -arg +arg -arg +arg tDOT2 -arg +arg tDOT3 tBDOT2 -arg +arg tBDOT3 -arg +arg -arg +arg '+' -arg +arg -arg +arg '-' -arg +arg -arg +arg '*' -arg +arg -arg +arg '/' -arg +arg -arg +arg '%' -arg +arg -arg +arg tPOW -arg +arg tUMINUS_NUM -simple_numeric +simple_numeric tPOW -arg +arg tUPLUS -arg +arg tUMINUS -arg +arg -arg +arg '|' -arg +arg -arg +arg '^' -arg +arg -arg +arg '&' -arg +arg -arg +arg tCMP -arg +arg -rel_expr +rel_expr -arg +arg tEQ -arg +arg -arg +arg tEQQ -arg +arg -arg +arg tNEQ -arg +arg -arg +arg tMATCH -arg +arg -arg +arg tNMATCH -arg +arg '!' -arg +arg '~' -arg +arg -arg +arg tLSHFT -arg +arg -arg +arg tRSHFT -arg +arg -arg +arg tANDOP -arg +arg -arg +arg tOROP -arg +arg keyword_defined -option_'\n' -begin_defined -arg +option_'\n' +begin_defined +arg -arg +arg '?' -arg -option_'\n' +arg +option_'\n' ':' -arg +arg -def_endless_method_endless_arg +def_endless_method_endless_arg -primary - -

op_asgn_arg_rhs

+primary
+

Referenced by: + endless_command + expr + arg + endless_arg + rel_expr + value_expr_arg + arg_rhs +

+
+
+

op_asgn_arg_rhs

+
-var_lhs +var_lhs tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -primary_value +primary_value '[' -opt_call_args -rbracket +opt_call_args +rbracket tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -primary_value -call_op +primary_value +call_op tIDENTIFIER tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -primary_value -call_op +primary_value +call_op tCONSTANT tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -primary_value +primary_value tCOLON2 tIDENTIFIER tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -primary_value +primary_value tCOLON2 tCONSTANT tOP_ASGN -lex_ctxt -arg_rhs +lex_ctxt +arg_rhs -backref +backref tOP_ASGN -lex_ctxt -arg_rhs - -

def_endless_method_endless_arg

+lex_ctxt +arg_rhs
+

Referenced by: + arg +

+
+
+

def_endless_method_endless_arg

+
-defn_head -f_opt_paren_args +defn_head +f_opt_paren_args '=' -endless_arg +endless_arg -defs_head -f_opt_paren_args +defs_head +f_opt_paren_args '=' -endless_arg - -

endless_arg

+endless_arg
+

Referenced by: + arg +

+
+
+

endless_arg

+
-arg +arg -endless_arg +endless_arg modifier_rescue -after_rescue -arg +after_rescue +arg keyword_not -option_'\n' -endless_arg - -

relop

+option_'\n' +endless_arg
+

Referenced by: + def_endless_method_endless_arg + endless_arg +

+
+
+

relop

+
-'>' +'>' '<' tGEQ -tLEQ - -

rel_expr

+tLEQ
+

Referenced by: + rel_expr +

+
+
+

rel_expr

+
-arg -relop -arg +arg +relop +arg -rel_expr -relop -arg - -

lex_ctxt

+rel_expr +relop +arg
+

Referenced by: + arg + rel_expr +

+
+
+

lex_ctxt

+
-none - -

begin_defined

+none
+

Referenced by: + bodystmt + k_END + stmt + asgn_lhs_mrhs + asgn_lhs_command_rhs + op_asgn_command_rhs + asgn_lhs_arg_rhs + arg + op_asgn_arg_rhs + begin_defined + after_rescue + p_expr_basic +

+
+
+

begin_defined

+
-lex_ctxt - -

after_rescue

+lex_ctxt
+

Referenced by: + arg + primary +

+
+
+

after_rescue

+
-lex_ctxt - -

value_expr_arg

+lex_ctxt
+

Referenced by: + stmt + endless_command + command_rhs + endless_arg + arg_rhs +

+
+
+

value_expr_arg

+
-arg - -

arg_value

+arg
+

Referenced by: + arg_value +

+
+
+

arg_value

+
-value_expr_arg - -

aref_args

+value_expr_arg
+

Referenced by: + block_arg + args + arg_splat + mrhs_arg + mrhs + case_args + exc_list + f_kw_arg_value + f_opt_arg_value + assoc +

+
+
+

aref_args

+
-none +none -args -trailer +args +trailer -args +args ',' -assocs -trailer +assocs +trailer -assocs -trailer - -

arg_rhs

+assocs +trailer
+

Referenced by: + primary +

+
+
+

arg_rhs

+
-arg +arg -arg +arg modifier_rescue -after_rescue -arg - -

paren_args

+after_rescue +arg
+

Referenced by: + asgn_lhs_arg_rhs + arg + op_asgn_arg_rhs +

+
+
+

paren_args

+
'(' -opt_call_args -rparen +opt_call_args +rparen '(' -args +args ',' -args_forward -rparen +args_forward +rparen '(' -args_forward -rparen - -

opt_paren_args

+args_forward +rparen
+

Referenced by: + opt_paren_args + method_call +

+
+
+

opt_paren_args

+
-none +none -paren_args - -

opt_call_args

+paren_args
+

Referenced by: + block_call + method_call +

+
+
+

opt_call_args

+
-none +none -call_args +call_args -args +args ',' -args +args ',' -assocs +assocs ',' -assocs -',' - -

value_expr_command

+assocs +','
+

Referenced by: + op_asgn_command_rhs + mlhs_node + lhs + op_asgn_arg_rhs + paren_args + method_call +

+
+
+

value_expr_command

+
-command - -

call_args

+command
+

Referenced by: + call_args +

+
+
+

call_args

+
-value_expr_command +value_expr_command -args -opt_block_arg +args +opt_block_arg -assocs -opt_block_arg +assocs +opt_block_arg -args +args ',' -assocs -opt_block_arg +assocs +opt_block_arg -block_arg - -

$@13

- - - - - - -

command_args

+block_arg
+

Referenced by: + command + opt_call_args + command_args + primary +

+
+
+

command_args

+
- - -$@13 -call_args - -

block_arg

+ + +call_args
+

Referenced by: + block_command + command + block_call +

+
+
+

block_arg

+
tAMPER -arg_value +arg_value -tAMPER - -

opt_block_arg

+tAMPER
+

Referenced by: + call_args + opt_block_arg +

+
+
+

opt_block_arg

+
',' -block_arg +block_arg -none - -

args

+none
+

Referenced by: + call_args +

+
+
+

args

+
-arg_value +arg_value -arg_splat +arg_splat -args +args ',' -arg_value +arg_value -args +args ',' -arg_splat - -

arg_splat

+arg_splat
+

Referenced by: + aref_args + paren_args + opt_call_args + call_args + args + mrhs +

+
+
+

arg_splat

+
tSTAR -arg_value +arg_value -tSTAR - -

mrhs_arg

+tSTAR
+

Referenced by: + args +

+
+
+

mrhs_arg

+
-mrhs +mrhs -arg_value - -

mrhs

+arg_value
+

Referenced by: + stmt +

+
+
+

mrhs

+
-args +args ',' -arg_value +arg_value -args +args ',' tSTAR -arg_value +arg_value tSTAR -arg_value - -

primary

- - - - - -literal - -strings - -xstring - -regexp - -words - -qwords - -symbols - -qsymbols - -var_ref - -backref - -tFID - -k_begin -$@14 -bodystmt -k_end - -tLPAREN_ARG -compstmt_stmts -$@15 -')' - -tLPAREN -compstmt_stmts -')' - -primary_value -tCOLON2 -tCONSTANT - -tCOLON3 -tCONSTANT - -tLBRACK -aref_args -']' - -tLBRACE -assoc_list -'}' - -k_return - -k_yield -'(' -call_args -rparen - -k_yield -'(' -rparen - -k_yield - -keyword_defined -option_'\n' -'(' -begin_defined -expr -rparen - -keyword_not -'(' -expr -rparen - -keyword_not -'(' -rparen - -fcall -brace_block - -method_call - -method_call -brace_block - -lambda - -k_if -expr_value -then -compstmt_stmts -if_tail -k_end - -k_unless -expr_value -then -compstmt_stmts -opt_else -k_end - -k_while -expr_value_do -compstmt_stmts -k_end - -k_until -expr_value_do -compstmt_stmts -k_end - -k_case -expr_value -option_terms -@16 -case_body -k_end - -k_case -option_terms -@17 -case_body -k_end - -k_case -expr_value -option_terms -p_case_body -k_end - -k_for -for_var +arg_value
+

Referenced by: + asgn_lhs_mrhs + mrhs_arg + exc_list +

+
+
+

primary

+
+ + + + + +literal + +strings + +xstring + +regexp + +words + +qwords + +symbols + +qsymbols + +var_ref + +backref + +tFID + +k_begin +bodystmt +k_end + +tLPAREN_ARG +compstmt_stmts +')' + +tLPAREN +compstmt_stmts +')' + +primary_value +tCOLON2 +tCONSTANT + +tCOLON3 +tCONSTANT + +tLBRACK +aref_args +']' + +tLBRACE +assoc_list +'}' + +k_return + +k_yield +'(' +call_args +rparen + +k_yield +'(' +rparen + +k_yield + +keyword_defined +option_'\n' +'(' +begin_defined +expr +rparen + +keyword_not +'(' +expr +rparen + +keyword_not +'(' +rparen + +fcall +brace_block + +method_call + +method_call +brace_block + +lambda + +k_if +expr_value +then +compstmt_stmts +if_tail +k_end + +k_unless +expr_value +then +compstmt_stmts +opt_else +k_end + +k_while +expr_value_do +compstmt_stmts +k_end + +k_until +expr_value_do +compstmt_stmts +k_end + +k_case +expr_value +option_terms +case_body +k_end + +k_case +option_terms +case_body +k_end + +k_case +expr_value +option_terms +p_case_body +k_end + +k_for +for_var keyword_in -$@18 -expr_value -do -$@19 -compstmt_stmts -k_end - -k_class -cpath -superclass -$@20 -bodystmt -k_end - -k_class -tLSHFT -expr_value -$@21 -term -bodystmt -k_end - -k_module -cpath -$@22 -bodystmt -k_end - -defn_head -f_arglist -$@23 -bodystmt -k_end - -defs_head -f_arglist -$@24 -bodystmt -k_end - -keyword_break - -keyword_next - -keyword_redo - -keyword_retry - -

$@14

- - - - - - -

$@15

- - - - - - -

@16

- - - - - - -

@17

- - - - - - -

$@18

- - - - - - -

$@19

- - - - - - -

$@20

- - - - - - -

$@21

- - - - - - -

$@22

- - - - - - -

$@23

- - - - - - -

$@24

- - - - - - -

value_expr_primary

+expr_value +do +compstmt_stmts +k_end + +k_class +cpath +superclass +bodystmt +k_end + +k_class +tLSHFT +expr_value +term +bodystmt +k_end + +k_module +cpath +bodystmt +k_end + +defn_head +f_arglist +bodystmt +k_end + +defs_head +f_arglist +bodystmt +k_end + +keyword_break + +keyword_next + +keyword_redo + +keyword_retry
+

Referenced by: + arg + value_expr_primary +

+
+
+

value_expr_primary

+
-primary - -

primary_value

+primary
+

Referenced by: + primary_value +

+
+
+

primary_value

+
-value_expr_primary - -

k_begin

+value_expr_primary
+

Referenced by: + op_asgn_command_rhs + command + mlhs_node + lhs + cpath + op_asgn_arg_rhs + primary + f_kw_primary_value + f_opt_primary_value + method_call +

+
+
+

k_begin

+
-keyword_begin - -

k_if

+keyword_begin
+

Referenced by: + primary +

+
+
+

k_if

+
-keyword_if - -

k_unless

+keyword_if
+

Referenced by: + primary +

+
+
+

k_unless

+
-keyword_unless - -

k_while

+keyword_unless
+

Referenced by: + primary +

+
+
+

k_while

+
keyword_while -allow_exits - -

k_until

+allow_exits
+

Referenced by: + primary +

+
+
+

k_until

+
keyword_until -allow_exits - -

k_case

+allow_exits
+

Referenced by: + primary +

+
+
+

k_case

+
-keyword_case - -

k_for

+keyword_case
+

Referenced by: + primary +

+
+
+

k_for

+
keyword_for -allow_exits - -

k_class

+allow_exits
+

Referenced by: + primary +

+
+
+

k_class

+
-keyword_class - -

k_module

+keyword_class
+

Referenced by: + primary +

+
+
+

k_module

+
-keyword_module - -

k_def

+keyword_module
+

Referenced by: + primary +

+
+
+

k_def

+
-keyword_def - -

k_do

+keyword_def
+

Referenced by: + defn_head + defs_head +

+
+
+

k_do

+
-keyword_do - -

k_do_block

+keyword_do
+

Referenced by: + brace_block +

+
+
+

k_do_block

+
-keyword_do_block - -

k_rescue

+keyword_do_block
+

Referenced by: + do_block +

+
+
+

k_rescue

+
-keyword_rescue - -

k_ensure

+keyword_rescue
+

Referenced by: + opt_rescue +

+
+
+

k_ensure

+
-keyword_ensure - -

k_when

+keyword_ensure
+

Referenced by: + opt_ensure +

+
+
+

k_when

+
-keyword_when - -

k_else

+keyword_when
+

Referenced by: + case_body +

+
+
+

k_else

+
-keyword_else - -

k_elsif

+keyword_else
+

Referenced by: + bodystmt + opt_else +

+
+
+

k_elsif

+
-keyword_elsif - -

k_end

+keyword_elsif
+

Referenced by: + if_tail +

+
+
+

k_end

+
@@ -2091,382 +2532,528 @@

k_end

keyword_end -tDUMNY_END - -

k_return

+tDUMNY_END
+

Referenced by: + primary + lambda_body + do_block + brace_block +

+
+
+

k_return

+
-keyword_return - -

k_yield

+keyword_return
+

Referenced by: + command + primary +

+
+
+

k_yield

+
-keyword_yield - -

then

+keyword_yield
+

Referenced by: + command + primary +

+
+
+

then

+
-term +term keyword_then -term -keyword_then - -

do

+term +keyword_then
+

Referenced by: + primary + if_tail + case_body + p_case_body + opt_rescue +

+
+
+

do

+
-term +term -keyword_do_cond - -

if_tail

+keyword_do_cond
+

Referenced by: + expr_value_do + primary +

+
+
+

if_tail

+
-opt_else +opt_else -k_elsif -expr_value -then -compstmt_stmts -if_tail - -

opt_else

+k_elsif +expr_value +then +compstmt_stmts +if_tail
+

Referenced by: + primary + if_tail +

+
+
+

opt_else

+
-none +none -k_else -compstmt_stmts - -

for_var

+k_else +compstmt_stmts
+

Referenced by: + primary + if_tail + cases + p_cases +

+
+
+

for_var

+
-lhs +lhs -mlhs - -

f_marg

+mlhs
+

Referenced by: + primary +

+
+
+

f_marg

+
-f_norm_arg +f_norm_arg tLPAREN -f_margs -rparen - -

f_marg_list

+f_margs +rparen
+

Referenced by: + f_marg_list +

+
+
+

f_marg_list

+
-f_marg +f_marg -f_marg_list +f_marg_list ',' -f_marg - -

f_margs

+f_marg
+

Referenced by: + f_marg_list + f_margs +

+
+
+

f_margs

+
-f_marg_list +f_marg_list -f_marg_list +f_marg_list ',' -f_rest_marg +f_rest_marg -f_marg_list +f_marg_list ',' -f_rest_marg +f_rest_marg ',' -f_marg_list +f_marg_list -f_rest_marg +f_rest_marg -f_rest_marg +f_rest_marg ',' -f_marg_list - -

f_rest_marg

+f_marg_list
+

Referenced by: + f_marg + f_arg_item +

+
+
+

f_rest_marg

+
tSTAR -f_norm_arg +f_norm_arg -tSTAR - -

f_any_kwrest

+tSTAR
+

Referenced by: + f_margs +

+
+
+

f_any_kwrest

+
-f_kwrest +f_kwrest -f_no_kwarg - -

$@25

- - - - - - -

f_eq

+f_no_kwarg
+

Referenced by: + block_args_tail + args_tail +

+
+
+

f_eq

+
- - -$@25 -'=' - -

f_kw_primary_value

+ + +'='
+

Referenced by: + f_opt_primary_value + f_opt_arg_value +

+
+
+

f_kw_primary_value

+
-f_label -primary_value +f_label +primary_value -f_label - -

f_kwarg_primary_value

+f_label
+

Referenced by: + f_kwarg_primary_value +

+
+
+

f_kwarg_primary_value

+
-f_kw_primary_value +f_kw_primary_value -f_kwarg_primary_value +f_kwarg_primary_value ',' -f_kw_primary_value - -

block_args_tail

+f_kw_primary_value
+

Referenced by: + f_kwarg_primary_value + block_args_tail +

+
+
+

block_args_tail

+
-f_kwarg_primary_value +f_kwarg_primary_value ',' -f_kwrest -opt_f_block_arg +f_kwrest +opt_f_block_arg -f_kwarg_primary_value -opt_f_block_arg +f_kwarg_primary_value +opt_f_block_arg -f_any_kwrest -opt_f_block_arg +f_any_kwrest +opt_f_block_arg -f_block_arg - -

excessed_comma

+f_block_arg
+

Referenced by: + opt_args_tail_block_args_tail + block_param +

+
+
+

excessed_comma

+
-',' - -

f_opt_primary_value

+','
+

Referenced by: + block_param +

+
+
+

f_opt_primary_value

+
-f_arg_asgn -f_eq -primary_value - -

f_optarg_primary_value

+f_arg_asgn +f_eq +primary_value
+

Referenced by: + f_optarg_primary_value +

+
+
+

f_optarg_primary_value

+
-f_opt_primary_value +f_opt_primary_value -f_optarg_primary_value +f_optarg_primary_value ',' -f_opt_primary_value - -

opt_args_tail_block_args_tail

+f_opt_primary_value
+

Referenced by: + f_optarg_primary_value + block_param +

+
+
+

opt_args_tail_block_args_tail

+
',' -block_args_tail - - -

block_param

+block_args_tail +
+

Referenced by: + block_param +

+
+
+

block_param

+
-f_arg +f_arg ',' -f_optarg_primary_value +f_optarg_primary_value ',' -f_rest_arg -opt_args_tail_block_args_tail +f_rest_arg +opt_args_tail_block_args_tail -f_arg +f_arg ',' -f_optarg_primary_value +f_optarg_primary_value ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_arg +f_arg ',' -f_optarg_primary_value -opt_args_tail_block_args_tail +f_optarg_primary_value +opt_args_tail_block_args_tail -f_arg +f_arg ',' -f_optarg_primary_value +f_optarg_primary_value ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_arg +f_arg ',' -f_rest_arg -opt_args_tail_block_args_tail +f_rest_arg +opt_args_tail_block_args_tail -f_arg -excessed_comma +f_arg +excessed_comma -f_arg +f_arg ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_optarg_primary_value +f_optarg_primary_value ',' -f_rest_arg -opt_args_tail_block_args_tail +f_rest_arg +opt_args_tail_block_args_tail -f_optarg_primary_value +f_optarg_primary_value ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_optarg_primary_value -opt_args_tail_block_args_tail +f_optarg_primary_value +opt_args_tail_block_args_tail -f_optarg_primary_value +f_optarg_primary_value ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -f_rest_arg -opt_args_tail_block_args_tail +f_rest_arg +opt_args_tail_block_args_tail -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_block_args_tail +f_arg +opt_args_tail_block_args_tail -block_args_tail - -

opt_block_param

+block_args_tail
+

Referenced by: + block_param_def +

+
+
+

opt_block_param

+
-none +none -block_param_def - -

block_param_def

+block_param_def
+

Referenced by: + brace_body + do_body +

+
+
+

block_param_def

+
'|' -opt_bv_decl +opt_bv_decl '|' '|' -block_param -opt_bv_decl -'|' - -

opt_bv_decl

+block_param +opt_bv_decl +'|'
+

Referenced by: + opt_block_param +

+
+
+

opt_bv_decl

+
-option_'\n' +option_'\n' -option_'\n' +option_'\n' ';' -bv_decls -option_'\n' - -

bv_decls

+bv_decls +option_'\n'
+

Referenced by: + block_param_def + f_larglist +

+
+
+

bv_decls

+
-bvar +bvar -bv_decls +bv_decls ',' -bvar - -

bvar

+bvar
+

Referenced by: + opt_bv_decl + bv_decls +

+
+
+

bvar

+
@@ -2474,552 +3061,693 @@

bvar

tIDENTIFIER -f_bad_arg - -

max_numparam

- - - - - - -

numparam

- - - - - - -

it_id

+f_bad_arg
+

Referenced by: + bv_decls +

+
+
+

max_numparam

+
- - -

@26

+
+

Referenced by: + lambda + brace_body + do_body +

+
+
+

numparam

+
- - -

$@27

+
+

Referenced by: + lambda + brace_body + do_body +

+
+
+

it_id

+
- - -

lambda

+
+

Referenced by: + lambda + brace_body + do_body +

+
+
+

lambda

+
- - + + tLAMBDA -@26 -max_numparam -numparam -it_id -allow_exits -f_larglist -$@27 -lambda_body - -

f_larglist

+max_numparam +numparam +it_id +allow_exits +f_larglist +lambda_body
+

Referenced by: + primary + p_primitive +

+
+
+

f_larglist

+
'(' -f_args -opt_bv_decl +f_args +opt_bv_decl ')' -f_args - -

lambda_body

- - - - - -tLAMBEG -compstmt_stmts -'}' - +f_args
+

Referenced by: + lambda +

+
+
+

lambda_body

+
+ + + + + +tLAMBEG +compstmt_stmts +'}' + keyword_do_LAMBDA -$@28 -bodystmt -k_end - -

$@28

- - - - - - -

do_block

+bodystmt +k_end
+

Referenced by: + lambda +

+
+
+

do_block

+
-k_do_block -do_body -k_end - -

block_call

+k_do_block +do_body +k_end
+

Referenced by: + block_call +

+
+
+

block_call

+
-command -do_block +command +do_block -block_call -call_op2 -operation2 -opt_paren_args +block_call +call_op2 +operation2 +opt_paren_args -block_call -call_op2 -operation2 -opt_paren_args -brace_block +block_call +call_op2 +operation2 +opt_paren_args +brace_block -block_call -call_op2 -operation2 -command_args -do_block - -

method_call

+block_call +call_op2 +operation2 +command_args +do_block
+

Referenced by: + block_command + block_call +

+
+
+

method_call

+
-fcall -paren_args +fcall +paren_args -primary_value -call_op -operation2 -opt_paren_args +primary_value +call_op +operation2 +opt_paren_args -primary_value +primary_value tCOLON2 -operation2 -paren_args +operation2 +paren_args -primary_value +primary_value tCOLON2 -operation3 +operation3 -primary_value -call_op -paren_args +primary_value +call_op +paren_args -primary_value +primary_value tCOLON2 -paren_args +paren_args keyword_super -paren_args +paren_args keyword_super -primary_value +primary_value '[' -opt_call_args -rbracket - -

brace_block

+opt_call_args +rbracket
+

Referenced by: + primary +

+
+
+

brace_block

+
'{' -brace_body +brace_body '}' -k_do -do_body -k_end - -

@29

- - - - - - -

brace_body

- - - - - -@29 -max_numparam -numparam -it_id -allow_exits -opt_block_param -compstmt_stmts - -

@30

- - - - - - -

do_body

- - - - - -@30 -max_numparam -numparam -it_id -allow_exits -opt_block_param -bodystmt - -

case_args

+k_do +do_body +k_end
+

Referenced by: + primary + block_call +

+
+
+

brace_body

+
+ + + + + +max_numparam +numparam +it_id +allow_exits +opt_block_param +compstmt_stmts
+

Referenced by: + cmd_brace_block + command + brace_block +

+
+
+

do_body

+
+ + + + + +max_numparam +numparam +it_id +allow_exits +opt_block_param +bodystmt
+

Referenced by: + do_block + brace_block +

+
+
+

case_args

+
-arg_value +arg_value tSTAR -arg_value +arg_value -case_args +case_args ',' -arg_value +arg_value -case_args +case_args ',' tSTAR -arg_value - -

case_body

+arg_value
+

Referenced by: + case_args + case_body +

+
+
+

case_body

+
-k_when -case_args -then -compstmt_stmts -cases - -

cases

+k_when +case_args +then +compstmt_stmts +cases
+

Referenced by: + primary + cases +

+
+
+

cases

+
-opt_else +opt_else -case_body - -

p_pvtbl

- - - - - - -

p_pktbl

+case_body
+

Referenced by: + case_body +

+
+
+

p_pvtbl

+
- - -

p_in_kwarg

+
+

Referenced by: + expr + p_case_body +

+
+
+

p_pktbl

+
- - -

$@31

+
+

Referenced by: + expr + p_case_body + p_lparen + p_lbracket + p_expr_basic +

+
+
+

p_in_kwarg

+
- - -

p_case_body

+
+

Referenced by: + expr + p_case_body +

+
+
+

p_case_body

+
- - + + keyword_in -p_in_kwarg -p_pvtbl -p_pktbl -p_top_expr -then -$@31 -compstmt_stmts -p_cases - -

p_cases

+p_in_kwarg +p_pvtbl +p_pktbl +p_top_expr +then +compstmt_stmts +p_cases
+

Referenced by: + primary + p_cases +

+
+
+

p_cases

+
-opt_else +opt_else -p_case_body - -

p_top_expr

+p_case_body
+

Referenced by: + p_case_body +

+
+
+

p_top_expr

+
-p_top_expr_body +p_top_expr_body -p_top_expr_body +p_top_expr_body modifier_if -expr_value +expr_value -p_top_expr_body +p_top_expr_body modifier_unless -expr_value - -

p_top_expr_body

+expr_value
+

Referenced by: + p_case_body +

+
+
+

p_top_expr_body

+
-p_expr +p_expr -p_expr +p_expr ',' -p_expr +p_expr ',' -p_args +p_args -p_find +p_find -p_args_tail +p_args_tail -p_kwargs - -

p_expr

+p_kwargs
+

Referenced by: + expr + p_top_expr +

+
+
+

p_expr

+
-p_as - -

p_as

+p_as
+

Referenced by: + p_top_expr_body + p_as + p_expr_basic + p_args + p_arg + p_kw +

+
+
+

p_as

+
-p_expr +p_expr tASSOC -p_variable +p_variable -p_alt - -

p_alt

+p_alt
+

Referenced by: + p_expr +

+
+
+

p_alt

+
-p_alt +p_alt '|' -p_expr_basic +p_expr_basic -p_expr_basic - -

p_lparen

+p_expr_basic
+

Referenced by: + p_as + p_alt +

+
+
+

p_lparen

+
'(' -p_pktbl - -

p_lbracket

+p_pktbl
+

Referenced by: + p_expr_basic +

+
+
+

p_lbracket

+
'[' -p_pktbl - -

p_expr_basic

- - - - - -p_value - -p_variable - -p_const -p_lparen -p_args -rparen - -p_const -p_lparen -p_find -rparen - -p_const -p_lparen -p_kwargs -rparen - -p_const -'(' -rparen - -p_const -p_lbracket -p_args -rbracket - -p_const -p_lbracket -p_find -rbracket - -p_const -p_lbracket -p_kwargs -rbracket - -p_const -'[' -rbracket - -tLBRACK -p_args -rbracket - -tLBRACK -p_find -rbracket - -tLBRACK -rbracket - +p_pktbl
+

Referenced by: + p_expr_basic +

+
+
+

p_expr_basic

+
+ + + + + +p_value + +p_variable + +p_const +p_lparen +p_args +rparen + +p_const +p_lparen +p_find +rparen + +p_const +p_lparen +p_kwargs +rparen + +p_const +'(' +rparen + +p_const +p_lbracket +p_args +rbracket + +p_const +p_lbracket +p_find +rbracket + +p_const +p_lbracket +p_kwargs +rbracket + +p_const +'[' +rbracket + +tLBRACK +p_args +rbracket + +tLBRACK +p_find +rbracket + +tLBRACK +rbracket + tLBRACE -p_pktbl -lex_ctxt -$@32 -p_kwargs -rbrace - -tLBRACE -rbrace - -tLPAREN -p_pktbl -p_expr -rparen - -

$@32

- - - - - - -

p_args

+p_pktbl +lex_ctxt +p_kwargs +rbrace + +tLBRACE +rbrace + +tLPAREN +p_pktbl +p_expr +rparen
+

Referenced by: + p_alt +

+
+
+

p_args

+
-p_expr +p_expr -p_args_head +p_args_head -p_args_head -p_arg +p_args_head +p_arg -p_args_head -p_rest +p_args_head +p_rest -p_args_head -p_rest +p_args_head +p_rest ',' -p_args_post +p_args_post -p_args_tail - -

p_args_head

+p_args_tail
+

Referenced by: + p_top_expr_body + p_expr_basic +

+
+
+

p_args_head

+
-p_arg +p_arg ',' -p_args_head -p_arg -',' - -

p_args_tail

+p_args_head +p_arg +','
+

Referenced by: + p_args + p_args_head +

+
+
+

p_args_tail

+
-p_rest +p_rest -p_rest +p_rest ',' -p_args_post - -

p_find

+p_args_post
+

Referenced by: + p_top_expr_body + p_args +

+
+
+

p_find

+
-p_rest +p_rest ',' -p_args_post +p_args_post ',' -p_rest - -

p_rest

+p_rest
+

Referenced by: + p_top_expr_body + p_expr_basic +

+
+
+

p_rest

+
@@ -3028,69 +3756,108 @@

p_rest

tSTAR tIDENTIFIER -tSTAR - -

p_args_post

+tSTAR
+

Referenced by: + p_args + p_args_tail + p_find +

+
+
+

p_args_post

+
-p_arg +p_arg -p_args_post +p_args_post ',' -p_arg - -

p_arg

+p_arg
+

Referenced by: + p_args + p_args_tail + p_find + p_args_post +

+
+
+

p_arg

+
-p_expr - -

p_kwargs

+p_expr
+

Referenced by: + p_args + p_args_head + p_args_post +

+
+
+

p_kwargs

+
-p_kwarg +p_kwarg ',' -p_any_kwrest +p_any_kwrest -p_kwarg +p_kwarg -p_kwarg +p_kwarg ',' -p_any_kwrest - -

p_kwarg

+p_any_kwrest
+

Referenced by: + p_top_expr_body + p_expr_basic +

+
+
+

p_kwarg

+
-p_kw +p_kw -p_kwarg +p_kwarg ',' -p_kw - -

p_kw

+p_kw
+

Referenced by: + p_kwargs + p_kwarg +

+
+
+

p_kw

+
-p_kw_label -p_expr +p_kw_label +p_expr -p_kw_label - -

p_kw_label

+p_kw_label
+

Referenced by: + p_kwarg +

+
+
+

p_kw_label

+
@@ -3099,124 +3866,172 @@

p_kw_label

tLABEL tSTRING_BEG -string_contents -tLABEL_END - -

p_kwrest

+string_contents +tLABEL_END
+

Referenced by: + p_kw +

+
+
+

p_kwrest

+
-kwrest_mark +kwrest_mark tIDENTIFIER -kwrest_mark - -

p_kwnorest

+kwrest_mark
+

Referenced by: + p_any_kwrest +

+
+
+

p_kwnorest

+
-kwrest_mark -keyword_nil - -

p_any_kwrest

+kwrest_mark +keyword_nil
+

Referenced by: + p_any_kwrest + f_no_kwarg +

+
+
+

p_any_kwrest

+
-p_kwrest +p_kwrest -p_kwnorest - -

p_value

+p_kwnorest
+

Referenced by: + p_kwargs +

+
+
+

p_value

+
-p_primitive +p_primitive -p_primitive_value +p_primitive_value tDOT2 -p_primitive_value +p_primitive_value -p_primitive_value +p_primitive_value tDOT3 -p_primitive_value +p_primitive_value -p_primitive_value +p_primitive_value tDOT2 -p_primitive_value +p_primitive_value tDOT3 -p_var_ref +p_var_ref -p_expr_ref +p_expr_ref -p_const +p_const tBDOT2 -p_primitive_value +p_primitive_value tBDOT3 -p_primitive_value - -

p_primitive

+p_primitive_value
+

Referenced by: + p_expr_basic +

+
+
+

p_primitive

+
-literal +literal -strings +strings -xstring +xstring -regexp +regexp -words +words -qwords +qwords -symbols +symbols -qsymbols +qsymbols -keyword_variable +keyword_variable -lambda - -

value_expr_p_primitive

+lambda
+

Referenced by: + p_value + value_expr_p_primitive +

+
+
+

value_expr_p_primitive

+
-p_primitive - -

p_primitive_value

+p_primitive
+

Referenced by: + p_primitive_value +

+
+
+

p_primitive_value

+
-value_expr_p_primitive - -

p_variable

+value_expr_p_primitive
+

Referenced by: + p_value +

+
+
+

p_variable

+
-tIDENTIFIER - -

p_var_ref

+tIDENTIFIER
+

Referenced by: + p_as + p_expr_basic +

+
+
+

p_var_ref

+
@@ -3226,9 +4041,14 @@

p_var_ref

tIDENTIFIER '^' -nonlocal_var - -

p_expr_ref

+nonlocal_var
+

Referenced by: + p_value +

+
+
+

p_expr_ref

+
@@ -3236,93 +4056,138 @@

p_expr_ref

'^' tLPAREN -expr_value -rparen - -

p_const

+expr_value +rparen
+

Referenced by: + p_value +

+
+
+

p_const

+
tCOLON3 -cname +cname -p_const +p_const tCOLON2 -cname +cname -tCONSTANT - -

opt_rescue

+tCONSTANT
+

Referenced by: + p_expr_basic + p_value + p_const +

+
+
+

opt_rescue

+
-k_rescue -exc_list -exc_var -then -compstmt_stmts -opt_rescue +k_rescue +exc_list +exc_var +then +compstmt_stmts +opt_rescue -none - -

exc_list

+none
+

Referenced by: + bodystmt + opt_rescue +

+
+
+

exc_list

+
-arg_value +arg_value -mrhs +mrhs -none - -

exc_var

+none
+

Referenced by: + opt_rescue +

+
+
+

exc_var

+
tASSOC -lhs +lhs -none - -

opt_ensure

+none
+

Referenced by: + opt_rescue +

+
+
+

opt_ensure

+
-k_ensure -stmts -option_terms +k_ensure +stmts +option_terms -none - -

literal

+none
+

Referenced by: + bodystmt +

+
+
+

literal

+
-numeric +numeric -symbol - -

strings

+symbol
+

Referenced by: + primary + p_primitive +

+
+
+

strings

+
-string - -

string

+string
+

Referenced by: + primary + p_primitive +

+
+
+

string

+
@@ -3330,42 +4195,65 @@

string

tCHAR -string1 +string1 -string -string1 - -

string1

+string +string1
+

Referenced by: + strings + string +

+
+
+

string1

+
tSTRING_BEG -string_contents -tSTRING_END - -

xstring

+string_contents +tSTRING_END
+

Referenced by: + string +

+
+
+

xstring

+
tXSTRING_BEG -xstring_contents -tSTRING_END - -

regexp

+xstring_contents +tSTRING_END
+

Referenced by: + primary + p_primitive +

+
+
+

regexp

+
tREGEXP_BEG -regexp_contents -tREGEXP_END - -

nonempty_list_' '

+regexp_contents +tREGEXP_END
+

Referenced by: + primary + p_primitive +

+
+
+

nonempty_list_' '

+
@@ -3373,218 +4261,303 @@

nonempty_list_' '

' ' -nonempty_list_' ' -' ' - -

words_tWORDS_BEG_word_list

+nonempty_list_' ' +' '
+

Referenced by: + nonempty_list_' ' + words_tWORDS_BEG_word_list + word_list + words_tSYMBOLS_BEG_symbol_list + symbol_list + words_tQWORDS_BEG_qword_list + words_tQSYMBOLS_BEG_qsym_list + qword_list + qsym_list +

+
+
+

words_tWORDS_BEG_word_list

+
tWORDS_BEG -nonempty_list_' ' -word_list -tSTRING_END - -

words

+nonempty_list_' ' +word_list +tSTRING_END
+

Referenced by: + words +

+
+
+

words

+
-words_tWORDS_BEG_word_list - -

word_list

+words_tWORDS_BEG_word_list
+

Referenced by: + primary + p_primitive +

+
+
+

word_list

+
-word_list -word -nonempty_list_' ' - -

word

+word_list +word +nonempty_list_' '
+

Referenced by: + words_tWORDS_BEG_word_list + word_list +

+
+
+

word

+
-string_content +string_content -word -string_content - -

words_tSYMBOLS_BEG_symbol_list

+word +string_content
+

Referenced by: + word_list + word + symbol_list +

+
+
+

words_tSYMBOLS_BEG_symbol_list

+
tSYMBOLS_BEG -nonempty_list_' ' -symbol_list -tSTRING_END - -

symbols

+nonempty_list_' ' +symbol_list +tSTRING_END
+

Referenced by: + symbols +

+
+
+

symbols

+
-words_tSYMBOLS_BEG_symbol_list - -

symbol_list

+words_tSYMBOLS_BEG_symbol_list
+

Referenced by: + primary + p_primitive +

+
+
+

symbol_list

+
-symbol_list -word -nonempty_list_' ' - -

words_tQWORDS_BEG_qword_list

+symbol_list +word +nonempty_list_' '
+

Referenced by: + words_tSYMBOLS_BEG_symbol_list + symbol_list +

+
+
+

words_tQWORDS_BEG_qword_list

+
tQWORDS_BEG -nonempty_list_' ' -qword_list -tSTRING_END - -

qwords

+nonempty_list_' ' +qword_list +tSTRING_END
+

Referenced by: + qwords +

+
+
+

qwords

+
-words_tQWORDS_BEG_qword_list - -

words_tQSYMBOLS_BEG_qsym_list

+words_tQWORDS_BEG_qword_list
+

Referenced by: + primary + p_primitive +

+
+
+

words_tQSYMBOLS_BEG_qsym_list

+
tQSYMBOLS_BEG -nonempty_list_' ' -qsym_list -tSTRING_END - -

qsymbols

+nonempty_list_' ' +qsym_list +tSTRING_END
+

Referenced by: + qsymbols +

+
+
+

qsymbols

+
-words_tQSYMBOLS_BEG_qsym_list - -

qword_list

+words_tQSYMBOLS_BEG_qsym_list
+

Referenced by: + primary + p_primitive +

+
+
+

qword_list

+
-qword_list +qword_list tSTRING_CONTENT -nonempty_list_' ' - -

qsym_list

+nonempty_list_' '
+

Referenced by: + words_tQWORDS_BEG_qword_list + qword_list +

+
+
+

qsym_list

+
-qsym_list +qsym_list tSTRING_CONTENT -nonempty_list_' ' - -

string_contents

+nonempty_list_' '
+

Referenced by: + words_tQSYMBOLS_BEG_qsym_list + qsym_list +

+
+
+

string_contents

+
-string_contents -string_content - -

xstring_contents

+string_contents +string_content
+

Referenced by: + p_kw_label + string1 + string_contents + dsym + assoc +

+
+
+

xstring_contents

+
-xstring_contents -string_content - -

regexp_contents

+xstring_contents +string_content
+

Referenced by: + xstring + xstring_contents +

+
+
+

regexp_contents

+
-regexp_contents -string_content - -

string_content

+regexp_contents +string_content
+

Referenced by: + regexp + regexp_contents +

+
+
+

string_content

+
- - -tSTRING_CONTENT - -tSTRING_DVAR -@33 -string_dvar - + + +tSTRING_CONTENT + +tSTRING_DVAR +string_dvar + tSTRING_DBEG -@34 -@35 -@36 -compstmt_stmts -string_dend - -

@33

- - - - - - -

@34

- - - - - - -

@35

- - - - - - -

@36

- - - - - - -

string_dend

+compstmt_stmts +string_dend
+

Referenced by: + word + string_contents + xstring_contents + regexp_contents +

+
+
+

string_dend

+
@@ -3592,69 +4565,105 @@

string_dend

tSTRING_DEND -END_OF_INPUT - -

string_dvar

+END_OF_INPUT
+

Referenced by: + string_content +

+
+
+

string_dvar

+
-nonlocal_var +nonlocal_var -backref - -

symbol

+backref
+

Referenced by: + string_content +

+
+
+

symbol

+
-ssym +ssym -dsym - -

ssym

+dsym
+

Referenced by: + fitem + literal +

+
+
+

ssym

+
tSYMBEG -sym - -

sym

+sym
+

Referenced by: + symbol +

+
+
+

sym

+
-fname +fname -nonlocal_var - -

dsym

+nonlocal_var
+

Referenced by: + ssym +

+
+
+

dsym

+
tSYMBEG -string_contents -tSTRING_END - -

numeric

+string_contents +tSTRING_END
+

Referenced by: + symbol +

+
+
+

numeric

+
-simple_numeric +simple_numeric tUMINUS_NUM -simple_numeric - -

simple_numeric

+simple_numeric
+

Referenced by: + literal +

+
+
+

simple_numeric

+
@@ -3666,9 +4675,15 @@

simple_numeric

tRATIONAL -tIMAGINARY - -

nonlocal_var

+tIMAGINARY
+

Referenced by: + arg + numeric +

+
+
+

nonlocal_var

+
@@ -3678,9 +4693,17 @@

nonlocal_var

tGVAR -tCVAR - -

user_variable

+tCVAR
+

Referenced by: + p_var_ref + string_dvar + sym + user_variable +

+
+
+

user_variable

+
@@ -3690,9 +4713,17 @@

user_variable

tCONSTANT -nonlocal_var - -

keyword_variable

+nonlocal_var
+

Referenced by: + mlhs_node + lhs + var_ref + var_lhs +

+
+
+

keyword_variable

+
@@ -3710,29 +4741,50 @@

keyword_variable

keyword__LINE__ -keyword__ENCODING__ - -

var_ref

+keyword__ENCODING__
+

Referenced by: + mlhs_node + lhs + p_primitive + var_ref + var_lhs +

+
+
+

var_ref

+
-user_variable +user_variable -keyword_variable - -

var_lhs

+keyword_variable
+

Referenced by: + primary + value_expr_var_ref +

+
+
+

var_lhs

+
-user_variable +user_variable -keyword_variable - -

backref

+keyword_variable
+

Referenced by: + op_asgn_command_rhs + op_asgn_arg_rhs +

+
+
+

backref

+
@@ -3740,231 +4792,293 @@

backref

tNTH_REF -tBACK_REF - -

$@37

- - - - - - -

superclass

- - - - - +tBACK_REF
+

Referenced by: + op_asgn_command_rhs + mlhs_node + lhs + op_asgn_arg_rhs + primary + string_dvar +

+
+
+

superclass

+
+ + + + + '<' -$@37 -expr_value -term - - -

f_opt_paren_args

+expr_value +term +
+

Referenced by: + primary +

+
+
+

f_opt_paren_args

+
-f_paren_args +f_paren_args -none - -

f_paren_args

+none
+

Referenced by: + def_endless_method_endless_command + def_endless_method_endless_arg +

+
+
+

f_paren_args

+
'(' -f_args -rparen - -

f_arglist

+f_args +rparen
+

Referenced by: + f_opt_paren_args + f_arglist +

+
+
+

f_arglist

+
- - -f_paren_args - -@38 -f_args -term - -

@38

- - - - - - -

f_kw_arg_value

+ + +f_paren_args + +f_args +term
+

Referenced by: + primary +

+
+
+

f_kw_arg_value

+
-f_label -arg_value +f_label +arg_value -f_label - -

f_kwarg_arg_value

+f_label
+

Referenced by: + f_kwarg_arg_value +

+
+
+

f_kwarg_arg_value

+
-f_kw_arg_value +f_kw_arg_value -f_kwarg_arg_value +f_kwarg_arg_value ',' -f_kw_arg_value - -

args_tail

+f_kw_arg_value
+

Referenced by: + f_kwarg_arg_value + args_tail +

+
+
+

args_tail

+
-f_kwarg_arg_value +f_kwarg_arg_value ',' -f_kwrest -opt_f_block_arg +f_kwrest +opt_f_block_arg -f_kwarg_arg_value -opt_f_block_arg +f_kwarg_arg_value +opt_f_block_arg -f_any_kwrest -opt_f_block_arg +f_any_kwrest +opt_f_block_arg -f_block_arg +f_block_arg -args_forward - -

f_opt_arg_value

+args_forward
+

Referenced by: + opt_args_tail_args_tail + f_args +

+
+
+

f_opt_arg_value

+
-f_arg_asgn -f_eq -arg_value - -

f_optarg_arg_value

+f_arg_asgn +f_eq +arg_value
+

Referenced by: + f_optarg_arg_value +

+
+
+

f_optarg_arg_value

+
-f_opt_arg_value +f_opt_arg_value -f_optarg_arg_value +f_optarg_arg_value ',' -f_opt_arg_value - -

opt_args_tail_args_tail

+f_opt_arg_value
+

Referenced by: + f_optarg_arg_value + f_args +

+
+
+

opt_args_tail_args_tail

+
',' -args_tail - - -

f_args

+args_tail +
+

Referenced by: + f_args +

+
+
+

f_args

+
-f_arg +f_arg ',' -f_optarg_arg_value +f_optarg_arg_value ',' -f_rest_arg -opt_args_tail_args_tail +f_rest_arg +opt_args_tail_args_tail -f_arg +f_arg ',' -f_optarg_arg_value +f_optarg_arg_value ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_arg +f_arg ',' -f_optarg_arg_value -opt_args_tail_args_tail +f_optarg_arg_value +opt_args_tail_args_tail -f_arg +f_arg ',' -f_optarg_arg_value +f_optarg_arg_value ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_arg +f_arg ',' -f_rest_arg -opt_args_tail_args_tail +f_rest_arg +opt_args_tail_args_tail -f_arg +f_arg ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_optarg_arg_value +f_optarg_arg_value ',' -f_rest_arg -opt_args_tail_args_tail +f_rest_arg +opt_args_tail_args_tail -f_optarg_arg_value +f_optarg_arg_value ',' -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_optarg_arg_value -opt_args_tail_args_tail +f_optarg_arg_value +opt_args_tail_args_tail -f_optarg_arg_value +f_optarg_arg_value ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -f_rest_arg -opt_args_tail_args_tail +f_rest_arg +opt_args_tail_args_tail -f_rest_arg +f_rest_arg ',' -f_arg -opt_args_tail_args_tail +f_arg +opt_args_tail_args_tail -args_tail - - -

args_forward

+args_tail +
+

Referenced by: + f_larglist + f_paren_args + f_arglist +

+
+
+

args_forward

+
-tBDOT3 - -

f_bad_arg

+tBDOT3
+

Referenced by: + paren_args + args_tail +

+
+
+

f_bad_arg

+
@@ -3976,59 +5090,97 @@

f_bad_arg

tGVAR -tCVAR - -

f_norm_arg

+tCVAR
+

Referenced by: + bvar + f_norm_arg +

+
+
+

f_norm_arg

+
-f_bad_arg +f_bad_arg -tIDENTIFIER - -

f_arg_asgn

+tIDENTIFIER
+

Referenced by: + f_marg + f_rest_marg + f_arg_asgn +

+
+
+

f_arg_asgn

+
-f_norm_arg - -

f_arg_item

+f_norm_arg
+

Referenced by: + f_opt_primary_value + f_opt_arg_value + f_arg_item +

+
+
+

f_arg_item

+
-f_arg_asgn +f_arg_asgn tLPAREN -f_margs -rparen - -

f_arg

+f_margs +rparen
+

Referenced by: + f_arg +

+
+
+

f_arg

+
-f_arg_item +f_arg_item -f_arg +f_arg ',' -f_arg_item - -

f_label

+f_arg_item
+

Referenced by: + block_param + f_args + f_arg +

+
+
+

f_label

+
-tLABEL - -

kwrest_mark

+tLABEL
+

Referenced by: + f_kw_primary_value + f_kw_arg_value +

+
+
+

kwrest_mark

+
@@ -4036,28 +5188,47 @@

kwrest_mark

tPOW -tDSTAR - -

f_no_kwarg

+tDSTAR
+

Referenced by: + p_kwrest + p_kwnorest + f_kwrest +

+
+
+

f_no_kwarg

+
-p_kwnorest - -

f_kwrest

+p_kwnorest
+

Referenced by: + f_any_kwrest +

+
+
+

f_kwrest

+
-kwrest_mark +kwrest_mark tIDENTIFIER -kwrest_mark - -

restarg_mark

+kwrest_mark
+

Referenced by: + f_any_kwrest + block_args_tail + args_tail +

+
+
+

restarg_mark

+
@@ -4065,20 +5236,31 @@

restarg_mark

'*' -tSTAR - -

f_rest_arg

+tSTAR
+

Referenced by: + f_rest_arg +

+
+
+

f_rest_arg

+
-restarg_mark +restarg_mark tIDENTIFIER -restarg_mark - -

blkarg_mark

+restarg_mark
+

Referenced by: + block_param + f_args +

+
+
+

blkarg_mark

+
@@ -4086,107 +5268,146 @@

blkarg_mark

'&' -tAMPER - -

f_block_arg

+tAMPER
+

Referenced by: + f_block_arg +

+
+
+

f_block_arg

+
-blkarg_mark +blkarg_mark tIDENTIFIER -blkarg_mark - -

opt_f_block_arg

+blkarg_mark
+

Referenced by: + block_args_tail + args_tail + opt_f_block_arg +

+
+
+

opt_f_block_arg

+
',' -f_block_arg +f_block_arg -none - -

value_expr_var_ref

+none
+

Referenced by: + block_args_tail + args_tail +

+
+
+

value_expr_var_ref

+
-var_ref - -

singleton

+var_ref
+

Referenced by: + singleton +

+
+
+

singleton

+
- - -value_expr_var_ref - + + +value_expr_var_ref + '(' -$@39 -expr -rparen - -

$@39

- - - - - - -

assoc_list

+expr +rparen
+

Referenced by: + defs_head +

+
+
+

assoc_list

+
-none +none -assocs -trailer - -

assocs

+assocs +trailer
+

Referenced by: + primary +

+
+
+

assocs

+
-assoc +assoc -assocs +assocs ',' -assoc - -

assoc

+assoc
+

Referenced by: + aref_args + opt_call_args + call_args + assoc_list + assocs +

+
+
+

assoc

+
-arg_value +arg_value tASSOC -arg_value +arg_value tLABEL -arg_value +arg_value tLABEL tSTRING_BEG -string_contents +string_contents tLABEL_END -arg_value +arg_value tDSTAR -arg_value +arg_value -tDSTAR - -

operation

+tDSTAR
+

Referenced by: + assocs +

+
+
+

operation

+
@@ -4196,19 +5417,33 @@

operation

tCONSTANT -tFID - -

operation2

+tFID
+

Referenced by: + fcall + operation2 +

+
+
+

operation2

+
-operation +operation -op - -

operation3

+op
+

Referenced by: + block_command + command + block_call + method_call +

+
+
+

operation3

+
@@ -4218,9 +5453,14 @@

operation3

tFID -op - -

dot_or_colon

+op
+

Referenced by: + method_call +

+
+
+

dot_or_colon

+
@@ -4228,9 +5468,14 @@

dot_or_colon

'.' -tCOLON2 - -

call_op

+tCOLON2
+

Referenced by: + defs_head +

+
+
+

call_op

+
@@ -4238,56 +5483,109 @@

call_op

'.' -tANDDOT - -

call_op2

+tANDDOT
+

Referenced by: + op_asgn_command_rhs + command + mlhs_node + lhs + op_asgn_arg_rhs + method_call + call_op2 +

+
+
+

call_op2

+
-call_op +call_op -tCOLON2 - -

rparen

+tCOLON2
+

Referenced by: + block_command + block_call +

+
+
+

rparen

+
-option_'\n' -')' - -

rbracket

+option_'\n' +')'
+

Referenced by: + mlhs + mlhs_inner + mlhs_item + paren_args + primary + f_marg + p_expr_basic + p_expr_ref + f_paren_args + f_arg_item + singleton +

+
+
+

rbracket

+
-option_'\n' -']' - -

rbrace

+option_'\n' +']'
+

Referenced by: + op_asgn_command_rhs + mlhs_node + lhs + op_asgn_arg_rhs + method_call + p_expr_basic +

+
+
+

rbrace

+
-option_'\n' -'}' - -

trailer

+option_'\n' +'}'
+

Referenced by: + p_expr_basic +

+
+
+

trailer

+
-option_'\n' +option_'\n' -',' - -

term

+','
+

Referenced by: + aref_args + assoc_list +

+
+
+

term

+
@@ -4295,84 +5593,61 @@

term

';' -'\n' - -

terms

+'\n'
+

Referenced by: + primary + then + do + superclass + f_arglist + terms +

+
+
+

terms

+
-term +term -terms -';' - -

none

+terms +';'
+

Referenced by: + option_terms + top_stmts + stmts + terms +

+
+
+

none

+
- - - - +
+

Referenced by: + top_stmts + stmts + lex_ctxt + aref_args + opt_paren_args + opt_call_args + opt_block_arg + opt_else + opt_block_param + opt_rescue + exc_list + exc_var + opt_ensure + f_opt_paren_args + opt_f_block_arg + assoc_list +

+
+ diff --git a/sig/generated/lrama/diagram.rbs b/sig/generated/lrama/diagram.rbs index 030632276..89014fdfe 100644 --- a/sig/generated/lrama/diagram.rbs +++ b/sig/generated/lrama/diagram.rbs @@ -17,8 +17,8 @@ module Lrama # @rbs () -> string def default_style: () -> string - # @rbs () -> string - def diagrams: () -> string + # @rbs () -> Array[Hash[Symbol, (String | Array[String])]] + def linked_sections: () -> Array[Hash[Symbol, String | Array[String]]] private @@ -27,8 +27,5 @@ module Lrama # @rbs () -> string def template_file: () -> string - - # @rbs (String name, RailroadDiagrams::Diagram diagram, String result) -> void - def add_diagram: (String name, RailroadDiagrams::Diagram diagram, String result) -> void end end diff --git a/spec/lrama/command_spec.rb b/spec/lrama/command_spec.rb index 58069e4a7..a2d0f1ff3 100644 --- a/spec/lrama/command_spec.rb +++ b/spec/lrama/command_spec.rb @@ -14,6 +14,21 @@ end end + context "when `--diagram` is specified" do + it "generates links and reverse references without text diagrams" do + diagram_file = File.join(Dir.tmpdir, "diagram.html") + command = Lrama::Command.new(o_option + ["--diagram=#{diagram_file}", fixture_path("command/basic.y")]) + command.run + + html = File.read(diagram_file) + expect(html).to include('
') + expect(html).to include('href="#rule-expr"') + expect(html).to include("Referenced by:") + expect(html).not_to include("$accept') expect(out.string).to include('

unused

') expect(out.string).to include("') + expect(out.string).to include('href="#rule-program"') + expect(out.string).to include("Referenced by:") end end @@ -68,15 +73,96 @@ end end - describe "#diagrams" do - before do - Lrama::Diagram.require_railroad_diagrams + describe "linked diagrams" do + it "preserves rule order and includes references" do + sections = diagram.linked_sections + + expect(sections.map { |section| section[:name] }).to eq(%w[$accept program class strings_1 strings_2 string_1 string_2 string unused]) + expect(sections.map { |section| section[:id] }.uniq.size).to eq(sections.size) + expect(sections.find { |section| section[:name] == "program" }[:referenced_by]).to eq(["$accept"]) + expect(sections.find { |section| section[:name] == "string_1" }[:referenced_by]).to eq(["strings_1", "strings_2"]) + expect(sections.find { |section| section[:name] == "unused" }[:referenced_by]).to eq([]) + sections.each do |section| + expect(REXML::Document.new(section[:svg]).root.name).to eq("svg") + end + end + + context "with midrule actions" do + let(:grammar_file_path) { "midrule-actions.y" } + let(:text) do + <<~GRAMMAR + %union { int i; } + %token NUMBER + %type start value + %% + start: { setup(); } value { checkpoint(); } empty + | value { $$ = $1; } empty { $$ = $2; } + | actions; + value: NUMBER; + empty: %empty; + actions: { setup(); } { finish(); }; + GRAMMAR + end + + it "omits action rules and references while preserving empty grammar rules" do + original_rules = grammar.rules.map(&:display_name) + action_names = grammar.rules.select(&:original_rule).map { |rule| rule.lhs.id.s_value } + expect(action_names).to include("$@1", "@3") + + sections = diagram.linked_sections + expect(sections.map { |section| section[:name] }).to eq(%w[$accept start value empty actions]) + start = sections.find { |section| section[:name] == "start" } + svg = REXML::Document.new(start[:svg]) + expect(REXML::XPath.match(svg, "//text").map(&:text)).to eq(%w[value empty value empty actions]) + expect(sections.find { |section| section[:name] == "empty" }[:referenced_by]).to eq(["start"]) + actions = sections.find { |section| section[:name] == "actions" } + expect(REXML::XPath.match(REXML::Document.new(actions[:svg]), "//text")).to eq([]) + + diagram.render + action_names.each { |name| expect(out.string).not_to include(name) } + ids = out.string.scan(/\bid="([^"]+)"/).flatten + targets = out.string.scan(/\bhref="#([^"]+)"/).flatten + expect(targets - ids).to eq([]) + expect(out.string).to include('href="#rule-empty"') + expect(grammar.rules.map(&:display_name)).to eq(original_rules) + end end - it "returns diagrams" do - expect(diagram.diagrams).to include('

$accept

') - expect(diagram.diagrams).to include('

unused

') - expect(diagram.diagrams).to include("') + expect(out.string).to include("Referenced by:") + expect(out.string).not_to include("#{RailroadDiagrams.escape_html(name)}") + expect(out.string).not_to include(name) end end end diff --git a/template/diagram/diagram.html b/template/diagram/diagram.html index 3e87e6e51..8f50f8aae 100644 --- a/template/diagram/diagram.html +++ b/template/diagram/diagram.html @@ -1,102 +1,36 @@ +<% sections = output.linked_sections -%> +<% rule_ids = sections.each_with_object({}) { |section, ids| ids[section[:name]] = section[:id] } -%> - + + + Lrama syntax diagrams - - - - <%= output.diagrams %> - + +

Lrama syntax diagrams

+ <% sections.each do |section| -%> +
+

<%= RailroadDiagrams.escape_html(section[:name]) %>

+
<%= section[:svg] %>
+ <% unless section[:referenced_by].empty? -%> +

Referenced by: + <% section[:referenced_by].each do |name| -%> + <%= RailroadDiagrams.escape_html(name) %> + <% end -%> +

+ <% end -%> +
+ <% end -%>