-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtree-sitter-perl.ebnf
690 lines (508 loc) · 19.9 KB
/
tree-sitter-perl.ebnf
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
//
// From tree-sitter-perl/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
_statement*
_statement ::=
package_statement
| use_no_statement
| use_no_if_statement
| bareword_import
| use_no_subs_statement
| use_no_feature_statement
| use_no_version
| require_statement
| use_constant_statement
| use_parent_statement
| _expression_statement
| _declaration
| single_line_statement
| _compound_statement
| standalone_block
| named_block_statement
| ellipsis_statement
| special_block
| special_literal
| heredoc_body_statement
| pod_statement
heredoc_initializer ::=
_heredoc_operator heredoc_start_identifier
_heredoc_operator ::=
'<<'
heredoc_body_statement ::=
_imaginary_heredoc_start ( interpolation | escape_sequence | _heredoc_content )* heredoc_end_identifier
pod_statement ::=
'='[a-zA-Z_]* _pod_content
special_literal ::=
'__FILE__'
| '__LINE__'
| '__PACKAGE__'
| '__SUB__'
| '__END__'
| '__DATA__'
use_parent_statement ::=
'use' 'parent' ( no_require ',' )? ( _string ( ( ',' | '=>' ) _string )* ','? | word_list_qw ) semi_colon
use_constant_statement ::=
'use' 'constant' ( ( identifier | _string ) ( '=>' | ',' ) _expression | hash_ref ) semi_colon
special_block ::=
'sub'? ( 'BEGIN' | 'UNITCHECK' | 'CHECK' | 'INIT' | 'END' ) block
package_statement ::=
'package' package_name version? ( semi_colon | block )
ellipsis_statement ::=
'...' semi_colon?
use_no_version ::=
( 'use' | 'no' ) version semi_colon
use_no_feature_statement ::=
( 'use' | 'no' ) 'feature' ( _list | _string )? semi_colon
_expression_or_return_expression ::=
_expression
| return_expression
single_line_statement ::=
_expression_or_return_expression _statement_modifiers
_statement_modifiers ::=
if_simple_statement
| unless_simple_statement
| while_simple_statement
| until_simple_statement
| for_simple_statement
| when_simple_statement
_compound_statement ::=
if_statement
| unless_statement
| while_statement
| until_statement
| for_statement_1
| for_statement_2
_expression_statement ::=
_expression semi_colon
use_no_statement ::=
( 'use' | 'no' ) ( package_name | module_name ) version? ( _list | _string )? semi_colon
use_no_if_statement ::=
( 'use' | 'no' ) _if_simple ',' ( package_name | module_name | _string ) version? _comma_operator? ( _list | _string )? semi_colon
bareword_import ::=
identifier '->' 'import' _list semi_colon
use_no_subs_statement ::=
( 'use' | 'no' ) 'subs' _list semi_colon
require_statement ::=
'require' package_name semi_colon
if_simple_statement ::=
_if_simple semi_colon
_if_simple ::=
'if' ( parenthesized_expression | _expression )
unless_simple_statement ::=
'unless' ( parenthesized_expression | _expression ) semi_colon
while_simple_statement ::=
'while' ( parenthesized_expression | _expression ) semi_colon
until_simple_statement ::=
'until' ( parenthesized_expression | _expression ) semi_colon
for_simple_statement ::=
( 'for' | 'foreach' ) _expression | '(' _expression ')' semi_colon
when_simple_statement ::=
'when' ( parenthesized_expression | _expression ) semi_colon
if_statement ::=
'if' parenthesized_expression block elsif_clause* else_clause?
unless_statement ::=
'unless' parenthesized_expression block elsif_clause* else_clause?
elsif_clause ::=
'elsif' parenthesized_expression block
else_clause ::=
'else' block
while_statement ::=
( identifier ':' )? 'while' empty_parenthesized_expression block continue?
continue ::=
'continue' block
until_statement ::=
( identifier ':' )? 'until' empty_parenthesized_expression block continue?
for_statement_1 ::=
( identifier ':' )? ( 'for' | 'foreach' ) _for_parenthesize block
for_statement_2 ::=
( identifier ':' )? ( 'for' | 'foreach' ) ( scope? scalar_variable | '\\' scope? hash_variable )? array block continue?
_for_parenthesize ::=
'(' _expression semi_colon _expression semi_colon _expression ')'
| '(' semi_colon semi_colon ')'
_declaration ::=
function_definition
variable_declaration ::=
scope ( multi_var_declaration | single_var_declaration | type_glob_declaration ) _initializer?
multi_var_declaration ::=
'(' variable_declarator ( ( ',' | '=>' ) variable_declarator )* ','? ')'
single_var_declaration ::=
variable_declarator
variable_declarator ::=
_variables
_initializer ::=
'=' _expression
type_glob_declaration ::=
type_glob
scope ::=
'our'
| 'state'
| 'my'
| 'local'
function_definition ::=
scope? 'sub' identifier ( function_prototype? function_attribute? function_signature? semi_colon | function_prototype? function_attribute? block | function_attribute? function_signature? block | ':' 'prototype' function_prototype function_signature block )
anonymous_function ::=
'sub' block
block ::=
'{' _block_statements*? '}'
function_prototype ::=
'(' prototype? ')'
prototype ::=
[#x5B#x5D$@%&*\]+
function_attribute ::=
':' identifier ( ':'? identifier )*
function_signature ::=
'(' ( _variables | _string | hash_ref | array_ref | ( scope? ( single_var_declaration | type_glob_declaration ) _initializer? ) ) ( ( ',' | '=>' ) ( _variables | _string | hash_ref | array_ref | ( scope? ( single_var_declaration | type_glob_declaration ) _initializer? ) ) )* ','? ')'
standalone_block ::=
( identifier ':' )? '{' _block_statements*? '}' continue?
_block_statements ::=
_statement
| return_expression semi_colon
| loop_control_statement
loop_control_statement ::=
loop_control_keyword identifier? ( _statement_modifiers | semi_colon )
named_block_statement ::=
( identifier '{' ( _statement | return_expression semi_colon )* '}' )+ semi_colon
parenthesized_expression ::=
'(' _expression ')'
empty_parenthesized_expression ::=
'(' _expression? ')'
return_expression ::=
'return' _expression?
_expression ::=
_expression_without_bareword | call_expression_with_bareword | '(' ( _expression_without_bareword | call_expression_with_bareword ) ')'
_expression_without_bareword ::=
_primitive_expression | _string | _variables | _special_variable | _dereference | package_variable | binary_expression | unary_expression | ternary_expression | call_expression | call_expression_recursive | method_invocation | goto_expression | command_qx_quoted | backtick_quoted | patter_matcher_m | regex_pattern_qr | substitution_pattern_s | transliteration_tr_or_y | heredoc_initializer | pattern_matcher | _i_o_operator | type_glob | anonymous_function | bless | grep_or_map_function | join_function | sort_function | unpack_function | push_function | array_function | variable_declaration | '(' ( _primitive_expression | _string | _variables | _special_variable | _dereference | package_variable | binary_expression | unary_expression | ternary_expression | call_expression | call_expression_recursive | method_invocation | goto_expression | command_qx_quoted | backtick_quoted | patter_matcher_m | regex_pattern_qr | substitution_pattern_s | transliteration_tr_or_y | heredoc_initializer | pattern_matcher | _i_o_operator | type_glob | anonymous_function | bless | grep_or_map_function | join_function | sort_function | unpack_function | push_function | array_function | variable_declaration ) ')'
array_function ::=
identifier list_block _expression
package_variable ::=
( scalar_variable '::' ( identifier '::' )* ) identifier
push_function ::=
'push' _expression ( ( ',' | '=>' ) _expression )* ','? | '(' _expression ( ( ',' | '=>' ) _expression )* ','? ')'
grep_or_map_function ::=
( 'grep' | 'map' ) ( list_block _expression | _expression ( ( ',' | '=>' ) _expression )* ','? | '(' _expression ( ( ',' | '=>' ) _expression )* ','? ')' )
join_function ::=
( 'join' ) _expression ( ( ',' | '=>' ) _expression )* ','? | '(' _expression ( ( ',' | '=>' ) _expression )* ','? ')'
reverse_function ::=
'reverse' _expression ( ( ',' | '=>' ) _expression )* ','? | '(' _expression ( ( ',' | '=>' ) _expression )* ','? ')'?
sort_function ::=
'sort' ( _expression | list_block _expression | call_expression _expression )
unpack_function ::=
'unpack' _expression ( ( ',' | '=>' ) _expression )* ','? | '(' _expression ( ( ',' | '=>' ) _expression )* ','? ')'
list_block ::=
'{' ( ( _expression_without_bareword | key_value_pair )+ | _statement+ ) '}'
_special_variable ::=
'local'? ( special_scalar_variable | special_array_variable | special_hash_variable )
special_scalar_variable ::=
'$!' | '$"' | '$#' | '$$' | '$%' | '$&' | "$'" | '$(' | '$)' | '$*' | '$+' | '$,' | '$-' | '$.' | '$/' | '$0' | '$1' | '$2' | '$3' | '$4' | '$5' | '$6' | '$7' | '$8' | '$9' | '$:' | '$;' | '$<' | '$=' | '$>' | '$?' | '$@' | '$ACCUMULATOR' | '$ARG' | '$ARGV' | '$BASETIME' | '$CHILD_ERROR' | '$COMPILING' | '$DEBUGGING' | '$EFFECTIVE_GROUP_ID' | '$EFFECTIVE_USER_ID' | '$EGID' | '$ERRNO' | '$EUID' | '$EVAL_ERROR' | '$EXCEPTIONS_BEING_CAUGHT' | '$EXECUTABLE_NAME' | '$EXTENDED_OS_ERROR' | '$FORMAT_FORMFEED' | '$FORMAT_LINES_LEFT' | '$FORMAT_LINES_PER_PAGE' | '$FORMAT_LINE_BREAK_CHARACTERS' | '$FORMAT_NAME' | '$FORMAT_PAGE_NUMBER' | '$FORMAT_TOP_NAME' | '$GID' | '$INPLACE_EDIT' | '$INPUT_LINE_NUMBER' | '$INPUT_RECORD_SEPARATOR' | '$LAST_PAREN_MATCH' | '$LAST_REGEXP_CODE_RESULT' | '$LAST_SUBMATCH_RESULT' | '$LIST_SEPARATOR' | '$MATCH' | '$NR' | '$OFS' | '$OLD_PERL_VERSION' | '$ORS' | '$OSNAME' | '$OS_ERROR' | '$OUTPUT_AUTOFLUSH' | '$OUTPUT_FIELD_SEPARATOR' | '$OUTPUT_RECORD_SEPARATOR' | '$PERLDB' | '$PERL_VERSION' | '$PID' | '$POSTMATCH' | '$PREMATCH' | '$PROCESS_ID' | '$PROGRAM_NAME' | '$REAL_GROUP_ID' | '$REAL_USER_ID' | '$RS' | '$SUBSCRIPT_SEPARATOR' | '$SUBSEP' | '$SYSTEM_FD_MAX' | '$UID' | '$WARNING' | '$[' | '$\' | '$]' | '$^' | '$^A' | '$^C' | '$^D' | '$^E' | '$^F' | '$^H' | '$^I' | '$^L' | '$^M' | '$^N' | '$^O' | '$^P' | '$^R' | '$^S' | '$^T' | '$^V' | '$^W' | '$^X' | '$_' | '$`' | '$a' | '$b' | '${^CHILD_ERROR_NATIVE}' | '${^ENCODING}' | '${^GLOBAL_PHASE}' | '${^LAST_FH}' | '${^MATCH}' | '${^OPEN}' | '${^POSTMATCH}' | '${^PREMATCH}' | '${^RE_COMPILE_RECURSION_LIMIT}' | '${^RE_DEBUG_FLAGS}' | '${^RE_TRIE_MAXBUF}' | '${^SAFE_LOCALES}' | '${^TAINT}' | '${^UNICODE}' | '${^UTF8CACHE}' | '${^UTF8LOCALE}' | '${^WARNING_BITS}' | '${^WIN32_SLOPPY_STAT}' | '$|' | '$~' | '$ENV' | '$INC' | '$SIG' | '${^CAPTURE_ALL}' | '${^CAPTURE}' | '$F' | '$ISA' | '$LAST_MATCH_END' | '$LAST_MATCH_START'
special_array_variable ::=
'@+'
| '@-'
| '@ARG'
| '@ARGV'
| '@F'
| '@INC'
| '@ISA'
| '@LAST_MATCH_END'
| '@LAST_MATCH_START'
| '@_'
| '@{^CAPTURE}'
| '@!'
| '@ENV'
| '@ERRNO'
| '@INC'
| '@LAST_PAREN_MATCH'
| '@OS_ERROR'
| '@SIG'
| '@^H'
| '@{^CAPTURE_ALL}'
| '@{^CAPTURE}'
special_hash_variable ::=
'%!'
| '%+'
| '%-'
| '%ENV'
| '%ERRNO'
| '%INC'
| '%LAST_PAREN_MATCH'
| '%OS_ERROR'
| '%SIG'
| '%^H'
| '%{^CAPTURE_ALL}'
| '%{^CAPTURE}'
bless ::=
'bless' _reference ( ',' _expression )? | '(' _reference ( ',' _expression )? ')'
type_glob ::=
'*' ( identifier )
goto_expression ::=
'goto' ( identifier ':' | _expression | call_expression )
binary_expression ::=
_expression '+' _expression
| _expression '-' _expression
| _exponentiation
| _binding_expression
| _bodmas_1
| _bodmas_2
| _shift_expression
| _relational_expression
| _equality_expression
| _class_instance_exp
| _bitwise_and_exp
| _bitwise_or_xor_exp
| _logical_and_exp
| _logical_ors_exp
| _range_exp
| _assignment_exp
| _logical_verbal_or_xor
unary_expression ::=
_auto_increment_decrement
| _symbolic_unary
| _unary_not
| _unary_and
ternary_expression ::=
_expression '?' _expression ':' _expression
_auto_increment_decrement ::=
( '++' | '--' ) _expression | _expression ( '++' | '--' )
_exponentiation ::=
_expression '**' _expression
_symbolic_unary ::=
'!' _expression | '~' _expression | to_reference | '+' _expression | '-' _expression
_binding_expression ::=
_expression '=~' _expression | _expression '!~' _expression
_bodmas_1 ::=
_expression '*' _expression | _expression '/' _expression | _expression '%' _expression | _expression 'x' _expression
_bodmas_2 ::=
_expression '+' _expression | _expression '-' _expression | _expression '.' _expression
_shift_expression ::=
_expression_without_bareword '<<' _expression_without_bareword | _expression_without_bareword '>>' _expression_without_bareword
_relational_expression ::=
_expression ( ( '<' | '>' | '<=' | '>=' | 'lt' | 'gt' | 'le' | 'ge' ) _expression )+
_equality_expression ::=
_expression ( ( '==' | '!=' | 'eq' | 'ne' ) _expression )+ | _expression '<=>' _expression | _expression 'cmp' _expression | _expression '~~' _expression
_class_instance_exp ::=
_expression 'isa' _expression
_bitwise_and_exp ::=
_expression '&' _expression
_bitwise_or_xor_exp ::=
_expression '|' _expression | _expression '^' _expression
_logical_and_exp ::=
_expression '&&' _expression
_logical_ors_exp ::=
_expression '||' _expression | _expression '//' _expression
_range_exp ::=
_expression '..' _expression | _expression '...' _expression
_assignment_exp ::=
_expression '=' _expression | _expression '**=' _expression | _expression '+=' _expression | _expression '*=' _expression | _expression '&=' _expression | _expression '&.=' _expression | _expression '<<=' _expression | _expression '&&=' _expression | _expression '-=' _expression | _expression '/=' _expression | _expression '|=' _expression | _expression '|.=' _expression | _expression '>>=' _expression | _expression '||=' _expression | _expression '.=' _expression | _expression '%=' _expression | _expression '^=' _expression | _expression '^.=' _expression | _expression '//=' _expression | _expression 'X=' _expression
_comma_operator ::=
','
| '=>'
_unary_not ::=
'not' _expression
_unary_and ::=
'and' _expression
_logical_verbal_or_xor ::=
_expression 'or' _expression | _expression 'xor' _expression
_i_o_operator ::=
standard_input
| file_handle
| standard_input_to_identifier
| standard_input_to_variable
standard_input ::=
'<>'
| '<<>>'
| '<STDIN>'
| '\\'*'STDIN'
file_handle ::=
'<FILEHANDLE>'
standard_input_to_identifier ::=
'<' identifier '>'
standard_input_to_variable ::=
'<' scalar_variable '>'
call_expression ::=
'&'? ( package_name '::' )? identifier ( empty_parenthesized_argument | parenthesized_argument | arguments )
call_expression_with_bareword ::=
'&'? ( package_name '::' )? identifier
method_invocation ::=
( ( identifier | package_name | string_single_quoted ) | scalar_variable | _expression ) ( arrow_operator ( ( super '::' )? identifier | scalar_variable | scalar_dereference ) ( empty_parenthesized_argument | parenthesized_argument | arguments )? )+
empty_parenthesized_argument ::=
'(' ')'
parenthesized_argument ::=
'(' arguments ')'
arguments ::=
argument ( ( ',' | '=>' ) argument )* ','?
argument ::=
key_value_pair | _expression
call_expression_recursive ::=
'__SUB__' '->' parenthesized_argument
_primitive_expression ::=
_scalar_type
| _boolean
| _array_type
| hash
_variables ::=
scalar_variable
| array_variable
| hash_variable
_scalar_type ::=
string_single_quoted
| string_q_quoted
| string_double_quoted
| string_qq_quoted
| _numeric_literals
| array_ref
| hash_ref
| array_access_variable
| hash_access_variable
_string ::=
string_single_quoted | string_q_quoted | string_double_quoted | string_qq_quoted | heredoc_initializer
_resolves_to_digit ::=
string_single_quoted
| string_q_quoted
| string_qq_quoted
| _numeric_literals
_array_type ::=
array
| word_list_qw
_numeric_literals ::=
integer
| floating_point
| scientific_notation
| hexadecimal
| octal
integer ::=
'-'?[0-9]+
floating_point ::=
'-'?[0-9]+'.'[0-9]+
scientific_notation ::=
[-+]?[0-9]*'.'?[0-9]+([eE][-+]?[0-9]+)?
hexadecimal ::=
'0'[xX][0-9a-fA-F]+
octal ::=
'0'[1-7][0-7]*
version ::=
'v'[0-9.]+
| [0-9.]+
| [0-9._]+
identifier ::=
[a-zA-Z0-9_]+
identifier_2 ::=
[a-zA-Z0-9_$:.@%\^]+
loop_control_keyword ::=
'next'
| 'last'
| 'redo'
package_name ::=
identifier
| identifier ( '::' identifier )+
module_name ::=
"'" '.'*'pm' "'"
| '"' '.'*'pm' '"'
semi_colon ::=
';'
string_single_quoted ::=
"'" _string_single_quoted_content* "'"
string_q_quoted ::=
'q' ( '{' [^}]+ '}' | '/' [^/]+ '/' | '(' [^)]+ ')' | "'" [^']+ "'" )
string_double_quoted ::=
'"' ( interpolation | escape_sequence | _string_double_quoted_content )* '"'
string_qq_quoted ::=
'qq' _start_delimiter ( _string_qq_quoted_content | interpolation | escape_sequence )* _end_delimiter
command_qx_quoted ::=
'qx' ( string_single_quoted | _start_delimiter ( _string_qq_quoted_content | interpolation | escape_sequence )* _end_delimiter )
backtick_quoted ::=
'`' ( interpolation | escape_sequence | [^`]+ )* '`'
word_list_qw ::=
'qw' _start_delimiter_qw _element_in_qw* _end_delimiter_qw
patter_matcher_m ::=
'm' _start_delimiter_regex ( _regex_pattern | interpolation | escape_sequence )* _end_delimiter_regex regex_option?
pattern_matcher ::=
'/' regex_pattern '/' regex_option?
regex_pattern_qr ::=
'qr' _start_delimiter_regex ( _regex_pattern | interpolation | escape_sequence )* _end_delimiter_regex regex_option?
substitution_pattern_s ::=
's' _start_delimiter_search_replace ( _search_replace_content | interpolation | escape_sequence )* _separator_delimiter_search_replace ( _search_replace_content | interpolation | escape_sequence )* _end_delimiter_search_replace regex_option_for_substitution?
transliteration_tr_or_y ::=
( 'tr' | 'y' ) _start_delimiter_transliteration _transliteration_content* _separator_delimiter_transliteration _transliteration_content* _end_delimiter_transliteration regex_option_for_transliteration?
regex_pattern ::=
( '[' ( '\\' '.' | [^#x5D#x0A\] )* ']' | '\\' '.' | [^/\#x5B#x0A] )+
regex_option ::=
[msixpodualng]+
regex_option_for_substitution ::=
[msixpodualngcer]+
regex_option_for_transliteration ::=
[cdsr]+
escape_sequence ::=
'\\' [tnrfbae]
interpolation ::=
array_variable
| hash_ref_in_interpolation
| scalar_variable
| _special_variable
hash_ref_in_interpolation ::=
'\$_'?[a-zA-Z0-9_]+ '->' '{' ( identifier | scalar_variable ) '}'
_boolean ::=
true
| false
true ::=
'true'
false ::=
'false'
scalar_variable ::=
'\$\#_'?[a-zA-Z0-9_]+
| '\$'[A-Z^_?\]
| '\$_'?[a-zA-Z0-9_]+
array_access_variable ::=
( scalar_variable | array_access_variable | hash_access_variable | call_expression | method_invocation | _expression ) ( ( '->[' | '[' ) _expression ']' )+
hash_access_variable ::=
( scalar_variable | array_access_variable | hash_access_variable | call_expression | method_invocation | _expression ) ( ( '->{' | '{' ) ( identifier | key_words_in_hash_key | _expression_without_bareword ) '}' )+
array_variable ::=
'@'[a-zA-Z0-9_]+
hash_variable ::=
'%'[a-zA-Z0-9_]+
_list ::=
_array_type
| array_variable
array ::=
'(' _expression ( ( ',' | '=>' ) _expression )* ','?? ')'
array_ref ::=
'[' _expression ( ( ',' | '=>' ) _expression )* ','?? ']'
hash ::=
'(' ( ternary_expression | key_value_pair | hash_dereference ) ( ',' ( ternary_expression | key_value_pair | hash_dereference ) )* ','?? ')'
hash_ref ::=
'+'? '{' ( ternary_expression | key_value_pair | hash_dereference | hash_variable ) ( ',' ( ternary_expression | key_value_pair | hash_dereference | hash_variable ) )* ','?? '}'
_reference ::=
array_ref
| hash_ref
| scalar_variable
| to_reference
to_reference ::=
'\\' _expression
_dereference ::=
scalar_dereference
| array_dereference
| hash_dereference
scalar_dereference ::=
'$' _expression_without_bareword | '{' _expression_without_bareword '}'
array_dereference ::=
'@' _expression | '{' _expression '}'
hash_dereference ::=
'%' _expression | '{' _expression '}'
key_value_pair ::=
( identifier | key_words_in_hash_key | ( scope? ( single_var_declaration | type_glob_declaration ) _initializer? ) | _expression_without_bareword ) hash_arrow_operator _expression
key_words_in_hash_key ::=
'sub'
arrow_operator ::=
'->'
hash_arrow_operator ::=
'=>'
super ::=
'SUPER'
no_require ::=
'-norequire'
comments ::=
'#' '.'*