rattler 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,11 +3,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
3
3
|
describe DirectAction do
|
4
4
|
include CombinatorParserSpecHelper
|
5
5
|
|
6
|
+
subject { DirectAction[nested, code] }
|
7
|
+
|
6
8
|
describe '#parse' do
|
7
9
|
|
8
10
|
context 'with a capturing parser' do
|
9
11
|
|
10
|
-
|
12
|
+
let(:nested) { Match[/[[:digit:]]+/] }
|
13
|
+
let(:code) { '|s| s * 2' }
|
11
14
|
|
12
15
|
context 'when the parser matches' do
|
13
16
|
it 'applies the action binding the captured results as arguments' do
|
@@ -23,7 +26,7 @@ describe DirectAction do
|
|
23
26
|
|
24
27
|
context 'using the "_" character' do
|
25
28
|
|
26
|
-
|
29
|
+
let(:code) { '_ * 2' }
|
27
30
|
|
28
31
|
it 'applies the action binding the captured result as "_"' do
|
29
32
|
parsing('451a').should result_in('451451').at(3)
|
@@ -32,13 +35,13 @@ describe DirectAction do
|
|
32
35
|
end
|
33
36
|
|
34
37
|
context 'with a sequence parser' do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'|l, r| "#{r} -> #{l}"'
|
39
|
-
]
|
38
|
+
|
39
|
+
let :nested do
|
40
|
+
Sequence[Match[/[[:alpha:]]+/], Skip[Match[/\=/]], Match[/[[:digit:]]+/]]
|
40
41
|
end
|
41
42
|
|
43
|
+
let(:code) { '|l, r| "#{r} -> #{l}"' }
|
44
|
+
|
42
45
|
context 'when the parser matches' do
|
43
46
|
it 'applies the action binding the captured results as arguments' do
|
44
47
|
parsing('val=42 ').should result_in('42 -> val').at(6)
|
@@ -46,12 +49,8 @@ describe DirectAction do
|
|
46
49
|
end
|
47
50
|
|
48
51
|
context 'using the "_" character' do
|
49
|
-
|
50
|
-
|
51
|
-
Sequence[Match[/[[:alpha:]]+/], Skip[Match[/\=/]], Match[/[[:digit:]]+/]],
|
52
|
-
'_.join " <- "'
|
53
|
-
]
|
54
|
-
end
|
52
|
+
|
53
|
+
let(:code) { '_.join " <- "' }
|
55
54
|
|
56
55
|
it 'applies the action binding the captured result array as "_"' do
|
57
56
|
parsing('val=42 ').should result_in('val <- 42').at(6)
|
@@ -61,11 +60,12 @@ describe DirectAction do
|
|
61
60
|
|
62
61
|
context 'with an optional parser' do
|
63
62
|
|
64
|
-
|
63
|
+
let(:nested) { Repeat[Match[/\d/], 0, 1] }
|
64
|
+
let(:code) { '|s| s' }
|
65
65
|
|
66
66
|
context 'when the nested parser matches' do
|
67
67
|
it 'applies the action to an array containing the match' do
|
68
|
-
parsing('451a').should result_in(['
|
68
|
+
parsing('451a').should result_in(['4']).at(1)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -78,11 +78,12 @@ describe DirectAction do
|
|
78
78
|
|
79
79
|
context 'with a zero-or-more parser' do
|
80
80
|
|
81
|
-
|
81
|
+
let(:nested) { Repeat[Match[/\d/], 0, nil] }
|
82
|
+
let(:code) { '|s| s * 2' }
|
82
83
|
|
83
84
|
context 'when the nested parser matches' do
|
84
85
|
it 'applies the action to an array containing the matches' do
|
85
|
-
parsing('451a').should result_in(
|
86
|
+
parsing('451a').should result_in(%w{4 5 1 4 5 1}).at(3)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -95,7 +96,8 @@ describe DirectAction do
|
|
95
96
|
|
96
97
|
context 'with a one-or-more parser' do
|
97
98
|
|
98
|
-
|
99
|
+
let(:nested) { Repeat[Match[/\d/], 1, nil] }
|
100
|
+
let(:code) { '|s| s * 2' }
|
99
101
|
|
100
102
|
context 'when the nested parser matches' do
|
101
103
|
it 'applies the action to an array containing the matches' do
|
@@ -110,8 +112,28 @@ describe DirectAction do
|
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
115
|
+
context 'with a list parser' do
|
116
|
+
|
117
|
+
let(:nested) { ListParser[Match[/[[:digit:]]+/], Match[/,/], 2, 4] }
|
118
|
+
let(:code) { '_.map {|s| s.to_i }' }
|
119
|
+
|
120
|
+
context 'when the nested parser matches' do
|
121
|
+
it 'applies the action to an array containing the matches' do
|
122
|
+
parsing('1,2,42').should result_in([1, 2, 42]).at(6)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when the nested parser fails' do
|
127
|
+
it 'fails' do
|
128
|
+
parsing('foo').should fail
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
113
133
|
context 'with a token parser' do
|
114
|
-
|
134
|
+
|
135
|
+
let(:nested) { Token[Match[/[[:digit:]]+/]] }
|
136
|
+
let(:code) { '|s| s.to_i' }
|
115
137
|
|
116
138
|
context 'when the parser matches' do
|
117
139
|
it 'applies the action to the matched string' do
|
@@ -122,7 +144,8 @@ describe DirectAction do
|
|
122
144
|
|
123
145
|
context 'with a non-capturing parser' do
|
124
146
|
|
125
|
-
|
147
|
+
let(:nested) { Skip[Match[/\w+/]] }
|
148
|
+
let(:code) { '42' }
|
126
149
|
|
127
150
|
context 'when the parser matches' do
|
128
151
|
it 'applies the action with no arguments' do
|
@@ -132,12 +155,10 @@ describe DirectAction do
|
|
132
155
|
end
|
133
156
|
|
134
157
|
context 'with a labeled parser' do
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
]
|
140
|
-
end
|
158
|
+
|
159
|
+
let(:nested) { Label[:word, Match[/[[:alpha:]]+/]] }
|
160
|
+
let(:code) { 'word * 2' }
|
161
|
+
|
141
162
|
context 'when the parser matches' do
|
142
163
|
it 'applies the action binding the label to the result' do
|
143
164
|
parsing('foo ').should result_in('foofoo').at(3)
|
@@ -146,16 +167,17 @@ describe DirectAction do
|
|
146
167
|
end
|
147
168
|
|
148
169
|
context 'with a sequence of labeled parsers' do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
],
|
156
|
-
'"#{right} -> #{left}"'
|
170
|
+
|
171
|
+
let :nested do
|
172
|
+
Sequence[
|
173
|
+
Label[:left, Match[/[[:alpha:]]+/]],
|
174
|
+
Match[/\=/],
|
175
|
+
Label[:right, Match[/[[:digit:]]+/]]
|
157
176
|
]
|
158
177
|
end
|
178
|
+
|
179
|
+
let(:code) { '"#{right} -> #{left}"' }
|
180
|
+
|
159
181
|
context 'when the parser matches' do
|
160
182
|
it 'applies the action binding the labels to the results' do
|
161
183
|
parsing('val=42 ').should result_in('42 -> val').at(6)
|
@@ -166,19 +188,37 @@ describe DirectAction do
|
|
166
188
|
|
167
189
|
describe '#capturing?' do
|
168
190
|
|
191
|
+
let(:code) { '' }
|
192
|
+
|
169
193
|
context 'with a capturing parser' do
|
170
|
-
|
194
|
+
|
195
|
+
let(:nested) { Match[/\w+/] }
|
196
|
+
|
171
197
|
it 'is true' do
|
172
198
|
subject.should be_capturing
|
173
199
|
end
|
174
200
|
end
|
175
201
|
|
176
202
|
context 'with a non-capturing parser' do
|
177
|
-
|
203
|
+
|
204
|
+
let(:nested) { Skip[Match[/\s*/]] }
|
205
|
+
|
178
206
|
it 'is false' do
|
179
207
|
subject.should_not be_capturing
|
180
208
|
end
|
181
209
|
end
|
182
210
|
end
|
183
211
|
|
212
|
+
describe '#with_ws' do
|
213
|
+
|
214
|
+
let(:ws) { Match[/\s*/] }
|
215
|
+
let(:nested) { Match[/\w+/] }
|
216
|
+
let(:code) { '' }
|
217
|
+
|
218
|
+
it 'applies #with_ws to the nested parser' do
|
219
|
+
subject.with_ws(ws).
|
220
|
+
should == DirectAction[Sequence[Skip[ws], nested], code]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
184
224
|
end
|
@@ -3,28 +3,39 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
3
3
|
describe Disallow do
|
4
4
|
include CombinatorParserSpecHelper
|
5
5
|
|
6
|
-
subject { Disallow[
|
7
|
-
|
6
|
+
subject { Disallow[nested] }
|
7
|
+
|
8
|
+
let(:nested) { Match[/\w+/] }
|
9
|
+
|
8
10
|
describe '#parse' do
|
9
|
-
|
11
|
+
|
10
12
|
context 'when the parser matches' do
|
11
13
|
it 'fails' do
|
12
14
|
parsing('abc123').should fail
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
context 'when the parser fails' do
|
17
19
|
it 'returns true without advancing' do
|
18
20
|
parsing(' ').should result_in(true).at(0)
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
23
|
+
|
22
24
|
end
|
23
|
-
|
25
|
+
|
24
26
|
describe '#capturing?' do
|
25
27
|
it 'is false' do
|
26
28
|
subject.should_not be_capturing
|
27
29
|
end
|
28
30
|
end
|
29
|
-
|
31
|
+
|
32
|
+
describe '#with_ws' do
|
33
|
+
|
34
|
+
let(:ws) { Match[/\s*/] }
|
35
|
+
|
36
|
+
it 'applies #with_ws to the nested parser' do
|
37
|
+
subject.with_ws(ws).should == Disallow[Sequence[Skip[ws], nested]]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
30
41
|
end
|
@@ -3,13 +3,31 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
3
3
|
describe DispatchAction do
|
4
4
|
include CombinatorParserSpecHelper
|
5
5
|
|
6
|
-
subject { DispatchAction[
|
6
|
+
subject { DispatchAction[nested] }
|
7
7
|
|
8
8
|
describe '#parse' do
|
9
9
|
|
10
10
|
context 'with a capturing parser' do
|
11
11
|
|
12
|
-
let
|
12
|
+
let(:nested) { Match[/[[:digit:]]+/] }
|
13
|
+
|
14
|
+
context 'when the parser matches' do
|
15
|
+
it 'applies the action to the result' do
|
16
|
+
parsing('451a').
|
17
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['451'])).at(3)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the parser fails' do
|
22
|
+
it 'fails' do
|
23
|
+
parsing('foo').should fail
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a sequence parser' do
|
29
|
+
|
30
|
+
let(:nested) { Sequence[
|
13
31
|
Match[/[[:alpha:]]+/], Match[/\=/], Match[/[[:digit:]]+/]
|
14
32
|
] }
|
15
33
|
|
@@ -27,21 +45,83 @@ describe DispatchAction do
|
|
27
45
|
end
|
28
46
|
end
|
29
47
|
|
30
|
-
context 'with
|
48
|
+
context 'with an optional parser' do
|
31
49
|
|
32
|
-
let
|
50
|
+
let(:nested) { Repeat[Match[/\d/], 0, 1] }
|
33
51
|
|
34
|
-
context 'when the parser matches' do
|
52
|
+
context 'when the nested parser matches' do
|
53
|
+
it 'applies the action to an array containing the match' do
|
54
|
+
parsing('451a').
|
55
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['4'])).at(1)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when the nested parser fails' do
|
35
60
|
it 'applies the action to an empty array' do
|
36
|
-
parsing('
|
37
|
-
should result_in(Rattler::Runtime::ParseNode.parsed([])).at(
|
61
|
+
parsing('foo').
|
62
|
+
should result_in(Rattler::Runtime::ParseNode.parsed([])).at(0)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with a zero-or-more parser' do
|
68
|
+
|
69
|
+
let(:nested) { Repeat[Match[/\d/], 0, nil] }
|
70
|
+
|
71
|
+
context 'when the nested parser matches' do
|
72
|
+
it 'applies the action to an array containing the matches' do
|
73
|
+
parsing('451a').
|
74
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['4', '5', '1'])).at(3)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when the nested parser fails' do
|
79
|
+
it 'applies the action to an empty array' do
|
80
|
+
parsing('foo').
|
81
|
+
should result_in(Rattler::Runtime::ParseNode.parsed([])).at(0)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'with a one-or-more parser' do
|
87
|
+
|
88
|
+
let(:nested) { Repeat[Match[/\d/], 1, nil] }
|
89
|
+
|
90
|
+
context 'when the nested parser matches' do
|
91
|
+
it 'applies the action to an array containing the matches' do
|
92
|
+
parsing('451a').
|
93
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['4', '5', '1'])).at(3)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when the nested parser fails' do
|
98
|
+
it 'fails' do
|
99
|
+
parsing('foo').should fail
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'with a list parser' do
|
105
|
+
|
106
|
+
let(:nested) { ListParser[Match[/[[:digit:]]+/], Match[/,/], 2, 4] }
|
107
|
+
|
108
|
+
context 'when the nested parser matches' do
|
109
|
+
it 'applies the action to an array containing the matches' do
|
110
|
+
parsing('1,2,42').
|
111
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['1', '2', '42'])).at(6)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'when the nested parser fails' do
|
116
|
+
it 'fails' do
|
117
|
+
parsing('foo').should fail
|
38
118
|
end
|
39
119
|
end
|
40
120
|
end
|
41
121
|
|
42
122
|
context 'with a token parser' do
|
43
123
|
|
44
|
-
|
124
|
+
let(:nested) { Token[Match[/\w+/]] }
|
45
125
|
|
46
126
|
context 'when the parser matches' do
|
47
127
|
it 'applies the action to the matched string' do
|
@@ -53,26 +133,37 @@ describe DispatchAction do
|
|
53
133
|
|
54
134
|
context 'with a non-capturing parser' do
|
55
135
|
|
56
|
-
|
136
|
+
let(:nested) { Skip[Match[/,/]] }
|
57
137
|
|
58
138
|
context 'when the parser matches' do
|
59
139
|
it 'applies the action to an empty array' do
|
60
|
-
parsing('
|
61
|
-
should result_in(Rattler::Runtime::ParseNode.parsed([])).at(
|
140
|
+
parsing(', ').
|
141
|
+
should result_in(Rattler::Runtime::ParseNode.parsed([])).at(1)
|
62
142
|
end
|
63
143
|
end
|
64
144
|
end
|
65
145
|
|
66
|
-
context 'with a
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
]
|
74
|
-
|
146
|
+
context 'with a labeled parser' do
|
147
|
+
|
148
|
+
let(:nested) { Label[:word, Match[/[[:alpha:]]+/]] }
|
149
|
+
|
150
|
+
context 'when the parser matches' do
|
151
|
+
it 'applies the action binding the label to the result' do
|
152
|
+
parsing('foo ').
|
153
|
+
should result_in(Rattler::Runtime::ParseNode.parsed(['foo'],
|
154
|
+
:labeled => {:word => 'foo'}))
|
155
|
+
end
|
75
156
|
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'with a sequence of labeled parsers' do
|
160
|
+
|
161
|
+
let(:nested) { Sequence[
|
162
|
+
Label[:name, Match[/[[:alpha:]]+/]],
|
163
|
+
Match[/\=/],
|
164
|
+
Label[:value, Match[/[[:digit:]]+/]]
|
165
|
+
] }
|
166
|
+
|
76
167
|
context 'when the parser matches' do
|
77
168
|
it 'applies the action binding the labels to the results' do
|
78
169
|
parsing('val=42 ').
|
@@ -86,18 +177,33 @@ describe DispatchAction do
|
|
86
177
|
describe '#capturing?' do
|
87
178
|
|
88
179
|
context 'with a capturing parser' do
|
89
|
-
|
180
|
+
|
181
|
+
let(:nested) { Match[/\w+/] }
|
182
|
+
|
90
183
|
it 'is true' do
|
91
184
|
subject.should be_capturing
|
92
185
|
end
|
93
186
|
end
|
94
187
|
|
95
188
|
context 'with a non-capturing parser' do
|
96
|
-
|
189
|
+
|
190
|
+
let(:nested) { Skip[Match[/\s*/]] }
|
191
|
+
|
97
192
|
it 'is false' do
|
98
193
|
subject.should_not be_capturing
|
99
194
|
end
|
100
195
|
end
|
101
196
|
end
|
102
197
|
|
198
|
+
describe '#with_ws' do
|
199
|
+
|
200
|
+
let(:ws) { Match[/\s*/] }
|
201
|
+
let(:nested) { Match[/\w+/] }
|
202
|
+
|
203
|
+
it 'applies #with_ws to the nested parser' do
|
204
|
+
subject.with_ws(ws).
|
205
|
+
should == DispatchAction[Sequence[Skip[ws], nested]]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
103
209
|
end
|