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
@@ -3,10 +3,6 @@ Feature: One-Or-More
|
|
3
3
|
The "+" operator following an expression means to match one or more times,
|
4
4
|
i.e. match repeatedly and succeed if input was matched at least once.
|
5
5
|
|
6
|
-
In order to define an expression that matches one or more times
|
7
|
-
As a language designer
|
8
|
-
I want to use a "one-or-more" postfix operator in my grammar
|
9
|
-
|
10
6
|
Scenario Outline: Capturing Expression
|
11
7
|
Given a grammar with:
|
12
8
|
"""
|
@@ -3,10 +3,6 @@ Feature: Optional Operator
|
|
3
3
|
The "?" operator following an expression makes the it optional, meaning it
|
4
4
|
succeeds even if no input is matched.
|
5
5
|
|
6
|
-
In order to define an expression that matches optionally
|
7
|
-
As a language designer
|
8
|
-
I want to use an "optional" postfix operator in my grammar
|
9
|
-
|
10
6
|
Scenario Outline: Capturing Expression
|
11
7
|
Given a grammar with:
|
12
8
|
"""
|
@@ -4,10 +4,6 @@ Feature: Ordered Choice Expressions
|
|
4
4
|
and it means to try each sub-expression in order until one matches, and fail
|
5
5
|
if none of the sub-expressions match.
|
6
6
|
|
7
|
-
In order to define multiple alternatives for an expression
|
8
|
-
As a language designer
|
9
|
-
I want to use ordered choice expressions in my grammar
|
10
|
-
|
11
7
|
Scenario Outline: Parsing
|
12
8
|
Given a grammar with:
|
13
9
|
"""
|
@@ -4,10 +4,6 @@ Feature: Positive Lookahead Operator
|
|
4
4
|
would match here but never consume any input. This is known as zero-width
|
5
5
|
positive lookahead.
|
6
6
|
|
7
|
-
In order to define zero-width positive lookahead expressions
|
8
|
-
As a language designer
|
9
|
-
I want to use the positive lookahead operator in my grammar
|
10
|
-
|
11
7
|
Scenario Outline: Parsing
|
12
8
|
Given a grammar with:
|
13
9
|
"""
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Feature: Positive Semantic Predicates
|
2
|
+
|
3
|
+
A positive semantic predicate can be defined by placing a "&" in front of a
|
4
|
+
semantic action. If the action results in a true value the parse succeeds,
|
5
|
+
otherwise the parse fails.
|
6
|
+
|
7
|
+
Scenario Outline: Single token
|
8
|
+
Given a grammar with:
|
9
|
+
"""
|
10
|
+
expr <- @DIGIT+ &{|s| s.to_i > 20 }
|
11
|
+
"""
|
12
|
+
When I parse <input>
|
13
|
+
Then the parse result should be <result>
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
| input | result |
|
17
|
+
| "42" | "42" |
|
18
|
+
| "17" | FAIL |
|
19
|
+
|
20
|
+
Scenario Outline: Sequence
|
21
|
+
Given a grammar with:
|
22
|
+
"""
|
23
|
+
%whitespace SPACE*
|
24
|
+
expr <- @DIGIT+ @DIGIT+ &{|a,b| a.to_i < b.to_i }
|
25
|
+
"""
|
26
|
+
When I parse <input>
|
27
|
+
Then the parse result should be <result>
|
28
|
+
|
29
|
+
Examples:
|
30
|
+
| input | result |
|
31
|
+
| "3 16" | ["3", "16"] |
|
32
|
+
| "16 3" | FAIL |
|
33
|
+
|
34
|
+
Scenario Outline: Sequence with non-capturing expressions
|
35
|
+
Given a grammar with:
|
36
|
+
"""
|
37
|
+
expr <- ~"(" @DIGIT+ ~">" @DIGIT+ ~")" &{|a,b| a.to_i > b.to_i }
|
38
|
+
"""
|
39
|
+
When I parse <input>
|
40
|
+
Then the parse result should be <result>
|
41
|
+
|
42
|
+
Examples:
|
43
|
+
| input | result |
|
44
|
+
| "(23>17)" | ["23", "17"] |
|
45
|
+
| "(17>23)" | FAIL |
|
46
|
+
|
47
|
+
Scenario Outline: Sequence with labeled expressions
|
48
|
+
Given a grammar with:
|
49
|
+
"""
|
50
|
+
expr <- "(" left:@DIGIT+ "<" right:@DIGIT+ ")" &{ left.to_i < right.to_i }
|
51
|
+
"""
|
52
|
+
When I parse <input>
|
53
|
+
Then the parse result should be <result>
|
54
|
+
|
55
|
+
Examples:
|
56
|
+
| input | result |
|
57
|
+
| "(17<23)" | ["(", "17", "<", "23", ")"] |
|
58
|
+
| "(23<17)" | FAIL |
|
59
|
+
|
60
|
+
Scenario Outline: Single token using "_"
|
61
|
+
Given a grammar with:
|
62
|
+
"""
|
63
|
+
expr <- @DIGIT+ &{ _.to_i > 20 }
|
64
|
+
"""
|
65
|
+
When I parse <input>
|
66
|
+
Then the parse result should be <result>
|
67
|
+
|
68
|
+
Examples:
|
69
|
+
| input | result |
|
70
|
+
| "42" | "42" |
|
71
|
+
| "17" | FAIL |
|
72
|
+
|
73
|
+
Scenario Outline: Sequence using "_"
|
74
|
+
Given a grammar with:
|
75
|
+
"""
|
76
|
+
%whitespace SPACE*
|
77
|
+
expr <- @DIGIT+ @DIGIT+ &{ _[0].to_i < _[1].to_i }
|
78
|
+
"""
|
79
|
+
When I parse <input>
|
80
|
+
Then the parse result should be <result>
|
81
|
+
|
82
|
+
Examples:
|
83
|
+
| input | result |
|
84
|
+
| "3 16" | ["3", "16"] |
|
85
|
+
| "16 3" | FAIL |
|
86
|
+
|
87
|
+
Scenario Outline: Sequence using "_" as a parameter name
|
88
|
+
Given a grammar with:
|
89
|
+
"""
|
90
|
+
%whitespace SPACE*
|
91
|
+
expr <- @DIGIT+ @DIGIT+ &{|_| _.to_i < 20 }
|
92
|
+
"""
|
93
|
+
When I parse <input>
|
94
|
+
Then the parse result should be <result>
|
95
|
+
|
96
|
+
Examples:
|
97
|
+
| input | result |
|
98
|
+
| "3 16" | ["3", "16"] |
|
99
|
+
| "42 7" | FAIL |
|
@@ -18,11 +18,7 @@ Feature: POSIX Character Classes
|
|
18
18
|
SPACE - Whitespace characters
|
19
19
|
UPPER - Uppercase characters
|
20
20
|
XDIGIT - Hexadecimal digits
|
21
|
-
WORD - Alphanumeric characters plus "_"
|
22
|
-
|
23
|
-
In order to write more consistent and readable grammars
|
24
|
-
As a language designer
|
25
|
-
I want to use POSIX character classes in my grammar
|
21
|
+
WORD - Alphanumeric characters plus "_"
|
26
22
|
|
27
23
|
Scenario: ALNUM
|
28
24
|
Given a grammar with:
|
@@ -70,4 +66,5 @@ Feature: POSIX Character Classes
|
|
70
66
|
expr <- UPPER+
|
71
67
|
"""
|
72
68
|
When I parse "ABCdef"
|
73
|
-
Then the parse result should be ["A", "B", "C"]
|
69
|
+
Then the parse result should be ["A", "B", "C"]
|
70
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Feature: Generalized Repeat
|
2
|
+
|
3
|
+
Repetition counts or ranges can be used for generalized repeat expressions.
|
4
|
+
A count by itself means to match the preceding expression exactly that many
|
5
|
+
times. A range can be written with ".." between the lower and upper bounds.
|
6
|
+
The upper bound is optional.
|
7
|
+
|
8
|
+
Scenario Outline: Range
|
9
|
+
Given a grammar with:
|
10
|
+
"""
|
11
|
+
expr <- ALPHA 2..4
|
12
|
+
"""
|
13
|
+
When I parse <input>
|
14
|
+
Then the parse result should be <result>
|
15
|
+
And the parse position should be <pos>
|
16
|
+
|
17
|
+
Examples:
|
18
|
+
| input | result | pos |
|
19
|
+
| "abc" | ["a", "b", "c"] | 3 |
|
20
|
+
| "abcde" | ["a", "b", "c", "d"] | 4 |
|
21
|
+
| "a" | FAIL | 0 |
|
22
|
+
|
23
|
+
Scenario Outline: Lower bound only
|
24
|
+
Given a grammar with:
|
25
|
+
"""
|
26
|
+
expr <- ALPHA 2..
|
27
|
+
"""
|
28
|
+
When I parse <input>
|
29
|
+
Then the parse result should be <result>
|
30
|
+
And the parse position should be <pos>
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
| input | result | pos |
|
34
|
+
| "abc" | ["a", "b", "c"] | 3 |
|
35
|
+
| "abcde" | ["a", "b", "c", "d", "e"] | 5 |
|
36
|
+
| "a" | FAIL | 0 |
|
37
|
+
|
38
|
+
Scenario Outline: Specific count
|
39
|
+
Given a grammar with:
|
40
|
+
"""
|
41
|
+
expr <- ALPHA 2
|
42
|
+
"""
|
43
|
+
When I parse <input>
|
44
|
+
Then the parse result should be <result>
|
45
|
+
And the parse position should be <pos>
|
46
|
+
|
47
|
+
Examples:
|
48
|
+
| input | result | pos |
|
49
|
+
| "abc" | ["a", "b"] | 2 |
|
50
|
+
| "a" | FAIL | 0 |
|
@@ -3,10 +3,6 @@ Feature: Sequence Expressions
|
|
3
3
|
A sequence expression is a series of sub-expressions and it means to match
|
4
4
|
all of the sub-expressions in sequence, otherwise fail and consume no input.
|
5
5
|
|
6
|
-
In order to define an expression as a sequence of sub-expressions
|
7
|
-
As a language designer
|
8
|
-
I want to use sequence expressions in my grammar
|
9
|
-
|
10
6
|
Scenario Outline: Parsing
|
11
7
|
Given a grammar with:
|
12
8
|
"""
|
@@ -0,0 +1,81 @@
|
|
1
|
+
Feature: Semantic side-effects
|
2
|
+
|
3
|
+
A semantic side-effect can be defined by placing a "~" in front of a symantic
|
4
|
+
action. The expression is evaulated for effect and always succeeds with no
|
5
|
+
parse result.
|
6
|
+
|
7
|
+
Scenario: Single token
|
8
|
+
Given a grammar with:
|
9
|
+
"""
|
10
|
+
expr <- @DIGIT+ ~{|s| $x = s.to_i }
|
11
|
+
"""
|
12
|
+
When I parse "42 "
|
13
|
+
Then the parse result should be "42"
|
14
|
+
And $x should be 42
|
15
|
+
|
16
|
+
Scenario: Sequence
|
17
|
+
Given a grammar with:
|
18
|
+
"""
|
19
|
+
%whitespace SPACE*
|
20
|
+
expr <- @DIGIT+ @DIGIT+ ~{|a,b| $x = a.to_i * b.to_i }
|
21
|
+
"""
|
22
|
+
When I parse "3 16"
|
23
|
+
Then the parse result should be ["3", "16"]
|
24
|
+
And $x should be 48
|
25
|
+
|
26
|
+
Scenario: Sequence with non-capturing expressions
|
27
|
+
Given a grammar with:
|
28
|
+
"""
|
29
|
+
expr <- ~"(" @DIGIT+ ~"+" @DIGIT+ ~")" ~{|a,b| $x = a.to_i + b.to_i }
|
30
|
+
"""
|
31
|
+
When I parse "(23+17)"
|
32
|
+
Then the parse result should be ["23", "17"]
|
33
|
+
And $x should be 40
|
34
|
+
|
35
|
+
Scenario: Sequence with labeled expressions
|
36
|
+
Given a grammar with:
|
37
|
+
"""
|
38
|
+
expr <- "(" l:@DIGIT+ "+" r:@DIGIT+ ")" ~{ $x = l.to_i + r.to_i }
|
39
|
+
"""
|
40
|
+
When I parse "(17+29)"
|
41
|
+
Then the parse result should be ["(", "17", "+", "29", ")"]
|
42
|
+
And $x should be 46
|
43
|
+
|
44
|
+
Scenario: Single token using "_"
|
45
|
+
Given a grammar with:
|
46
|
+
"""
|
47
|
+
expr <- @DIGIT+ ~{ $x = _.to_i }
|
48
|
+
"""
|
49
|
+
When I parse "23"
|
50
|
+
Then the parse result should be "23"
|
51
|
+
And $x should be 23
|
52
|
+
|
53
|
+
Scenario: Sequence using "_"
|
54
|
+
Given a grammar with:
|
55
|
+
"""
|
56
|
+
%whitespace SPACE*
|
57
|
+
expr <- @DIGIT+ @DIGIT+ ~{ $x = _.reverse }
|
58
|
+
"""
|
59
|
+
When I parse "3 16"
|
60
|
+
Then the parse result should be ["3", "16"]
|
61
|
+
And $x should be ["16", "3"]
|
62
|
+
|
63
|
+
Scenario: Sequence using "_" as a parameter name
|
64
|
+
Given a grammar with:
|
65
|
+
"""
|
66
|
+
%whitespace SPACE*
|
67
|
+
expr <- @DIGIT+ @DIGIT+ ~{|_| $x = _.to_i }
|
68
|
+
"""
|
69
|
+
When I parse "3 16"
|
70
|
+
Then the parse result should be ["3", "16"]
|
71
|
+
And $x should be 3
|
72
|
+
|
73
|
+
Scenario: Lone action
|
74
|
+
Given a grammar with:
|
75
|
+
"""
|
76
|
+
expr <- ~{ $x = 42 }
|
77
|
+
"""
|
78
|
+
When I parse "anything"
|
79
|
+
Then the parse result should be true
|
80
|
+
And $x should be 42
|
81
|
+
And the parse position should be 0
|
@@ -2,10 +2,6 @@ Feature: Skip Operator
|
|
2
2
|
|
3
3
|
The "~" operator before an expression means to match but ignore the result.
|
4
4
|
|
5
|
-
In order to match syntax without it being included in the parse results
|
6
|
-
As a language designer
|
7
|
-
I want to use a "skip" prefix operator in my grammar
|
8
|
-
|
9
5
|
Scenario: Sequence with skipped sub-expressions
|
10
6
|
Given a grammar with:
|
11
7
|
"""
|
@@ -21,4 +17,5 @@ Feature: Skip Operator
|
|
21
17
|
"""
|
22
18
|
When I parse "if "
|
23
19
|
Then the parse result should be true
|
24
|
-
And the parse position should be 2
|
20
|
+
And the parse position should be 2
|
21
|
+
|
@@ -2,10 +2,6 @@ Feature: Start Rule
|
|
2
2
|
|
3
3
|
The first rule defined in a grammar is the start rule.
|
4
4
|
|
5
|
-
In order to make my grammars readable
|
6
|
-
As a language designer
|
7
|
-
I want to give my start rule a meaningful name
|
8
|
-
|
9
5
|
Scenario Outline: Default Start Rule
|
10
6
|
Given a grammar with:
|
11
7
|
"""
|
@@ -18,4 +14,4 @@ Feature: Start Rule
|
|
18
14
|
Examples:
|
19
15
|
| input | result |
|
20
16
|
| "42a" | "42" |
|
21
|
-
| "foo" | FAIL |
|
17
|
+
| "foo" | FAIL |
|
@@ -8,10 +8,6 @@ Feature: Symantic Actions
|
|
8
8
|
are simply ignored. Labeled parse results can be refered to as identifiers in
|
9
9
|
the action. The special identifier "_" refers to the entire parse results.
|
10
10
|
|
11
|
-
In order to add simple symantics to parse results
|
12
|
-
As a language designer
|
13
|
-
I want to use symantic actions in my grammar
|
14
|
-
|
15
11
|
Scenario: Single token
|
16
12
|
Given a grammar with:
|
17
13
|
"""
|
@@ -70,3 +66,12 @@ Feature: Symantic Actions
|
|
70
66
|
"""
|
71
67
|
When I parse "3 16"
|
72
68
|
Then the parse result should be 3
|
69
|
+
|
70
|
+
Scenario: Lone action
|
71
|
+
Given a grammar with:
|
72
|
+
"""
|
73
|
+
default <- { 42 }
|
74
|
+
"""
|
75
|
+
When I parse "anything"
|
76
|
+
Then the parse result should be 42
|
77
|
+
And the parse position should be 0
|
@@ -5,10 +5,6 @@ Feature: Token Operator
|
|
5
5
|
automatically skipped. The expression becomes atomic, so any defined
|
6
6
|
whitespace will be automatically skipped before the token.
|
7
7
|
|
8
|
-
In order to match arbitrarily complex expressions as tokens
|
9
|
-
As a language designer
|
10
|
-
I want to use a "token" prefix operator in my grammar
|
11
|
-
|
12
8
|
Scenario: Nested sequences and repeats
|
13
9
|
Given a grammar with:
|
14
10
|
"""
|
@@ -6,10 +6,6 @@ Feature: Whitespace
|
|
6
6
|
form defines whitespace for expressions in the block, otherwise it is defined
|
7
7
|
for the rest of the grammar.
|
8
8
|
|
9
|
-
In order to focus on the structure of my language
|
10
|
-
As a language designer
|
11
|
-
I want to specify whitespace in my grammar once and only once
|
12
|
-
|
13
9
|
Scenario: Block form
|
14
10
|
Given a grammar with:
|
15
11
|
"""
|
@@ -6,10 +6,6 @@ Feature: Word Literal Expressions
|
|
6
6
|
word character can be defined using the %word_character directive. By default
|
7
7
|
a word charactacter is an alphanumeric character or the underscore character.
|
8
8
|
|
9
|
-
In order to define keywords
|
10
|
-
As a language designer
|
11
|
-
I want to use word literals in my grammar
|
12
|
-
|
13
9
|
Scenario Outline: Default word character definition
|
14
10
|
Given a grammar with:
|
15
11
|
"""
|
@@ -3,10 +3,6 @@ Feature: Zero-Or-More
|
|
3
3
|
The "*" operator following an expression means to match zero or more times,
|
4
4
|
i.e. match repeatedly and succeed even if no input was matched.
|
5
5
|
|
6
|
-
In order to define an expression that matches zero or more times
|
7
|
-
As a language designer
|
8
|
-
I want to use a "zero-or-more" postfix operator in my grammar
|
9
|
-
|
10
6
|
Scenario Outline: Capturing Expression
|
11
7
|
Given a grammar with:
|
12
8
|
"""
|
@@ -76,6 +76,7 @@ module Rattler::BackEnd
|
|
76
76
|
autoload :OptimizationSequence, 'rattler/back_end/optimizer/optimization_sequence'
|
77
77
|
autoload :OptimizeChildren, 'rattler/back_end/optimizer/optimize_children'
|
78
78
|
autoload :InlineRegularRules, 'rattler/back_end/optimizer/inline_regular_rules'
|
79
|
+
autoload :SpecializeRepeat, 'rattler/back_end/optimizer/specialize_repeat'
|
79
80
|
autoload :SimplifyRedundantRepeat, 'rattler/back_end/optimizer/simplify_redundant_repeat'
|
80
81
|
autoload :RemoveMeaninglessWrapper, 'rattler/back_end/optimizer/remove_meaningless_wrapper'
|
81
82
|
autoload :SimplifyTokenMatch, 'rattler/back_end/optimizer/simplify_token_match'
|
@@ -20,10 +20,8 @@ module Rattler::BackEnd::Optimizer
|
|
20
20
|
|
21
21
|
def _applies_to?(parser, context)
|
22
22
|
context.matching? and
|
23
|
-
|
24
|
-
|
25
|
-
parser.child.is_a?(Match)
|
26
|
-
end
|
23
|
+
parser.is_a? Repeat and
|
24
|
+
parser.child.is_a? Match
|
27
25
|
end
|
28
26
|
|
29
27
|
def _apply(parser, context)
|
@@ -33,10 +31,24 @@ module Rattler::BackEnd::Optimizer
|
|
33
31
|
private
|
34
32
|
|
35
33
|
def suffix(parser)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
if parser.zero_or_more?
|
35
|
+
'*'
|
36
|
+
elsif parser.one_or_more?
|
37
|
+
'+'
|
38
|
+
elsif parser.optional?
|
39
|
+
'?'
|
40
|
+
else
|
41
|
+
general_suffix parser.lower_bound, parser.upper_bound
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def general_suffix(lower_bound, upper_bound)
|
46
|
+
if lower_bound == upper_bound
|
47
|
+
"{#{lower_bound}}"
|
48
|
+
elsif !upper_bound
|
49
|
+
"{#{lower_bound},}"
|
50
|
+
else
|
51
|
+
"{#{lower_bound},#{upper_bound}}"
|
40
52
|
end
|
41
53
|
end
|
42
54
|
|