rattler 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -3
- data/features/command_line/dest_option.feature +1 -1
- data/features/command_line/lib_option.feature +2 -2
- data/features/command_line/output_option.feature +2 -2
- data/features/command_line/parser_generator.feature +3 -3
- data/features/grammar/any_character.feature +0 -4
- data/features/grammar/back_reference.feature +0 -4
- data/features/grammar/character_class.feature +0 -4
- data/features/grammar/comments.feature +0 -4
- data/features/grammar/e_symbol.feature +18 -0
- data/features/grammar/eof.feature +0 -4
- data/features/grammar/fail.feature +0 -4
- data/features/grammar/list_matching.feature +52 -3
- data/features/grammar/literal.feature +0 -4
- data/features/grammar/negative_lookahead.feature +0 -4
- data/features/grammar/negative_semantic_predicate.feature +99 -0
- data/features/grammar/node_action.feature +17 -4
- data/features/grammar/nonterminal.feature +3 -7
- data/features/grammar/one_or_more.feature +0 -4
- data/features/grammar/optional.feature +0 -4
- data/features/grammar/ordered_choice.feature +0 -4
- data/features/grammar/positive_lookahead.feature +0 -4
- data/features/grammar/positive_semantic_predicate.feature +99 -0
- data/features/grammar/posix_class.feature +3 -6
- data/features/grammar/repeat.feature +50 -0
- data/features/grammar/sequence.feature +0 -4
- data/features/grammar/side_effect.feature +81 -0
- data/features/grammar/skip_operator.feature +2 -5
- data/features/grammar/start_rule.feature +1 -5
- data/features/grammar/symantic_action.feature +9 -4
- data/features/grammar/token.feature +0 -4
- data/features/grammar/whitespace.feature +0 -4
- data/features/grammar/word_literal.feature +0 -4
- data/features/grammar/zero_or_more.feature +0 -4
- data/features/step_definitions/grammar_steps.rb +5 -1
- data/lib/rattler/back_end/optimizer.rb +1 -0
- data/lib/rattler/back_end/optimizer/reduce_repeat_match.rb +20 -8
- data/lib/rattler/back_end/optimizer/simplify_redundant_repeat.rb +10 -7
- data/lib/rattler/back_end/optimizer/specialize_repeat.rb +40 -0
- data/lib/rattler/back_end/parser_generator.rb +11 -6
- data/lib/rattler/back_end/parser_generator/delegating_generator.rb +20 -0
- data/lib/rattler/back_end/parser_generator/e_symbol_generator.rb +52 -0
- data/lib/rattler/back_end/parser_generator/eof_generator.rb +58 -0
- data/lib/rattler/back_end/parser_generator/expr_generator.rb +6 -2
- data/lib/rattler/back_end/parser_generator/gen_method_names.rb +15 -5
- data/lib/rattler/back_end/parser_generator/general_list_generator.rb +194 -0
- data/lib/rattler/back_end/parser_generator/general_repeat_generator.rb +177 -0
- data/lib/rattler/back_end/parser_generator/label_generator.rb +4 -1
- data/lib/rattler/back_end/parser_generator/list0_generating.rb +36 -0
- data/lib/rattler/back_end/parser_generator/list1_generating.rb +30 -0
- data/lib/rattler/back_end/parser_generator/list_generator.rb +16 -20
- data/lib/rattler/back_end/parser_generator/one_or_more_generating.rb +25 -0
- data/lib/rattler/back_end/parser_generator/{optional_generator.rb → optional_generating.rb} +66 -81
- data/lib/rattler/back_end/parser_generator/predicate_propogating.rb +4 -4
- data/lib/rattler/back_end/parser_generator/repeat_generator.rb +53 -0
- data/lib/rattler/back_end/parser_generator/skip_propogating.rb +2 -2
- data/lib/rattler/back_end/parser_generator/sub_generating.rb +16 -18
- data/lib/rattler/back_end/parser_generator/token_propogating.rb +1 -1
- data/lib/rattler/back_end/parser_generator/zero_or_more_generating.rb +31 -0
- data/lib/rattler/grammar/grammar_parser.rb +20 -0
- data/lib/rattler/grammar/metagrammar.rb +131 -13
- data/lib/rattler/grammar/rattler.rtlr +25 -12
- data/lib/rattler/parsers.rb +9 -5
- data/lib/rattler/parsers/assert_code.rb +31 -0
- data/lib/rattler/parsers/atomic.rb +19 -0
- data/lib/rattler/parsers/direct_action.rb +12 -4
- data/lib/rattler/parsers/disallow_code.rb +31 -0
- data/lib/rattler/parsers/dispatch_action.rb +3 -2
- data/lib/rattler/parsers/e_symbol.rb +47 -0
- data/lib/rattler/parsers/effect_code.rb +31 -0
- data/lib/rattler/parsers/eof.rb +6 -13
- data/lib/rattler/parsers/list_parser.rb +33 -14
- data/lib/rattler/parsers/match.rb +1 -6
- data/lib/rattler/parsers/parser_dsl.rb +78 -35
- data/lib/rattler/parsers/predicate.rb +1 -4
- data/lib/rattler/parsers/repeat.rb +76 -0
- data/lib/rattler/parsers/semantic_assert.rb +19 -0
- data/lib/rattler/parsers/semantic_disallow.rb +19 -0
- data/lib/rattler/parsers/side_effect.rb +19 -0
- data/lib/rattler/parsers/skip.rb +1 -9
- data/lib/rattler/parsers/token.rb +1 -6
- data/lib/rattler/util/graphviz/node_builder.rb +6 -3
- data/spec/rattler/back_end/assert_compiler_examples.rb +187 -0
- data/spec/rattler/back_end/direct_action_compiler_examples.rb +227 -0
- data/spec/rattler/back_end/disallow_compiler_examples.rb +187 -0
- data/spec/rattler/back_end/dispatch_action_compiler_examples.rb +225 -0
- data/spec/rattler/back_end/optimizer/reduce_repeat_match_spec.rb +45 -33
- data/spec/rattler/back_end/optimizer/simplify_redundant_repeat_spec.rb +32 -172
- data/spec/rattler/back_end/parser_generator/e_symbol_generator_spec.rb +149 -0
- data/spec/rattler/back_end/parser_generator/eof_generator_spec.rb +152 -0
- data/spec/rattler/back_end/parser_generator/label_generator_spec.rb +4 -4
- data/spec/rattler/back_end/parser_generator/list0_generator_examples.rb +322 -0
- data/spec/rattler/back_end/parser_generator/list1_generator_examples.rb +343 -0
- data/spec/rattler/back_end/parser_generator/list_generator_spec.rb +597 -140
- data/spec/rattler/back_end/parser_generator/one_or_more_generator_examples.rb +292 -0
- data/spec/rattler/back_end/parser_generator/optional_generator_examples.rb +233 -0
- data/spec/rattler/back_end/parser_generator/repeat_generator_spec.rb +281 -0
- data/spec/rattler/back_end/parser_generator/zero_or_more_generator_examples.rb +277 -0
- data/spec/rattler/back_end/semantic_assert_compiler_examples.rb +152 -0
- data/spec/rattler/back_end/semantic_disallow_compiler_examples.rb +152 -0
- data/spec/rattler/back_end/shared_compiler_examples.rb +106 -651
- data/spec/rattler/back_end/side_effect_compiler_examples.rb +227 -0
- data/spec/rattler/back_end/skip_compiler_examples.rb +161 -0
- data/spec/rattler/back_end/token_compiler_examples.rb +262 -0
- data/spec/rattler/grammar/grammar_parser_spec.rb +302 -23
- data/spec/rattler/parsers/apply_spec.rb +6 -0
- data/spec/rattler/parsers/assert_spec.rb +18 -7
- data/spec/rattler/parsers/back_reference_spec.rb +9 -0
- data/spec/rattler/parsers/choice_spec.rb +36 -21
- data/spec/rattler/parsers/direct_action_spec.rb +76 -36
- data/spec/rattler/parsers/disallow_spec.rb +18 -7
- data/spec/rattler/parsers/dispatch_action_spec.rb +128 -22
- data/spec/rattler/parsers/e_symbol_spec.rb +30 -0
- data/spec/rattler/parsers/eof_spec.rb +15 -6
- data/spec/rattler/parsers/label_spec.rb +15 -2
- data/spec/rattler/parsers/list_parser_spec.rb +187 -0
- data/spec/rattler/parsers/match_spec.rb +16 -7
- data/spec/rattler/parsers/parser_dsl_spec.rb +82 -23
- data/spec/rattler/parsers/repeat_spec.rb +233 -0
- data/spec/rattler/parsers/semantic_assert_spec.rb +83 -0
- data/spec/rattler/parsers/semantic_disallow_spec.rb +83 -0
- data/spec/rattler/parsers/sequence_spec.rb +34 -20
- data/spec/rattler/parsers/side_effect_spec.rb +214 -0
- data/spec/rattler/parsers/skip_spec.rb +17 -6
- data/spec/rattler_spec.rb +2 -0
- data/spec/support/compiler_spec_helper.rb +8 -0
- metadata +156 -447
- data/bin/rtlr.compiled.rbc +0 -201
- data/features/step_definitions/cli_steps.rbc +0 -149
- data/features/step_definitions/grammar_steps.rbc +0 -1211
- data/features/support/env.rbc +0 -389
- data/lib/rattler.rbc +0 -1231
- data/lib/rattler/back_end.rbc +0 -286
- data/lib/rattler/back_end/compiler.rbc +0 -1394
- data/lib/rattler/back_end/optimizer.rbc +0 -2000
- data/lib/rattler/back_end/optimizer/composite_reducing.rbc +0 -337
- data/lib/rattler/back_end/optimizer/flatten_choice.rbc +0 -443
- data/lib/rattler/back_end/optimizer/flatten_sequence.rbc +0 -827
- data/lib/rattler/back_end/optimizer/flattening.rbc +0 -570
- data/lib/rattler/back_end/optimizer/inline_regular_rules.rbc +0 -691
- data/lib/rattler/back_end/optimizer/join_match_capturing_sequence.rbc +0 -1299
- data/lib/rattler/back_end/optimizer/join_match_choice.rbc +0 -523
- data/lib/rattler/back_end/optimizer/join_match_matching_sequence.rbc +0 -619
- data/lib/rattler/back_end/optimizer/join_match_sequence.rbc +0 -174
- data/lib/rattler/back_end/optimizer/join_predicate_bare_match.rbc +0 -1505
- data/lib/rattler/back_end/optimizer/join_predicate_match.rbc +0 -174
- data/lib/rattler/back_end/optimizer/join_predicate_nested_match.rbc +0 -620
- data/lib/rattler/back_end/optimizer/join_predicate_or_bare_match.rbc +0 -1502
- data/lib/rattler/back_end/optimizer/join_predicate_or_match.rbc +0 -174
- data/lib/rattler/back_end/optimizer/join_predicate_or_nested_match.rbc +0 -616
- data/lib/rattler/back_end/optimizer/match_joining.rbc +0 -1454
- data/lib/rattler/back_end/optimizer/optimization.rbc +0 -1366
- data/lib/rattler/back_end/optimizer/optimization_context.rbc +0 -1386
- data/lib/rattler/back_end/optimizer/optimization_sequence.rbc +0 -520
- data/lib/rattler/back_end/optimizer/optimize_children.rbc +0 -793
- data/lib/rattler/back_end/optimizer/reduce_repeat_match.rbc +0 -788
- data/lib/rattler/back_end/optimizer/remove_meaningless_wrapper.rbc +0 -508
- data/lib/rattler/back_end/optimizer/simplify_redundant_repeat.rbc +0 -807
- data/lib/rattler/back_end/optimizer/simplify_token_match.rbc +0 -561
- data/lib/rattler/back_end/parser_generator.rbc +0 -1326
- data/lib/rattler/back_end/parser_generator/apply_generator.rbc +0 -2148
- data/lib/rattler/back_end/parser_generator/assert_generator.rbc +0 -1967
- data/lib/rattler/back_end/parser_generator/back_reference_generator.rbc +0 -1665
- data/lib/rattler/back_end/parser_generator/choice_generator.rbc +0 -2793
- data/lib/rattler/back_end/parser_generator/direct_action_generator.rbc +0 -1071
- data/lib/rattler/back_end/parser_generator/disallow_generator.rbc +0 -1967
- data/lib/rattler/back_end/parser_generator/dispatch_action_generator.rbc +0 -1071
- data/lib/rattler/back_end/parser_generator/expr_generator.rbc +0 -2295
- data/lib/rattler/back_end/parser_generator/fail_generator.rbc +0 -1216
- data/lib/rattler/back_end/parser_generator/gen_method_names.rbc +0 -296
- data/lib/rattler/back_end/parser_generator/group_match.rbc +0 -612
- data/lib/rattler/back_end/parser_generator/group_match_generator.rbc +0 -1647
- data/lib/rattler/back_end/parser_generator/label_generator.rbc +0 -1401
- data/lib/rattler/back_end/parser_generator/list1_generator.rb +0 -54
- data/lib/rattler/back_end/parser_generator/list1_generator.rbc +0 -1237
- data/lib/rattler/back_end/parser_generator/list_generating.rb +0 -71
- data/lib/rattler/back_end/parser_generator/list_generating.rbc +0 -1900
- data/lib/rattler/back_end/parser_generator/list_generator.rbc +0 -1068
- data/lib/rattler/back_end/parser_generator/match_generator.rbc +0 -1743
- data/lib/rattler/back_end/parser_generator/nested.rbc +0 -496
- data/lib/rattler/back_end/parser_generator/one_or_more_generator.rb +0 -56
- data/lib/rattler/back_end/parser_generator/one_or_more_generator.rbc +0 -1277
- data/lib/rattler/back_end/parser_generator/optional_generator.rbc +0 -2025
- data/lib/rattler/back_end/parser_generator/predicate_propogating.rbc +0 -648
- data/lib/rattler/back_end/parser_generator/repeat_generating.rb +0 -57
- data/lib/rattler/back_end/parser_generator/repeat_generating.rbc +0 -1549
- data/lib/rattler/back_end/parser_generator/rule_generator.rbc +0 -1239
- data/lib/rattler/back_end/parser_generator/rule_set_generator.rbc +0 -2641
- data/lib/rattler/back_end/parser_generator/sequence_generator.rbc +0 -4867
- data/lib/rattler/back_end/parser_generator/skip_generator.rbc +0 -1278
- data/lib/rattler/back_end/parser_generator/skip_propogating.rbc +0 -432
- data/lib/rattler/back_end/parser_generator/sub_generating.rbc +0 -2785
- data/lib/rattler/back_end/parser_generator/token_generator.rbc +0 -755
- data/lib/rattler/back_end/parser_generator/token_propogating.rbc +0 -324
- data/lib/rattler/back_end/parser_generator/top_level.rbc +0 -352
- data/lib/rattler/back_end/parser_generator/zero_or_more_generator.rb +0 -53
- data/lib/rattler/back_end/parser_generator/zero_or_more_generator.rbc +0 -1111
- data/lib/rattler/back_end/ruby_generator.rbc +0 -1841
- data/lib/rattler/grammar.rbc +0 -557
- data/lib/rattler/grammar/analysis.rbc +0 -1944
- data/lib/rattler/grammar/grammar.rbc +0 -1090
- data/lib/rattler/grammar/grammar_dsl.rbc +0 -1401
- data/lib/rattler/grammar/grammar_parser.rbc +0 -2096
- data/lib/rattler/grammar/metagrammar.rbc +0 -11014
- data/lib/rattler/parsers.rbc +0 -1006
- data/lib/rattler/parsers/action_code.rbc +0 -1577
- data/lib/rattler/parsers/apply.rbc +0 -562
- data/lib/rattler/parsers/assert.rbc +0 -378
- data/lib/rattler/parsers/back_reference.rbc +0 -871
- data/lib/rattler/parsers/choice.rbc +0 -607
- data/lib/rattler/parsers/combinator_parser.rbc +0 -612
- data/lib/rattler/parsers/combining.rbc +0 -570
- data/lib/rattler/parsers/direct_action.rbc +0 -1472
- data/lib/rattler/parsers/disallow.rbc +0 -379
- data/lib/rattler/parsers/dispatch_action.rbc +0 -2078
- data/lib/rattler/parsers/eof.rbc +0 -567
- data/lib/rattler/parsers/fail.rbc +0 -745
- data/lib/rattler/parsers/label.rbc +0 -749
- data/lib/rattler/parsers/list.rbc +0 -292
- data/lib/rattler/parsers/list0.rb +0 -26
- data/lib/rattler/parsers/list0.rbc +0 -292
- data/lib/rattler/parsers/list1.rb +0 -26
- data/lib/rattler/parsers/list1.rbc +0 -305
- data/lib/rattler/parsers/list_parser.rbc +0 -886
- data/lib/rattler/parsers/match.rbc +0 -621
- data/lib/rattler/parsers/node_code.rbc +0 -1064
- data/lib/rattler/parsers/one_or_more.rb +0 -47
- data/lib/rattler/parsers/one_or_more.rbc +0 -475
- data/lib/rattler/parsers/optional.rb +0 -42
- data/lib/rattler/parsers/optional.rbc +0 -450
- data/lib/rattler/parsers/parser.rbc +0 -994
- data/lib/rattler/parsers/parser_dsl.rbc +0 -4765
- data/lib/rattler/parsers/predicate.rbc +0 -490
- data/lib/rattler/parsers/rule.rbc +0 -777
- data/lib/rattler/parsers/rule_set.rbc +0 -1438
- data/lib/rattler/parsers/sequence.rbc +0 -1040
- data/lib/rattler/parsers/skip.rbc +0 -613
- data/lib/rattler/parsers/token.rbc +0 -457
- data/lib/rattler/parsers/zero_or_more.rb +0 -40
- data/lib/rattler/parsers/zero_or_more.rbc +0 -462
- data/lib/rattler/runner.rbc +0 -3813
- data/lib/rattler/runtime.rbc +0 -370
- data/lib/rattler/runtime/extended_packrat_parser.rbc +0 -2351
- data/lib/rattler/runtime/packrat_parser.rbc +0 -1390
- data/lib/rattler/runtime/parse_failure.rbc +0 -909
- data/lib/rattler/runtime/parse_node.rbc +0 -1007
- data/lib/rattler/runtime/parser.rbc +0 -2267
- data/lib/rattler/runtime/parser_helper.rbc +0 -337
- data/lib/rattler/runtime/recursive_descent_parser.rbc +0 -942
- data/lib/rattler/util.rbc +0 -286
- data/lib/rattler/util/graphviz.rbc +0 -327
- data/lib/rattler/util/graphviz/node_builder.rbc +0 -2207
- data/lib/rattler/util/line_counter.rbc +0 -988
- data/lib/rattler/util/node.rbc +0 -2393
- data/lib/rattler/util/parser_spec_helper.rbc +0 -2533
- data/spec/rattler/back_end/compiler_spec.rbc +0 -1187
- data/spec/rattler/back_end/optimizer/flatten_choice_spec.rbc +0 -2093
- data/spec/rattler/back_end/optimizer/flatten_sequence_spec.rbc +0 -4055
- data/spec/rattler/back_end/optimizer/inline_regular_rules_spec.rbc +0 -2345
- data/spec/rattler/back_end/optimizer/join_match_capturing_sequence_spec.rbc +0 -7006
- data/spec/rattler/back_end/optimizer/join_match_choice_spec.rbc +0 -3252
- data/spec/rattler/back_end/optimizer/join_match_matching_sequence_spec.rbc +0 -3681
- data/spec/rattler/back_end/optimizer/join_predicate_bare_match_spec.rbc +0 -5603
- data/spec/rattler/back_end/optimizer/join_predicate_nested_match_spec.rbc +0 -5232
- data/spec/rattler/back_end/optimizer/join_predicate_or_bare_match_spec.rbc +0 -4272
- data/spec/rattler/back_end/optimizer/join_predicate_or_nested_match_spec.rbc +0 -4342
- data/spec/rattler/back_end/optimizer/reduce_repeat_match_spec.rbc +0 -2960
- data/spec/rattler/back_end/optimizer/simplify_redundant_repeat_spec.rbc +0 -6929
- data/spec/rattler/back_end/optimizer/simplify_token_match_spec.rbc +0 -2327
- data/spec/rattler/back_end/optimizer_spec.rbc +0 -372
- data/spec/rattler/back_end/parser_generator/apply_generator_spec.rbc +0 -4710
- data/spec/rattler/back_end/parser_generator/assert_generator_spec.rbc +0 -4697
- data/spec/rattler/back_end/parser_generator/back_reference_generator_spec.rbc +0 -4855
- data/spec/rattler/back_end/parser_generator/choice_generator_spec.rbc +0 -5350
- data/spec/rattler/back_end/parser_generator/direct_action_generator_spec.rbc +0 -4737
- data/spec/rattler/back_end/parser_generator/disallow_generator_spec.rbc +0 -4697
- data/spec/rattler/back_end/parser_generator/dispatch_action_generator_spec.rbc +0 -4731
- data/spec/rattler/back_end/parser_generator/fail_generator_spec.rbc +0 -2115
- data/spec/rattler/back_end/parser_generator/group_match_generator_spec.rbc +0 -4195
- data/spec/rattler/back_end/parser_generator/group_match_spec.rbc +0 -1414
- data/spec/rattler/back_end/parser_generator/label_generator_spec.rbc +0 -4696
- data/spec/rattler/back_end/parser_generator/list1_generator_spec.rb +0 -309
- data/spec/rattler/back_end/parser_generator/list1_generator_spec.rbc +0 -5213
- data/spec/rattler/back_end/parser_generator/list_generator_spec.rbc +0 -5179
- data/spec/rattler/back_end/parser_generator/match_generator_spec.rbc +0 -4681
- data/spec/rattler/back_end/parser_generator/one_or_more_generator_spec.rb +0 -259
- data/spec/rattler/back_end/parser_generator/one_or_more_generator_spec.rbc +0 -4957
- data/spec/rattler/back_end/parser_generator/optional_generator_spec.rb +0 -190
- data/spec/rattler/back_end/parser_generator/optional_generator_spec.rbc +0 -4704
- data/spec/rattler/back_end/parser_generator/rule_generator_spec.rbc +0 -545
- data/spec/rattler/back_end/parser_generator/rule_set_generator_spec.rbc +0 -1110
- data/spec/rattler/back_end/parser_generator/sequence_generator_spec.rbc +0 -5453
- data/spec/rattler/back_end/parser_generator/skip_generator_spec.rbc +0 -4691
- data/spec/rattler/back_end/parser_generator/token_generator_spec.rbc +0 -4691
- data/spec/rattler/back_end/parser_generator/zero_or_more_generator_spec.rb +0 -244
- data/spec/rattler/back_end/parser_generator/zero_or_more_generator_spec.rbc +0 -4924
- data/spec/rattler/back_end/ruby_generator_spec.rbc +0 -2460
- data/spec/rattler/back_end/shared_compiler_examples.rbc +0 -41886
- data/spec/rattler/grammar/analysis_spec.rbc +0 -4365
- data/spec/rattler/grammar/grammar_parser_spec.rbc +0 -10344
- data/spec/rattler/grammar/grammar_spec.rbc +0 -1701
- data/spec/rattler/parsers/action_code_spec.rbc +0 -4674
- data/spec/rattler/parsers/apply_spec.rbc +0 -851
- data/spec/rattler/parsers/assert_spec.rbc +0 -752
- data/spec/rattler/parsers/back_reference_spec.rbc +0 -1002
- data/spec/rattler/parsers/choice_spec.rbc +0 -1696
- data/spec/rattler/parsers/combinator_parser_spec.rbc +0 -361
- data/spec/rattler/parsers/direct_action_spec.rbc +0 -5222
- data/spec/rattler/parsers/disallow_spec.rbc +0 -752
- data/spec/rattler/parsers/dispatch_action_spec.rbc +0 -3033
- data/spec/rattler/parsers/eof_spec.rbc +0 -728
- data/spec/rattler/parsers/fail_spec.rbc +0 -548
- data/spec/rattler/parsers/label_spec.rbc +0 -1091
- data/spec/rattler/parsers/list0_spec.rb +0 -82
- data/spec/rattler/parsers/list0_spec.rbc +0 -2308
- data/spec/rattler/parsers/list1_spec.rb +0 -82
- data/spec/rattler/parsers/list1_spec.rbc +0 -2287
- data/spec/rattler/parsers/list_spec.rbc +0 -2308
- data/spec/rattler/parsers/match_spec.rbc +0 -780
- data/spec/rattler/parsers/node_code_spec.rbc +0 -1754
- data/spec/rattler/parsers/one_or_more_spec.rb +0 -64
- data/spec/rattler/parsers/one_or_more_spec.rbc +0 -1698
- data/spec/rattler/parsers/optional_spec.rb +0 -64
- data/spec/rattler/parsers/optional_spec.rbc +0 -1717
- data/spec/rattler/parsers/parser_dsl_spec.rbc +0 -10150
- data/spec/rattler/parsers/rule_set_spec.rbc +0 -1060
- data/spec/rattler/parsers/sequence_spec.rbc +0 -2899
- data/spec/rattler/parsers/skip_spec.rbc +0 -753
- data/spec/rattler/parsers/token_spec.rbc +0 -1511
- data/spec/rattler/parsers/zero_or_more_spec.rb +0 -64
- data/spec/rattler/parsers/zero_or_more_spec.rbc +0 -1719
- data/spec/rattler/runtime/extended_packrat_parser_spec.rbc +0 -1341
- data/spec/rattler/runtime/packrat_parser_spec.rbc +0 -210
- data/spec/rattler/runtime/parse_failure_spec.rbc +0 -2244
- data/spec/rattler/runtime/parse_node_spec.rbc +0 -2008
- data/spec/rattler/runtime/parser_spec.rbc +0 -2757
- data/spec/rattler/runtime/recursive_descent_parser_spec.rbc +0 -210
- data/spec/rattler/runtime/shared_parser_examples.rbc +0 -2567
- data/spec/rattler/util/graphviz/node_builder_spec.rbc +0 -3439
- data/spec/rattler/util/line_counter_spec.rbc +0 -2272
- data/spec/rattler/util/node_spec.rbc +0 -15023
- data/spec/rattler_spec.rbc +0 -1591
- data/spec/spec_helper.rbc +0 -336
- data/spec/support/combinator_parser_spec_helper.rbc +0 -1284
- data/spec/support/compiler_spec_helper.rbc +0 -1941
- data/spec/support/parser_generator_spec_helper.rbc +0 -718
- data/spec/support/runtime_parser_spec_helper.rbc +0 -313
data/lib/rattler/parsers.rb
CHANGED
@@ -22,18 +22,18 @@ module Rattler
|
|
22
22
|
autoload :Match, 'rattler/parsers/match'
|
23
23
|
autoload :Choice, 'rattler/parsers/choice'
|
24
24
|
autoload :Sequence, 'rattler/parsers/sequence'
|
25
|
-
autoload :
|
26
|
-
autoload :ZeroOrMore, 'rattler/parsers/zero_or_more'
|
27
|
-
autoload :OneOrMore, 'rattler/parsers/one_or_more'
|
25
|
+
autoload :Repeat, 'rattler/parsers/repeat'
|
28
26
|
autoload :ListParser, 'rattler/parsers/list_parser'
|
29
|
-
autoload :List0, 'rattler/parsers/list0'
|
30
|
-
autoload :List1, 'rattler/parsers/list1'
|
31
27
|
autoload :Apply, 'rattler/parsers/apply'
|
32
28
|
autoload :Assert, 'rattler/parsers/assert'
|
33
29
|
autoload :Disallow, 'rattler/parsers/disallow'
|
34
30
|
autoload :Eof, 'rattler/parsers/eof'
|
31
|
+
autoload :ESymbol, 'rattler/parsers/e_symbol'
|
35
32
|
autoload :DispatchAction, 'rattler/parsers/dispatch_action'
|
36
33
|
autoload :DirectAction, 'rattler/parsers/direct_action'
|
34
|
+
autoload :SemanticAssert, 'rattler/parsers/semantic_assert'
|
35
|
+
autoload :SemanticDisallow, 'rattler/parsers/semantic_disallow'
|
36
|
+
autoload :SideEffect, 'rattler/parsers/side_effect'
|
37
37
|
autoload :Token, 'rattler/parsers/token'
|
38
38
|
autoload :Skip, 'rattler/parsers/skip'
|
39
39
|
autoload :Label, 'rattler/parsers/label'
|
@@ -41,9 +41,13 @@ module Rattler
|
|
41
41
|
autoload :Fail, 'rattler/parsers/fail'
|
42
42
|
autoload :ParserDSL, 'rattler/parsers/parser_dsl'
|
43
43
|
autoload :Predicate, 'rattler/parsers/predicate'
|
44
|
+
autoload :Atomic, 'rattler/parsers/atomic'
|
44
45
|
autoload :Combining, 'rattler/parsers/combining'
|
45
46
|
autoload :MatchJoining, 'rattler/parsers/match_joining'
|
46
47
|
autoload :ActionCode, 'rattler/parsers/action_code'
|
48
|
+
autoload :EffectCode, 'rattler/parsers/effect_code'
|
49
|
+
autoload :AssertCode, 'rattler/parsers/assert_code'
|
50
|
+
autoload :DisallowCode, 'rattler/parsers/disallow_code'
|
47
51
|
autoload :NodeCode, 'rattler/parsers/node_code'
|
48
52
|
|
49
53
|
class <<self
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# = rattler/parsers/assert_code.rb
|
3
|
+
#
|
4
|
+
# Author:: Jason Arhart
|
5
|
+
# Documentation:: Author
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rattler/parsers'
|
9
|
+
|
10
|
+
module Rattler::Parsers
|
11
|
+
# @private
|
12
|
+
class AssertCode < ActionCode #:nodoc:
|
13
|
+
|
14
|
+
def bind(scope, bind_args)
|
15
|
+
"(#{super}) && #{result_code bind_args}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def result_code(bind_args)
|
21
|
+
if bind_args.size > 1
|
22
|
+
'[' + bind_args.join(', ') + ']'
|
23
|
+
elsif bind_args.size == 1
|
24
|
+
bind_args.first
|
25
|
+
else
|
26
|
+
'true'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# = rattler/parsers/atomic.rb
|
3
|
+
#
|
4
|
+
# Author:: Jason Arhart
|
5
|
+
# Documentation:: Author
|
6
|
+
#
|
7
|
+
|
8
|
+
module Rattler::Parsers
|
9
|
+
# @private
|
10
|
+
module Atomic #:nodoc:
|
11
|
+
|
12
|
+
# @param (see Parser#with_ws)
|
13
|
+
# @return (see Parser#with_ws)
|
14
|
+
def with_ws(ws)
|
15
|
+
ws.skip & self
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -18,12 +18,14 @@ module Rattler::Parsers
|
|
18
18
|
include Combining
|
19
19
|
|
20
20
|
def self.[](child, code)
|
21
|
-
self.new(child, :code => code)
|
21
|
+
self.new(child, :code => code.strip)
|
22
22
|
end
|
23
23
|
|
24
24
|
# @private
|
25
25
|
def self.parsed(results, *_) #:nodoc:
|
26
|
-
|
26
|
+
optional_expr, code = results
|
27
|
+
expr = optional_expr.first || ESymbol[]
|
28
|
+
self[expr, code]
|
27
29
|
end
|
28
30
|
|
29
31
|
# If the wrapped parser matches at the parse position, return the result
|
@@ -35,7 +37,7 @@ module Rattler::Parsers
|
|
35
37
|
# the parse failed.
|
36
38
|
def parse(scanner, rules, scope = {})
|
37
39
|
if result = parse_child(child, scanner, rules, scope) {|_| scope = _ }
|
38
|
-
if not capturing?
|
40
|
+
if not child.capturing?
|
39
41
|
apply([])
|
40
42
|
elsif result.respond_to?(:to_ary)
|
41
43
|
apply(result, scope)
|
@@ -46,13 +48,19 @@ module Rattler::Parsers
|
|
46
48
|
end
|
47
49
|
|
48
50
|
def bindable_code
|
49
|
-
@bindable_code ||=
|
51
|
+
@bindable_code ||= create_bindable_code
|
50
52
|
end
|
51
53
|
|
52
54
|
def bind(scope, bind_args)
|
53
55
|
bindable_code.bind(scope, bind_args)
|
54
56
|
end
|
55
57
|
|
58
|
+
protected
|
59
|
+
|
60
|
+
def create_bindable_code
|
61
|
+
ActionCode.new(code)
|
62
|
+
end
|
63
|
+
|
56
64
|
private
|
57
65
|
|
58
66
|
def parse_child(child, scanner, rules, scope)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# = rattler/parsers/disallow_code.rb
|
3
|
+
#
|
4
|
+
# Author:: Jason Arhart
|
5
|
+
# Documentation:: Author
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rattler/parsers'
|
9
|
+
|
10
|
+
module Rattler::Parsers
|
11
|
+
# @private
|
12
|
+
class DisallowCode < ActionCode #:nodoc:
|
13
|
+
|
14
|
+
def bind(scope, bind_args)
|
15
|
+
"!(#{super}) && #{result_code bind_args}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def result_code(bind_args)
|
21
|
+
if bind_args.size > 1
|
22
|
+
'[' + bind_args.join(', ') + ']'
|
23
|
+
elsif bind_args.size == 1
|
24
|
+
bind_args.first
|
25
|
+
else
|
26
|
+
'true'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -25,8 +25,9 @@ module Rattler::Parsers
|
|
25
25
|
|
26
26
|
# @private
|
27
27
|
def self.parsed(results, *_) #:nodoc:
|
28
|
-
|
29
|
-
|
28
|
+
optional_expr, optional_attribute, optional_name = results
|
29
|
+
expr = optional_expr.first || ESymbol[]
|
30
|
+
a = self[expr, optional_attribute.first || @@node_defaults[:target]]
|
30
31
|
unless optional_name.empty?
|
31
32
|
a.with_attrs(:target_attrs => {:name => eval(optional_name.first, TOPLEVEL_BINDING)})
|
32
33
|
else
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# = rattler/parsers/e_symbol.rb
|
3
|
+
#
|
4
|
+
# Author:: Jason Arhart
|
5
|
+
# Documentation:: Author
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rattler/parsers'
|
9
|
+
require 'singleton'
|
10
|
+
|
11
|
+
module Rattler::Parsers
|
12
|
+
#
|
13
|
+
# +ESymbol+ always succeeds without advancing.
|
14
|
+
#
|
15
|
+
# @author Jason Arhart
|
16
|
+
#
|
17
|
+
class ESymbol < Parser
|
18
|
+
include Atomic
|
19
|
+
include Singleton
|
20
|
+
|
21
|
+
# Return the singleton instance of +ESymbol+
|
22
|
+
#
|
23
|
+
# @return [ESymbol] the singleton instance
|
24
|
+
def self.[]()
|
25
|
+
self.instance
|
26
|
+
end
|
27
|
+
|
28
|
+
# @private
|
29
|
+
def self.parsed(*_) #:nodoc:
|
30
|
+
self.instance
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return +true+ without advancing
|
34
|
+
#
|
35
|
+
# @param (see Parser#parse)
|
36
|
+
#
|
37
|
+
# @return true
|
38
|
+
def parse(scanner, rules, scope = {})
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def capturing?
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# = rattler/parsers/effect_code.rb
|
3
|
+
#
|
4
|
+
# Author:: Jason Arhart
|
5
|
+
# Documentation:: Author
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rattler/parsers'
|
9
|
+
|
10
|
+
module Rattler::Parsers
|
11
|
+
# @private
|
12
|
+
class EffectCode < ActionCode #:nodoc:
|
13
|
+
|
14
|
+
def bind(scope, bind_args)
|
15
|
+
"#{super}; #{result_code bind_args}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def result_code(bind_args)
|
21
|
+
if bind_args.size > 1
|
22
|
+
'[' + bind_args.join(', ') + ']'
|
23
|
+
elsif bind_args.size == 1
|
24
|
+
bind_args.first
|
25
|
+
else
|
26
|
+
'true'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/rattler/parsers/eof.rb
CHANGED
@@ -15,36 +15,29 @@ module Rattler::Parsers
|
|
15
15
|
# @author Jason Arhart
|
16
16
|
#
|
17
17
|
class Eof < Predicate
|
18
|
+
include Atomic
|
18
19
|
include Singleton
|
19
|
-
|
20
|
+
|
20
21
|
# Return the singleton instance of +Eof+
|
21
22
|
#
|
22
23
|
# @return [Eof] the singleton instance
|
23
24
|
def self.[]()
|
24
25
|
self.instance
|
25
26
|
end
|
26
|
-
|
27
|
+
|
27
28
|
# @private
|
28
29
|
def self.parsed(*_) #:nodoc:
|
29
30
|
self.instance
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
# Return +true+ if there is no more input to parse
|
33
34
|
#
|
34
35
|
# @param (see Parser#parse_labeled)
|
35
36
|
#
|
36
37
|
# @return true if there is no more input to parse
|
37
|
-
def parse(scanner, rules,
|
38
|
+
def parse(scanner, rules, scope = {})
|
38
39
|
scanner.eos?
|
39
40
|
end
|
40
|
-
|
41
|
-
# Return a new parser that uses +ws+ to skip whitespace before matching.
|
42
|
-
#
|
43
|
-
# @param (see Parser#with_ws)
|
44
|
-
# @return (see Parser#with_ws)
|
45
|
-
def with_ws(ws)
|
46
|
-
Skip[ws] & self
|
47
|
-
end
|
48
|
-
|
41
|
+
|
49
42
|
end
|
50
43
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# = rattler/parsers/
|
2
|
+
# = rattler/parsers/list_parser.rb
|
3
3
|
#
|
4
4
|
# Author:: Jason Arhart
|
5
5
|
# Documentation:: Author
|
@@ -10,7 +10,9 @@ require 'rattler/parsers'
|
|
10
10
|
module Rattler::Parsers
|
11
11
|
#
|
12
12
|
# +ListParser+ matches terms matched by a term parser in a list with
|
13
|
-
# separators matched by a separator parser.
|
13
|
+
# separators matched by a separator parser. +ListParser+ fails unless at
|
14
|
+
# least <tt>#lower_bound</tt> terms are matched and stops matching at
|
15
|
+
# <tt>#upper_bound</tt>.
|
14
16
|
#
|
15
17
|
# @author Jason Arhart
|
16
18
|
#
|
@@ -19,13 +21,13 @@ module Rattler::Parsers
|
|
19
21
|
|
20
22
|
# @private
|
21
23
|
def self.parsed(results, *_) #:nodoc:
|
22
|
-
|
24
|
+
term_parser, bounds, sep_parser = results
|
25
|
+
self[term_parser, sep_parser, *bounds]
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
self.new(term_parser, sep_parser.skip)
|
28
|
+
def self.[](term_parser, sep_parser, lower_bound, upper_bound)
|
29
|
+
self.new(term_parser, sep_parser.skip,
|
30
|
+
:lower_bound => lower_bound, :upper_bound => upper_bound)
|
29
31
|
end
|
30
32
|
|
31
33
|
def term_parser
|
@@ -38,22 +40,39 @@ module Rattler::Parsers
|
|
38
40
|
|
39
41
|
# Parse terms matched by the term parser in a list with separators matched
|
40
42
|
# by the separator parser. Return the terms in an array, or +true+ if the
|
41
|
-
# term parser is not <tt>capturing?</tt>.
|
43
|
+
# term parser is not <tt>capturing?</tt>. Fails returning false unless at
|
44
|
+
# least <tt>#lower_bound</tt> terms are matched and stops matching at
|
45
|
+
# <tt>#upper_bound</tt>.
|
42
46
|
#
|
43
47
|
# @param (see Parser#parse_labeled)
|
44
48
|
#
|
45
|
-
# @return [Array,
|
46
|
-
# or +true+ if the term parser is not <tt>capturing?</tt>
|
49
|
+
# @return [Array, Boolean] an array containing the term parser's parse
|
50
|
+
# results, or +true+ if the term parser is not <tt>capturing?</tt> or
|
51
|
+
# +false+ if the parse fails.
|
47
52
|
def parse(scanner, rules, scope = {})
|
48
53
|
a = []
|
49
|
-
p = scanner.pos
|
50
|
-
while result = term_parser.parse(scanner, rules, scope)
|
54
|
+
p = start_pos = scanner.pos
|
55
|
+
while result = term_parser.parse(scanner, rules, scope) and
|
56
|
+
(!upper_bound or a.size < upper_bound)
|
51
57
|
p = scanner.pos
|
52
58
|
a << result
|
53
59
|
break unless sep_parser.parse(scanner, rules, scope)
|
54
60
|
end
|
55
|
-
|
56
|
-
|
61
|
+
if a.size >= lower_bound
|
62
|
+
scanner.pos = p
|
63
|
+
capturing? ? a : true
|
64
|
+
else
|
65
|
+
scanner.pos = start_pos
|
66
|
+
false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def lower_bound?
|
71
|
+
lower_bound > 0
|
72
|
+
end
|
73
|
+
|
74
|
+
def upper_bound?
|
75
|
+
not upper_bound.nil?
|
57
76
|
end
|
58
77
|
|
59
78
|
def variable_capture_count?
|
@@ -16,6 +16,7 @@ module Rattler::Parsers
|
|
16
16
|
# @author Jason Arhart
|
17
17
|
#
|
18
18
|
class Match < Parser
|
19
|
+
include Atomic
|
19
20
|
|
20
21
|
# Create a new parser that matches with +re+.
|
21
22
|
#
|
@@ -42,11 +43,5 @@ module Rattler::Parsers
|
|
42
43
|
scanner.scan re
|
43
44
|
end
|
44
45
|
|
45
|
-
# @param (see Parser#with_ws)
|
46
|
-
# @return (see Parser#with_ws)
|
47
|
-
def with_ws(ws)
|
48
|
-
ws.skip & self
|
49
|
-
end
|
50
|
-
|
51
46
|
end
|
52
47
|
end
|
@@ -66,7 +66,7 @@ module Rattler
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# Create a new parser to match a pattern, literal, referenced parse rule,
|
69
|
-
# posix character class, or
|
69
|
+
# posix character class, EOF, or E.
|
70
70
|
#
|
71
71
|
# @overload match(pattern)
|
72
72
|
# @param [Regexp] pattern the pattern to match
|
@@ -88,10 +88,15 @@ module Rattler
|
|
88
88
|
# @param :EOF
|
89
89
|
# @return [Eof] the {Eof} singleton
|
90
90
|
#
|
91
|
+
# @overload match(:E)
|
92
|
+
# @param :E
|
93
|
+
# @return [ESymbol] the {ESymbol} singleton
|
94
|
+
#
|
91
95
|
def match(arg)
|
92
96
|
case arg
|
93
97
|
when Regexp then Match[arg]
|
94
98
|
when :EOF then eof
|
99
|
+
when :E then e
|
95
100
|
when :ALNUM then match /[[:alnum:]]/
|
96
101
|
when :ALPHA then match /[[:alpha:]]/
|
97
102
|
when :BLANK then match /[[:blank:]]/
|
@@ -113,25 +118,25 @@ module Rattler
|
|
113
118
|
# Create a new optional parser.
|
114
119
|
#
|
115
120
|
# @overload optional(parser)
|
116
|
-
# @return [
|
121
|
+
# @return [Repeat] a new optional parser
|
117
122
|
# @overload optional(arg)
|
118
|
-
# @return [
|
123
|
+
# @return [Repeat] a new optional parser using arg to define a match
|
119
124
|
# parser
|
120
125
|
# @see #match
|
121
126
|
def optional(arg)
|
122
|
-
|
127
|
+
Repeat[to_parser(arg), 0, 1]
|
123
128
|
end
|
124
129
|
|
125
130
|
# Create a new zero-or-more parser.
|
126
131
|
#
|
127
132
|
# @overload zero_or_more(parser)
|
128
|
-
# @return [
|
133
|
+
# @return [Repeat] a new zero-or-more parser
|
129
134
|
# @overload zero_or_more(arg)
|
130
|
-
# @return [
|
135
|
+
# @return [Repeat] a new zero-or-more parser using arg to define a
|
131
136
|
# match parser
|
132
137
|
# @see #match
|
133
138
|
def zero_or_more(arg)
|
134
|
-
|
139
|
+
Repeat[to_parser(arg), 0, nil]
|
135
140
|
end
|
136
141
|
|
137
142
|
alias_method :any, :zero_or_more
|
@@ -139,39 +144,38 @@ module Rattler
|
|
139
144
|
# Create a new one-or-more parser.
|
140
145
|
#
|
141
146
|
# @overload one_or_more(parser)
|
142
|
-
# @return [
|
147
|
+
# @return [Repeat] a new one-or-more parser
|
143
148
|
# @overload one_or_more(arg)
|
144
|
-
# @return [
|
145
|
-
#
|
149
|
+
# @return [Repeat] a new one-or-more parser using arg to define a match
|
150
|
+
# parser
|
146
151
|
# @see #match
|
147
152
|
def one_or_more(arg)
|
148
|
-
|
153
|
+
Repeat[to_parser(arg), 1, nil]
|
149
154
|
end
|
150
155
|
|
151
156
|
alias_method :some, :one_or_more
|
152
157
|
|
153
|
-
# Create a
|
158
|
+
# Create a generalized repeat parser.
|
154
159
|
#
|
155
|
-
# @overload
|
156
|
-
# @return [
|
157
|
-
# @overload
|
158
|
-
# @return [
|
160
|
+
# @overload one_or_more(parser, min, max)
|
161
|
+
# @return [Repeat] a new repeat parser with the given bounds
|
162
|
+
# @overload one_or_more(arg, min, max)
|
163
|
+
# @return [Repeat] a new repeat parser using arg to define a match
|
164
|
+
# parser
|
159
165
|
# @see #match
|
160
|
-
def
|
161
|
-
|
166
|
+
def repeat(arg, min, max)
|
167
|
+
Repeat[to_parser(arg), min, max]
|
162
168
|
end
|
163
169
|
|
164
|
-
|
165
|
-
|
166
|
-
# Create a new list1 parser.
|
170
|
+
# Create a new list parser.
|
167
171
|
#
|
168
|
-
# @overload list(term_parser, sep_parser)
|
169
|
-
# @return [
|
170
|
-
# @overload list(term_arg, sep_arg)
|
171
|
-
# @return [
|
172
|
+
# @overload list(term_parser, sep_parser, min, max)
|
173
|
+
# @return [ListParser] a new list parser
|
174
|
+
# @overload list(term_arg, sep_arg, min, max)
|
175
|
+
# @return [ListParser] a new list parser using args to define a match parsers
|
172
176
|
# @see #match
|
173
|
-
def
|
174
|
-
|
177
|
+
def list(term_arg, sep_arg, min, max)
|
178
|
+
ListParser[to_parser(term_arg), to_parser(sep_arg), min, max]
|
175
179
|
end
|
176
180
|
|
177
181
|
# Create a new assert parser.
|
@@ -203,32 +207,71 @@ module Rattler
|
|
203
207
|
Eof[]
|
204
208
|
end
|
205
209
|
|
206
|
-
#
|
210
|
+
# @return the "E" symbol parser
|
211
|
+
def e
|
212
|
+
ESymbol[]
|
213
|
+
end
|
214
|
+
|
215
|
+
# Create a new semantic action that dispatches to a method.
|
207
216
|
#
|
208
217
|
# @overload dispatch_action(parser)
|
209
|
-
# @return [DispatchAction] a new
|
218
|
+
# @return [DispatchAction] a new semantic action
|
210
219
|
# @overload dispatch_action(arg)
|
211
|
-
# @return [DispatchAction] a new
|
220
|
+
# @return [DispatchAction] a new semantic action using arg to define a
|
212
221
|
# match parser
|
213
222
|
# @see #match
|
214
223
|
def dispatch_action(arg, attrs={})
|
215
224
|
DispatchAction[to_parser(arg), attrs]
|
216
225
|
end
|
217
226
|
|
218
|
-
#
|
219
|
-
|
220
|
-
# Create a new symantic action that evaluates ruby code.
|
227
|
+
# Create a new semantic action that evaluates ruby code.
|
221
228
|
#
|
222
229
|
# @overload direct_action(parser, code)
|
223
|
-
# @return [DirectAction] a new
|
230
|
+
# @return [DirectAction] a new semantic action
|
224
231
|
# @overload direct_action(arg, code)
|
225
|
-
# @return [DirectAction] a new
|
232
|
+
# @return [DirectAction] a new semantic action using arg to define a
|
226
233
|
# match parser
|
227
234
|
# @see #match
|
228
235
|
def direct_action(arg, code)
|
229
236
|
DirectAction[to_parser(arg), code]
|
230
237
|
end
|
231
238
|
|
239
|
+
# Create a new semantic action that evaluates ruby code for effect.
|
240
|
+
#
|
241
|
+
# @overload side_effect(parser, code)
|
242
|
+
# @return [SideEffect] a new semantic action
|
243
|
+
# @overload side_effect(arg, code)
|
244
|
+
# @return [SideEffect] a new semantic action using arg to define a
|
245
|
+
# match parser
|
246
|
+
# @see #match
|
247
|
+
def side_effect(arg, code)
|
248
|
+
SideEffect[to_parser(arg), code]
|
249
|
+
end
|
250
|
+
|
251
|
+
# Create a new positive semantic predicate.
|
252
|
+
#
|
253
|
+
# @overload semantic_assert(parser, code)
|
254
|
+
# @return [SemanticAssert] a new positive Semantic predicate
|
255
|
+
# @overload semantic_assert(arg, code)
|
256
|
+
# @return [SemanticAssert] a new positive Semantic predicate using arg
|
257
|
+
# to define a match parser
|
258
|
+
# @see #match
|
259
|
+
def semantic_assert(arg, code)
|
260
|
+
SemanticAssert[to_parser(arg), code]
|
261
|
+
end
|
262
|
+
|
263
|
+
# Create a new negative semantic predicate.
|
264
|
+
#
|
265
|
+
# @overload semantic_disallow(parser, code)
|
266
|
+
# @return [SemanticDisallow] a new negative Semantic predicate
|
267
|
+
# @overload semantic_disallow(arg, code)
|
268
|
+
# @return [SemanticDisallow] a new negative Semantic predicate using
|
269
|
+
# arg to define a match parser
|
270
|
+
# @see #match
|
271
|
+
def semantic_disallow(arg, code)
|
272
|
+
SemanticDisallow[to_parser(arg), code]
|
273
|
+
end
|
274
|
+
|
232
275
|
# Create a new token parser or token rule.
|
233
276
|
#
|
234
277
|
# @overload token(rule_name, &block)
|