walrus 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/walrus +29 -14
- data/ext/extconf.rb +16 -0
- data/ext/{jindex/jindex.c → jindex.c} +27 -14
- data/lib/walrus/additions/string.rb +11 -5
- data/lib/walrus/compile_error.rb +11 -5
- data/lib/walrus/compiler.rb +12 -6
- data/lib/walrus/contrib/spec/walruscloth_spec.rb +11 -5
- data/lib/walrus/contrib/walruscloth.rb +11 -5
- data/lib/walrus/diff.rb +11 -5
- data/lib/walrus/document.rb +11 -5
- data/lib/walrus/grammar/additions/proc.rb +11 -5
- data/lib/walrus/grammar/additions/regexp.rb +11 -5
- data/lib/walrus/grammar/additions/string.rb +11 -5
- data/lib/walrus/grammar/additions/symbol.rb +12 -5
- data/lib/walrus/grammar/and_predicate.rb +11 -5
- data/lib/walrus/grammar/array_result.rb +11 -5
- data/lib/walrus/grammar/continuation_wrapper_exception.rb +11 -5
- data/lib/walrus/grammar/left_recursion_exception.rb +11 -5
- data/lib/walrus/grammar/location_tracking.rb +19 -9
- data/lib/walrus/grammar/match_data_wrapper.rb +11 -5
- data/lib/walrus/grammar/memoizing.rb +11 -5
- data/lib/walrus/grammar/memoizing_cache.rb +18 -9
- data/lib/walrus/grammar/node.rb +11 -5
- data/lib/walrus/grammar/not_predicate.rb +11 -5
- data/lib/walrus/grammar/parse_error.rb +11 -5
- data/lib/walrus/grammar/parser_state.rb +11 -5
- data/lib/walrus/grammar/parslet.rb +11 -5
- data/lib/walrus/grammar/parslet_choice.rb +15 -7
- data/lib/walrus/grammar/parslet_combination.rb +11 -5
- data/lib/walrus/grammar/parslet_combining.rb +11 -5
- data/lib/walrus/grammar/parslet_merge.rb +11 -5
- data/lib/walrus/grammar/parslet_omission.rb +11 -5
- data/lib/walrus/grammar/parslet_repetition.rb +17 -8
- data/lib/walrus/grammar/parslet_repetition_default.rb +11 -5
- data/lib/walrus/grammar/parslet_sequence.rb +20 -8
- data/lib/walrus/grammar/predicate.rb +11 -5
- data/lib/walrus/grammar/proc_parslet.rb +11 -5
- data/lib/walrus/grammar/regexp_parslet.rb +11 -5
- data/lib/walrus/grammar/skipped_substring_exception.rb +11 -5
- data/lib/walrus/grammar/string_enumerator.rb +14 -6
- data/lib/walrus/grammar/string_parslet.rb +11 -5
- data/lib/walrus/grammar/string_result.rb +11 -5
- data/lib/walrus/grammar/symbol_parslet.rb +11 -5
- data/lib/walrus/grammar.rb +11 -5
- data/lib/walrus/no_parameter_marker.rb +11 -5
- data/lib/walrus/parser.rb +12 -6
- data/lib/walrus/runner.rb +60 -67
- data/lib/walrus/template.rb +15 -7
- data/lib/walrus/version.rb +3 -0
- data/lib/walrus/walrus_grammar/assignment_expression.rb +11 -5
- data/lib/walrus/walrus_grammar/block_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/comment.rb +11 -5
- data/lib/walrus/walrus_grammar/def_directive.rb +16 -8
- data/lib/walrus/walrus_grammar/echo_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/escape_sequence.rb +11 -5
- data/lib/walrus/walrus_grammar/import_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/include_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/instance_variable.rb +11 -5
- data/lib/walrus/walrus_grammar/literal.rb +11 -5
- data/lib/walrus/walrus_grammar/message_expression.rb +11 -5
- data/lib/walrus/walrus_grammar/multiline_comment.rb +11 -5
- data/lib/walrus/walrus_grammar/placeholder.rb +11 -5
- data/lib/walrus/walrus_grammar/raw_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/raw_text.rb +11 -5
- data/lib/walrus/walrus_grammar/ruby_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/ruby_expression.rb +11 -5
- data/lib/walrus/walrus_grammar/set_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/silent_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/slurp_directive.rb +11 -5
- data/lib/walrus/walrus_grammar/super_directive.rb +11 -5
- data/lib/walrus.rb +30 -16
- metadata +91 -211
- data/ext/jindex/extconf.rb +0 -11
- data/ext/mkdtemp/extconf.rb +0 -11
- data/ext/mkdtemp/mkdtemp.c +0 -41
- data/lib/walrus/additions/module.rb +0 -36
- data/lib/walrus/additions/test/unit/error_collector.rb +0 -62
- data/spec/acceptance/acceptance_spec.rb +0 -97
- data/spec/acceptance/block/basic_block.expected +0 -1
- data/spec/acceptance/block/basic_block.tmpl +0 -3
- data/spec/acceptance/block/nested_blocks.expected +0 -5
- data/spec/acceptance/block/nested_blocks.tmpl +0 -11
- data/spec/acceptance/comments/comments_and_text.expected +0 -3
- data/spec/acceptance/comments/comments_and_text.tmpl +0 -6
- data/spec/acceptance/comments/single_comment.expected +0 -0
- data/spec/acceptance/comments/single_comment.tmpl +0 -1
- data/spec/acceptance/def/alternative_def_calling_conventions.expected +0 -3
- data/spec/acceptance/def/alternative_def_calling_conventions.tmpl +0 -18
- data/spec/acceptance/def/basic_def_block_no_output.expected +0 -0
- data/spec/acceptance/def/basic_def_block_no_output.tmpl +0 -17
- data/spec/acceptance/def/defs_can_be_called_multiple_times.expected +0 -3
- data/spec/acceptance/def/defs_can_be_called_multiple_times.tmpl +0 -6
- data/spec/acceptance/def/defs_can_be_dynamic.expected +0 -4
- data/spec/acceptance/def/defs_can_be_dynamic.tmpl +0 -12
- data/spec/acceptance/echo/echo_directive_with_numeric_literal.expected +0 -1
- data/spec/acceptance/echo/echo_directive_with_numeric_literal.tmpl +0 -1
- data/spec/acceptance/echo/echo_expression_list.expected +0 -1
- data/spec/acceptance/echo/echo_expression_list.tmpl +0 -1
- data/spec/acceptance/echo/echo_short_notation.expected +0 -1
- data/spec/acceptance/echo/echo_short_notation.tmpl +0 -1
- data/spec/acceptance/echo/echo_simple_expression.expected +0 -1
- data/spec/acceptance/echo/echo_simple_expression.tmpl +0 -1
- data/spec/acceptance/echo/echo_single_quoted_string_literal.expected +0 -1
- data/spec/acceptance/echo/echo_single_quoted_string_literal.tmpl +0 -1
- data/spec/acceptance/echo/multiple_echo_statements.expected +0 -1
- data/spec/acceptance/echo/multiple_echo_statements.tmpl +0 -2
- data/spec/acceptance/includes/basic_included_file.txt +0 -1
- data/spec/acceptance/includes/basic_includer.complex +0 -3
- data/spec/acceptance/includes/basic_includer.expected +0 -3
- data/spec/acceptance/includes/basic_includer.rb +0 -38
- data/spec/acceptance/includes/complicated_included_file.txt +0 -3
- data/spec/acceptance/includes/complicated_includer.complex +0 -3
- data/spec/acceptance/includes/complicated_includer.expected +0 -3
- data/spec/acceptance/includes/complicated_includer.rb +0 -41
- data/spec/acceptance/includes/nested_include_1.txt +0 -3
- data/spec/acceptance/includes/nested_include_2.txt +0 -1
- data/spec/acceptance/includes/nested_includer.complex +0 -3
- data/spec/acceptance/includes/nested_includer.expected +0 -4
- data/spec/acceptance/includes/nested_includer.rb +0 -41
- data/spec/acceptance/inheritance/basic_child.complex +0 -10
- data/spec/acceptance/inheritance/basic_child.expected +0 -9
- data/spec/acceptance/inheritance/basic_child.rb +0 -54
- data/spec/acceptance/inheritance/basic_parent.complex +0 -5
- data/spec/acceptance/inheritance/basic_parent.expected +0 -3
- data/spec/acceptance/inheritance/basic_parent.rb +0 -41
- data/spec/acceptance/inheritance/importing_child.complex +0 -8
- data/spec/acceptance/inheritance/importing_child.expected +0 -7
- data/spec/acceptance/inheritance/importing_child.rb +0 -46
- data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.complex +0 -8
- data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.expected +0 -7
- data/spec/acceptance/inheritance/subdirectory/importing_child_in_subdirectory.rb +0 -44
- data/spec/acceptance/multiline_comments/multiline_comment_with_directives_inside.expected +0 -0
- data/spec/acceptance/multiline_comments/multiline_comment_with_directives_inside.tmpl +0 -15
- data/spec/acceptance/multiline_comments/simple_multiline_comment.expected +0 -2
- data/spec/acceptance/multiline_comments/simple_multiline_comment.tmpl +0 -4
- data/spec/acceptance/raw/complicated_raw_example.expected +0 -57
- data/spec/acceptance/raw/complicated_raw_example.tmpl +0 -79
- data/spec/acceptance/raw-text/UTF_8.expected +0 -12
- data/spec/acceptance/raw-text/UTF_8.tmpl +0 -12
- data/spec/acceptance/raw-text/empty_file.expected +0 -0
- data/spec/acceptance/raw-text/empty_file.tmpl +0 -0
- data/spec/acceptance/raw-text/multi_line.expected +0 -4
- data/spec/acceptance/raw-text/multi_line.tmpl +0 -4
- data/spec/acceptance/raw-text/single_line.expected +0 -1
- data/spec/acceptance/raw-text/single_line.tmpl +0 -1
- data/spec/acceptance/raw-text/single_line_whitespace.expected +0 -1
- data/spec/acceptance/raw-text/single_line_whitespace.tmpl +0 -1
- data/spec/acceptance/ruby/ruby_directive_is_just_like_silent.expected +0 -1
- data/spec/acceptance/ruby/ruby_directive_is_just_like_silent.tmpl +0 -4
- data/spec/acceptance/ruby/ruby_directive_using_here_doc.expected +0 -1
- data/spec/acceptance/ruby/ruby_directive_using_here_doc.tmpl +0 -4
- data/spec/acceptance/ruby/ruby_directive_using_here_doc_alt_syntax.expected +0 -1
- data/spec/acceptance/ruby/ruby_directive_using_here_doc_alt_syntax.tmpl +0 -4
- data/spec/acceptance/ruby/ruby_directive_with_accumulate.expected +0 -1
- data/spec/acceptance/ruby/ruby_directive_with_accumulate.tmpl +0 -4
- data/spec/acceptance/ruby/ruby_directive_with_accumulate_and_block.expected +0 -1
- data/spec/acceptance/ruby/ruby_directive_with_accumulate_and_block.tmpl +0 -6
- data/spec/acceptance/set/unused_set.expected +0 -0
- data/spec/acceptance/set/unused_set.tmpl +0 -1
- data/spec/acceptance/set/used_set.expected +0 -1
- data/spec/acceptance/set/used_set.tmpl +0 -2
- data/spec/acceptance/silent/silent_and_echo_combined.expected +0 -1
- data/spec/acceptance/silent/silent_and_echo_combined.tmpl +0 -2
- data/spec/acceptance/silent/silent_short_notation.expected +0 -1
- data/spec/acceptance/silent/silent_short_notation.tmpl +0 -1
- data/spec/acceptance/silent/simple_silent_directive.expected +0 -0
- data/spec/acceptance/silent/simple_silent_directive.tmpl +0 -1
- data/spec/acceptance/slurp/basic_slurp_demo.expected +0 -1
- data/spec/acceptance/slurp/basic_slurp_demo.tmpl +0 -4
- data/spec/acceptance/super/super_with_no_effect.expected +0 -4
- data/spec/acceptance/super/super_with_no_effect.tmpl +0 -5
- data/spec/additions/module_spec.rb +0 -126
- data/spec/additions/string_spec.rb +0 -99
- data/spec/compiler_spec.rb +0 -55
- data/spec/grammar/additions/proc_spec.rb +0 -25
- data/spec/grammar/additions/regexp_spec.rb +0 -37
- data/spec/grammar/additions/string_spec.rb +0 -106
- data/spec/grammar/and_predicate_spec.rb +0 -29
- data/spec/grammar/continuation_wrapper_exception_spec.rb +0 -23
- data/spec/grammar/match_data_wrapper_spec.rb +0 -41
- data/spec/grammar/memoizing_cache_spec.rb +0 -112
- data/spec/grammar/node_spec.rb +0 -126
- data/spec/grammar/not_predicate_spec.rb +0 -29
- data/spec/grammar/parser_state_spec.rb +0 -172
- data/spec/grammar/parslet_choice_spec.rb +0 -49
- data/spec/grammar/parslet_combining_spec.rb +0 -287
- data/spec/grammar/parslet_merge_spec.rb +0 -33
- data/spec/grammar/parslet_omission_spec.rb +0 -58
- data/spec/grammar/parslet_repetition_spec.rb +0 -77
- data/spec/grammar/parslet_sequence_spec.rb +0 -49
- data/spec/grammar/parslet_spec.rb +0 -23
- data/spec/grammar/predicate_spec.rb +0 -53
- data/spec/grammar/proc_parslet_spec.rb +0 -52
- data/spec/grammar/regexp_parslet_spec.rb +0 -347
- data/spec/grammar/string_enumerator_spec.rb +0 -94
- data/spec/grammar/string_parslet_spec.rb +0 -143
- data/spec/grammar/symbol_parslet_spec.rb +0 -30
- data/spec/grammar_spec.rb +0 -545
- data/spec/parser_spec.rb +0 -1418
- data/spec/spec_helper.rb +0 -34
- data/spec/walrus_grammar/comment_spec.rb +0 -39
- data/spec/walrus_grammar/echo_directive_spec.rb +0 -63
- data/spec/walrus_grammar/escape_sequence_spec.rb +0 -85
- data/spec/walrus_grammar/literal_spec.rb +0 -41
- data/spec/walrus_grammar/message_expression_spec.rb +0 -37
- data/spec/walrus_grammar/multiline_comment_spec.rb +0 -58
- data/spec/walrus_grammar/placeholder_spec.rb +0 -48
- data/spec/walrus_grammar/raw_directive_spec.rb +0 -81
- data/spec/walrus_grammar/raw_text_spec.rb +0 -65
- data/spec/walrus_grammar/silent_directive_spec.rb +0 -34
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
|
-
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
1
|
+
# Copyright 2007-2009 Wincent Colaiuta
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -48,9 +54,12 @@ module Walrus
|
|
48
54
|
identifier << options[:skipping_override] if options.has_key? :skipping_override
|
49
55
|
|
50
56
|
if (result = @cache[identifier]) != NoValueForKey.instance
|
51
|
-
if result.kind_of? Symbol
|
52
|
-
|
53
|
-
|
57
|
+
if result.kind_of? Symbol
|
58
|
+
throw result
|
59
|
+
elsif result.kind_of? Exception
|
60
|
+
raise result
|
61
|
+
else
|
62
|
+
return result
|
54
63
|
end
|
55
64
|
else # first time for this parseable/location/skipping_override (etc) combination, capture result and propagate
|
56
65
|
catch :NotPredicateSuccess do
|
data/lib/walrus/grammar/node.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -74,8 +80,10 @@ module Walrus
|
|
74
80
|
# the question is, is it more complicated than the other ways of getting right-associativity into Walrus-generated parsers?
|
75
81
|
|
76
82
|
rescue ParseError => e
|
77
|
-
if error.nil?
|
78
|
-
|
83
|
+
if error.nil?
|
84
|
+
error = e
|
85
|
+
else
|
86
|
+
error = e unless error.rightmost?(e)
|
79
87
|
end
|
80
88
|
end
|
81
89
|
end
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -35,9 +41,12 @@ module Walrus
|
|
35
41
|
rescue SkippedSubstringException => e
|
36
42
|
state.skipped(e)
|
37
43
|
rescue ParseError => e # failed, will try to skip; save original error in case skipping fails
|
38
|
-
if options.has_key?(:skipping_override)
|
39
|
-
|
40
|
-
|
44
|
+
if options.has_key?(:skipping_override)
|
45
|
+
skipping_parslet = options[:skipping_override]
|
46
|
+
elsif options.has_key?(:skipping)
|
47
|
+
skipping_parslet = options[:skipping]
|
48
|
+
else
|
49
|
+
skipping_parslet = nil
|
41
50
|
end
|
42
51
|
break if skipping_parslet.nil?
|
43
52
|
begin
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -76,6 +82,9 @@ module Walrus
|
|
76
82
|
rescue LeftRecursionException => e
|
77
83
|
left_recursion = true
|
78
84
|
continuation = nil
|
85
|
+
|
86
|
+
# Ruby 1.9/2.0 will almost certainly not support continuations so need to come up with an alternative
|
87
|
+
# for handling left recursion here
|
79
88
|
value = callcc { |c| continuation = c }
|
80
89
|
if value == continuation # first time that we're here
|
81
90
|
e.continuation = continuation # pack continuation into exception
|
@@ -99,9 +108,12 @@ module Walrus
|
|
99
108
|
rescue SkippedSubstringException => e
|
100
109
|
state.skipped(e)
|
101
110
|
rescue ParseError => e # failed, will try to skip; save original error in case skipping fails
|
102
|
-
if options.has_key?(:skipping_override)
|
103
|
-
|
104
|
-
|
111
|
+
if options.has_key?(:skipping_override)
|
112
|
+
skipping_parslet = options[:skipping_override]
|
113
|
+
elsif options.has_key?(:skipping)
|
114
|
+
skipping_parslet = options[:skipping]
|
115
|
+
else
|
116
|
+
skipping_parslet = nil
|
105
117
|
end
|
106
118
|
raise e if skipping_parslet.nil? # no skipper defined, raise original error
|
107
119
|
begin
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'strscan'
|
10
16
|
require 'walrus'
|
@@ -35,7 +41,9 @@ module Walrus
|
|
35
41
|
# Take a peek at the next character without actually consuming it. Returns nil if there is no next character.
|
36
42
|
# TODO: consider deleting this method as it's not currently used.
|
37
43
|
def peek
|
38
|
-
if char = self.next
|
44
|
+
if char = self.next
|
45
|
+
@scanner.unscan
|
46
|
+
end
|
39
47
|
char
|
40
48
|
end
|
41
49
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# Copyright 2007 Wincent Colaiuta
|
2
|
-
# This program is
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
2
|
+
# This program is free software: you can redistribute it and/or modify
|
3
|
+
# it under the terms of the GNU General Public License as published by
|
4
|
+
# the Free Software Foundation, either version 3 of the License, or
|
5
|
+
# (at your option) any later version.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# This program is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10
|
+
# GNU General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License
|
13
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
8
14
|
|
9
15
|
require 'walrus'
|
10
16
|
|