-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathruby.bnf
1210 lines (989 loc) · 19.4 KB
/
ruby.bnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
program : top_compstmt
;
top_compstmt : top_stmts opt_terms
;
top_stmts : none
| top_stmt
| top_stmts terms top_stmt
| error top_stmt
;
top_stmt : stmt
| keyword_BEGIN begin_block
;
begin_block : '{' top_compstmt '}'
;
bodystmt : compstmt
opt_rescue
k_else
compstmt
opt_ensure
| compstmt
opt_rescue
opt_ensure
;
compstmt : stmts opt_terms
;
stmts : none
| stmt_or_begin
| stmts terms stmt_or_begin
| error stmt
;
stmt_or_begin : stmt
| keyword_BEGIN
begin_block
;
stmt : keyword_alias fitem fitem
| keyword_alias tGVAR tGVAR
| keyword_alias tGVAR tBACK_REF
| keyword_alias tGVAR tNTH_REF
| keyword_undef undef_list
| stmt modifier_if expr_value
| stmt modifier_unless expr_value
| stmt modifier_while expr_value
| stmt modifier_until expr_value
| stmt modifier_rescue stmt
| keyword_END '{' compstmt '}'
| command_asgn
| mlhs '=' lex_ctxt command_call
| lhs '=' lex_ctxt mrhs
| mlhs '=' lex_ctxt mrhs_arg modifier_rescue stmt
| mlhs '=' lex_ctxt mrhs_arg
| expr
;
command_asgn : lhs '=' lex_ctxt command_rhs
| var_lhs tOP_ASGN lex_ctxt command_rhs
| primary_value '[' opt_call_args rbracket tOP_ASGN lex_ctxt command_rhs
| primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt command_rhs
| primary_value call_op tCONSTANT tOP_ASGN lex_ctxt command_rhs
| primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt command_rhs
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs
| defn_head f_opt_paren_args '=' command
| defn_head f_opt_paren_args '=' command modifier_rescue arg
| defs_head f_opt_paren_args '=' command
| defs_head f_opt_paren_args '=' command modifier_rescue arg
| backref tOP_ASGN lex_ctxt command_rhs
;
command_rhs : command_call %prec tOP_ASGN
| command_call modifier_rescue stmt
| command_asgn
;
expr : command_call
| expr keyword_and expr
| expr keyword_or expr
| keyword_not opt_nl expr
| '!' command_call
| arg tASSOC
p_top_expr_body
| arg keyword_in
p_top_expr_body
| arg %prec tLBRACE_ARG
;
def_name : fname
;
defn_head : k_def def_name
;
defs_head : k_def singleton dot_or_colon
def_name
;
expr_value : expr
;
expr_value_do : expr_value do
;
command_call : command
| block_command
;
block_command : block_call
| block_call call_op2 operation2 command_args
;
cmd_brace_block : tLBRACE_ARG brace_body '}'
;
fcall : operation
;
command : fcall command_args %prec tLOWEST
| fcall command_args cmd_brace_block
| primary_value call_op operation2 command_args %prec tLOWEST
| primary_value call_op operation2 command_args cmd_brace_block
| primary_value tCOLON2 operation2 command_args %prec tLOWEST
| primary_value tCOLON2 operation2 command_args cmd_brace_block
| keyword_super command_args
| keyword_yield command_args
| k_return call_args
| keyword_break call_args
| keyword_next call_args
;
mlhs : mlhs_basic
| tLPAREN mlhs_inner rparen
;
mlhs_inner : mlhs_basic
| tLPAREN mlhs_inner rparen
;
mlhs_basic : mlhs_head
| mlhs_head mlhs_item
| mlhs_head tSTAR mlhs_node
| mlhs_head tSTAR mlhs_node ',' mlhs_post
| mlhs_head tSTAR
| mlhs_head tSTAR ',' mlhs_post
| tSTAR mlhs_node
| tSTAR mlhs_node ',' mlhs_post
| tSTAR
| tSTAR ',' mlhs_post
;
mlhs_item : mlhs_node
| tLPAREN mlhs_inner rparen
;
mlhs_head : mlhs_item ','
| mlhs_head mlhs_item ','
;
mlhs_post : mlhs_item
| mlhs_post ',' mlhs_item
;
mlhs_node : user_variable
| keyword_variable
| primary_value '[' opt_call_args rbracket
| primary_value call_op tIDENTIFIER
| primary_value tCOLON2 tIDENTIFIER
| primary_value call_op tCONSTANT
| primary_value tCOLON2 tCONSTANT
| tCOLON3 tCONSTANT
| backref
;
lhs : user_variable
| keyword_variable
| primary_value '[' opt_call_args rbracket
| primary_value call_op tIDENTIFIER
| primary_value tCOLON2 tIDENTIFIER
| primary_value call_op tCONSTANT
| primary_value tCOLON2 tCONSTANT
| tCOLON3 tCONSTANT
| backref
;
cname : tIDENTIFIER
| tCONSTANT
;
cpath : tCOLON3 cname
| cname
| primary_value tCOLON2 cname
;
fname : tIDENTIFIER
| tCONSTANT
| tFID
| op
| reswords
;
fitem : fname
| symbol
;
undef_list : fitem
| undef_list ',' fitem
;
op : '|'
| '^'
| '&'
| tCMP
| tEQ
| tEQQ
| tMATCH
| tNMATCH
| '>'
| tGEQ
| '<'
| tLEQ
| tNEQ
| tLSHFT
| tRSHFT
| '+'
| '-'
| '*'
| tSTAR
| '/'
| '%'
| tPOW
| tDSTAR
| '!'
| '~'
| tUPLUS
| tUMINUS
| tAREF
| tASET
| '`'
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
| keyword_BEGIN | keyword_END
| keyword_alias | keyword_and | keyword_begin
| keyword_break | keyword_case | keyword_class | keyword_def
| keyword_defined | keyword_do | keyword_else | keyword_elsif
| keyword_end | keyword_ensure | keyword_false
| keyword_for | keyword_in | keyword_module | keyword_next
| keyword_nil | keyword_not | keyword_or | keyword_redo
| keyword_rescue | keyword_retry | keyword_return | keyword_self
| keyword_super | keyword_then | keyword_true | keyword_undef
| keyword_when | keyword_yield | keyword_if | keyword_unless
| keyword_while | keyword_until
;
arg : lhs '=' lex_ctxt arg_rhs
| var_lhs tOP_ASGN lex_ctxt arg_rhs
| primary_value '[' opt_call_args rbracket tOP_ASGN lex_ctxt arg_rhs
| primary_value call_op tIDENTIFIER tOP_ASGN lex_ctxt arg_rhs
| primary_value call_op tCONSTANT tOP_ASGN lex_ctxt arg_rhs
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt arg_rhs
| primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt arg_rhs
| tCOLON3 tCONSTANT tOP_ASGN lex_ctxt arg_rhs
| backref tOP_ASGN lex_ctxt arg_rhs
| arg tDOT2 arg
| arg tDOT3 arg
| arg tDOT2
| arg tDOT3
| tBDOT2 arg
| tBDOT3 arg
| arg '+' arg
| arg '-' arg
| arg '*' arg
| arg '/' arg
| arg '%' arg
| arg tPOW arg
| tUMINUS_NUM simple_numeric tPOW arg
| tUPLUS arg
| tUMINUS arg
| arg '|' arg
| arg '^' arg
| arg '&' arg
| arg tCMP arg
| rel_expr %prec tCMP
| arg tEQ arg
| arg tEQQ arg
| arg tNEQ arg
| arg tMATCH arg
| arg tNMATCH arg
| '!' arg
| '~' arg
| arg tLSHFT arg
| arg tRSHFT arg
| arg tANDOP arg
| arg tOROP arg
| keyword_defined opt_nl arg
| arg '?' arg opt_nl ':' arg
| defn_head f_opt_paren_args '=' arg
| defn_head f_opt_paren_args '=' arg modifier_rescue arg
| defs_head f_opt_paren_args '=' arg
| defs_head f_opt_paren_args '=' arg modifier_rescue arg
| primary
;
relop : '>'
| '<'
| tGEQ
| tLEQ
;
rel_expr : arg relop arg %prec '>'
| rel_expr relop arg %prec '>'
;
lex_ctxt : tSP
| none
;
arg_value : arg
;
aref_args : none
| args trailer
| args ',' assocs trailer
| assocs trailer
;
arg_rhs : arg %prec tOP_ASGN
| arg modifier_rescue arg
;
paren_args : '(' opt_call_args rparen
| '(' args ',' args_forward rparen
| '(' args_forward rparen
;
opt_paren_args : none
| paren_args
;
opt_call_args : none
| call_args
| args ','
| args ',' assocs ','
| assocs ','
;
call_args : command
| args opt_block_arg
| assocs opt_block_arg
| args ',' assocs opt_block_arg
| block_arg
;
command_args : call_args
;
block_arg : tAMPER arg_value
| tAMPER
;
opt_block_arg : ',' block_arg
| none
;
args : arg_value
| tSTAR arg_value
| tSTAR
| args ',' arg_value
| args ',' tSTAR arg_value
| args ',' tSTAR
;
mrhs_arg : mrhs
| arg_value
;
mrhs : args ',' arg_value
| args ',' tSTAR arg_value
| tSTAR arg_value
;
primary : literal
| strings
| xstring
| regexp
| words
| qwords
| symbols
| qsymbols
| var_ref
| backref
| tFID
| k_begin
bodystmt
k_end
| tLPAREN_ARG rparen
| tLPAREN_ARG stmt rparen
| tLPAREN compstmt ')'
| primary_value tCOLON2 tCONSTANT
| tCOLON3 tCONSTANT
| tLBRACK aref_args ']'
| tLBRACE assoc_list '}'
| k_return
| keyword_yield '(' call_args rparen
| keyword_yield '(' rparen
| keyword_yield
| keyword_defined opt_nl '(' 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
if_tail
k_end
| k_unless expr_value then
compstmt
opt_else
k_end
| k_while expr_value_do
compstmt
k_end
| k_until expr_value_do
compstmt
k_end
| k_case expr_value opt_terms
case_body
k_end
| k_case opt_terms
case_body
k_end
| k_case expr_value opt_terms
p_case_body
k_end
| k_for for_var keyword_in expr_value_do
compstmt
k_end
| k_class cpath superclass
bodystmt
k_end
| k_class tLSHFT expr
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
;
primary_value : primary
;
k_begin : keyword_begin
;
k_if : keyword_if
;
k_unless : keyword_unless
;
k_while : keyword_while
;
k_until : keyword_until
;
k_case : keyword_case
;
k_for : keyword_for
;
k_class : keyword_class
;
k_module : keyword_module
;
k_def : keyword_def
;
k_do : keyword_do
;
k_do_block : keyword_do_block
;
k_rescue : keyword_rescue
;
k_ensure : keyword_ensure
;
k_when : keyword_when
;
k_else : keyword_else
;
k_elsif : keyword_elsif
;
k_end : keyword_end
;
k_return : keyword_return
;
then : term
| keyword_then
| term keyword_then
;
do : term
| keyword_do_cond
;
if_tail : opt_else
| k_elsif expr_value then
compstmt
if_tail
;
opt_else : none
| k_else compstmt
;
for_var : lhs
| mlhs
;
f_marg : f_norm_arg
| tLPAREN f_margs rparen
;
f_marg_list : f_marg
| f_marg_list ',' f_marg
;
f_margs : f_marg_list
| f_marg_list ',' f_rest_marg
| f_marg_list ',' f_rest_marg ',' f_marg_list
| f_rest_marg
| f_rest_marg ',' f_marg_list
;
f_rest_marg : tSTAR f_norm_arg
| tSTAR
;
f_any_kwrest : f_kwrest
| f_no_kwarg
;
f_eq : '=';
block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg
| f_block_kwarg opt_f_block_arg
| f_any_kwrest opt_f_block_arg
| f_block_arg
;
opt_block_args_tail : ',' block_args_tail
|
;
excessed_comma : ','
;
block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail
| f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
| f_arg ',' f_block_optarg opt_block_args_tail
| f_arg ',' f_block_optarg ',' f_arg opt_block_args_tail
| f_arg ',' f_rest_arg opt_block_args_tail
| f_arg excessed_comma
| f_arg ',' f_rest_arg ',' f_arg opt_block_args_tail
| f_arg opt_block_args_tail
| f_block_optarg ',' f_rest_arg opt_block_args_tail
| f_block_optarg ',' f_rest_arg ',' f_arg opt_block_args_tail
| f_block_optarg opt_block_args_tail
| f_block_optarg ',' f_arg opt_block_args_tail
| f_rest_arg opt_block_args_tail
| f_rest_arg ',' f_arg opt_block_args_tail
| block_args_tail
;
opt_block_param : none
| block_param_def
;
block_param_def : '|' opt_bv_decl '|'
| '|' block_param opt_bv_decl '|'
;
opt_bv_decl : opt_nl
| opt_nl ';' bv_decls opt_nl
;
bv_decls : bvar
| bv_decls ',' bvar
;
bvar : tIDENTIFIER
| f_bad_arg
;
lambda : tLAMBDA
f_larglist
lambda_body
;
f_larglist : '(' f_args opt_bv_decl ')'
| f_args
;
lambda_body : tLAMBEG compstmt '}'
", &@3);
$$ = $2;
}
| keyword_do_LAMBDA bodystmt k_end
;
do_block : k_do_block do_body k_end
;
block_call : command do_block
| block_call call_op2 operation2 opt_paren_args
| block_call call_op2 operation2 opt_paren_args brace_block
| block_call call_op2 operation2 command_args do_block
;
method_call : fcall paren_args
| primary_value call_op operation2 opt_paren_args
| primary_value tCOLON2 operation2 paren_args
| primary_value tCOLON2 operation3
| primary_value call_op paren_args
| primary_value tCOLON2 paren_args
| keyword_super paren_args
| keyword_super
| primary_value '[' opt_call_args rbracket
;
brace_block : '{' brace_body '}'
| k_do do_body k_end
;
brace_body : opt_block_param compstmt
;
do_body : opt_block_param bodystmt
;
case_args : arg_value
| tSTAR arg_value
| case_args ',' arg_value
| case_args ',' tSTAR arg_value
;
case_body : k_when case_args then
compstmt
cases
;
cases : opt_else
| case_body
;
p_case_body : keyword_in
p_top_expr then
compstmt
p_cases
;
p_cases : opt_else
| p_case_body
;
p_top_expr : p_top_expr_body
| p_top_expr_body modifier_if expr_value
| p_top_expr_body modifier_unless expr_value
;
p_top_expr_body : p_expr
| p_expr ','
| p_expr ',' p_args
| p_find
| p_args_tail
| p_kwargs
;
p_expr : p_as
;
p_as : p_expr tASSOC p_variable
| p_alt
;
p_alt : p_alt '|' p_expr_basic
| p_expr_basic
;
p_lparen : '(' ;
p_lbracket : '[' ;
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_kwargs rbrace
| tLBRACE rbrace
| tLPAREN p_expr rparen
;
p_args : p_expr
| p_args_head
| p_args_head p_arg
| p_args_head p_rest
| p_args_head p_rest ',' p_args_post
| p_args_tail
;
p_args_head : p_arg ','
| p_args_head p_arg ','
;
p_args_tail : p_rest
| p_rest ',' p_args_post
;
p_find : p_rest ',' p_args_post ',' p_rest
;
p_rest : tSTAR tIDENTIFIER
| tSTAR
;
p_args_post : p_arg
| p_args_post ',' p_arg
;
p_arg : p_expr
;
p_kwargs : p_kwarg ',' p_any_kwrest
| p_kwarg
| p_kwarg ','
| p_any_kwrest
;
p_kwarg : p_kw
| p_kwarg ',' p_kw
;
p_kw : p_kw_label p_expr
| p_kw_label
;
p_kw_label : tLABEL
| tSTRING_BEG string_contents tLABEL_END
;
p_kwrest : kwrest_mark tIDENTIFIER
| kwrest_mark
;
p_kwnorest : kwrest_mark keyword_nil
;
p_any_kwrest : p_kwrest
| p_kwnorest
;
p_value : p_primitive
| p_primitive tDOT2 p_primitive
| p_primitive tDOT3 p_primitive
| p_primitive tDOT2
| p_primitive tDOT3
| p_var_ref
| p_expr_ref
| p_const
| tBDOT2 p_primitive
| tBDOT3 p_primitive
;
p_primitive : literal
| strings
| xstring
| regexp
| words
| qwords
| symbols
| qsymbols
| keyword_variable
| lambda
;
p_variable : tIDENTIFIER
;
p_var_ref : '^' tIDENTIFIER
| '^' nonlocal_var
;
p_expr_ref : '^' tLPAREN expr_value ')'
;
p_const : tCOLON3 cname
| p_const tCOLON2 cname
| tCONSTANT
;
opt_rescue : k_rescue exc_list exc_var then
compstmt
opt_rescue
| none
;
exc_list : arg_value
| mrhs
| none
;
exc_var : tASSOC lhs
| none
;
opt_ensure : k_ensure compstmt
| none
;
literal : numeric
| symbol
;
strings : string
;
string : tCHAR
| string1
| string string1
;
string1 : tSTRING_BEG string_contents tSTRING_END
;
xstring : tXSTRING_BEG xstring_contents tSTRING_END
;
regexp : tREGEXP_BEG regexp_contents tREGEXP_END
;
words : tWORDS_BEG ' ' word_list tSTRING_END
;
word_list :
| word_list word ' '
;
word : string_content
| word string_content
;
symbols : tSYMBOLS_BEG ' ' symbol_list tSTRING_END
;
symbol_list :
| symbol_list word ' '
;
qwords : tQWORDS_BEG ' ' qword_list tSTRING_END
;
qsymbols : tQSYMBOLS_BEG ' ' qsym_list tSTRING_END
;
qword_list :
| qword_list tSTRING_CONTENT ' '
;
qsym_list :
| qsym_list tSTRING_CONTENT ' '
;
string_contents :
| string_contents string_content
;
xstring_contents:
| xstring_contents string_content
;
regexp_contents:
| regexp_contents string_content
;
string_content : tSTRING_CONTENT
| tSTRING_DVAR
string_dvar
| tSTRING_DBEG
compstmt tSTRING_DEND
;
string_dvar : tGVAR
| tIVAR
| tCVAR
| backref
;
symbol : ssym
| dsym
;
ssym : tSYMBEG sym
;
sym : fname
| tIVAR
| tGVAR
| tCVAR
;
dsym : tSYMBEG string_contents tSTRING_END
;
numeric : simple_numeric
| tUMINUS_NUM simple_numeric %prec tLOWEST
;
simple_numeric : tINTEGER
| tFLOAT
| tRATIONAL
| tIMAGINARY
;
nonlocal_var : tIVAR
| tGVAR
| tCVAR
;
user_variable : tIDENTIFIER
| tIVAR
| tGVAR
| tCONSTANT
| tCVAR
;
keyword_variable: keyword_nil
| keyword_self
| keyword_true
| keyword_false
| keyword__FILE__
| keyword__LINE__
| keyword__ENCODING__
;
var_ref : user_variable
| keyword_variable
;
var_lhs : user_variable
| keyword_variable
;
backref : tNTH_REF
| tBACK_REF
;
superclass : '<'
expr_value term