walrus 0.2 → 0.3
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/bin/walrus +19 -12
- data/lib/walrus.rb +27 -70
- data/lib/walrus/additions/string.rb +21 -35
- data/lib/walrus/compile_error.rb +19 -16
- data/lib/walrus/compiler.rb +66 -55
- data/lib/walrus/contrib/spec/walruscloth_spec.rb +21 -17
- data/lib/walrus/contrib/walruscloth.rb +19 -11
- data/lib/walrus/document.rb +41 -33
- data/lib/walrus/grammar.rb +474 -162
- data/lib/walrus/grammar/assignment_expression.rb +33 -0
- data/lib/walrus/grammar/block_directive.rb +37 -0
- data/lib/walrus/grammar/comment.rb +33 -0
- data/lib/walrus/grammar/def_directive.rb +80 -0
- data/lib/walrus/grammar/echo_directive.rb +56 -0
- data/lib/walrus/grammar/escape_sequence.rb +33 -0
- data/lib/walrus/grammar/import_directive.rb +54 -0
- data/lib/walrus/grammar/include_directive.rb +36 -0
- data/lib/walrus/grammar/instance_variable.rb +33 -0
- data/lib/walrus/grammar/literal.rb +33 -0
- data/lib/walrus/grammar/message_expression.rb +34 -0
- data/lib/walrus/grammar/multiline_comment.rb +70 -0
- data/lib/walrus/grammar/placeholder.rb +47 -0
- data/lib/walrus/grammar/raw_directive.rb +50 -0
- data/lib/walrus/grammar/raw_text.rb +56 -0
- data/lib/walrus/grammar/ruby_directive.rb +41 -0
- data/lib/walrus/grammar/ruby_expression.rb +42 -0
- data/lib/walrus/grammar/set_directive.rb +34 -0
- data/lib/walrus/grammar/silent_directive.rb +51 -0
- data/lib/walrus/grammar/slurp_directive.rb +36 -0
- data/lib/walrus/grammar/super_directive.rb +34 -0
- data/lib/walrus/parser.rb +26 -408
- data/lib/walrus/runner.rb +37 -20
- data/lib/walrus/template.rb +34 -25
- data/lib/walrus/version.rb +24 -1
- metadata +57 -71
- data/ext/extconf.rb +0 -16
- data/ext/jindex.c +0 -92
- data/lib/walrus/diff.rb +0 -95
- data/lib/walrus/grammar/additions/proc.rb +0 -26
- data/lib/walrus/grammar/additions/regexp.rb +0 -27
- data/lib/walrus/grammar/additions/string.rb +0 -58
- data/lib/walrus/grammar/additions/symbol.rb +0 -49
- data/lib/walrus/grammar/and_predicate.rb +0 -46
- data/lib/walrus/grammar/array_result.rb +0 -25
- data/lib/walrus/grammar/continuation_wrapper_exception.rb +0 -34
- data/lib/walrus/grammar/left_recursion_exception.rb +0 -33
- data/lib/walrus/grammar/location_tracking.rb +0 -115
- data/lib/walrus/grammar/match_data_wrapper.rb +0 -71
- data/lib/walrus/grammar/memoizing.rb +0 -47
- data/lib/walrus/grammar/memoizing_cache.rb +0 -103
- data/lib/walrus/grammar/node.rb +0 -66
- data/lib/walrus/grammar/not_predicate.rb +0 -46
- data/lib/walrus/grammar/parse_error.rb +0 -45
- data/lib/walrus/grammar/parser_state.rb +0 -187
- data/lib/walrus/grammar/parslet.rb +0 -34
- data/lib/walrus/grammar/parslet_choice.rb +0 -128
- data/lib/walrus/grammar/parslet_combination.rb +0 -32
- data/lib/walrus/grammar/parslet_combining.rb +0 -160
- data/lib/walrus/grammar/parslet_merge.rb +0 -94
- data/lib/walrus/grammar/parslet_omission.rb +0 -63
- data/lib/walrus/grammar/parslet_repetition.rb +0 -106
- data/lib/walrus/grammar/parslet_repetition_default.rb +0 -64
- data/lib/walrus/grammar/parslet_sequence.rb +0 -214
- data/lib/walrus/grammar/predicate.rb +0 -63
- data/lib/walrus/grammar/proc_parslet.rb +0 -58
- data/lib/walrus/grammar/regexp_parslet.rb +0 -79
- data/lib/walrus/grammar/skipped_substring_exception.rb +0 -42
- data/lib/walrus/grammar/string_enumerator.rb +0 -53
- data/lib/walrus/grammar/string_parslet.rb +0 -81
- data/lib/walrus/grammar/string_result.rb +0 -30
- data/lib/walrus/grammar/symbol_parslet.rb +0 -69
- data/lib/walrus/no_parameter_marker.rb +0 -25
- data/lib/walrus/walrus_grammar/assignment_expression.rb +0 -30
- data/lib/walrus/walrus_grammar/block_directive.rb +0 -34
- data/lib/walrus/walrus_grammar/comment.rb +0 -30
- data/lib/walrus/walrus_grammar/def_directive.rb +0 -72
- data/lib/walrus/walrus_grammar/echo_directive.rb +0 -50
- data/lib/walrus/walrus_grammar/escape_sequence.rb +0 -30
- data/lib/walrus/walrus_grammar/import_directive.rb +0 -50
- data/lib/walrus/walrus_grammar/include_directive.rb +0 -33
- data/lib/walrus/walrus_grammar/instance_variable.rb +0 -30
- data/lib/walrus/walrus_grammar/literal.rb +0 -30
- data/lib/walrus/walrus_grammar/message_expression.rb +0 -31
- data/lib/walrus/walrus_grammar/multiline_comment.rb +0 -60
- data/lib/walrus/walrus_grammar/placeholder.rb +0 -46
- data/lib/walrus/walrus_grammar/raw_directive.rb +0 -48
- data/lib/walrus/walrus_grammar/raw_text.rb +0 -51
- data/lib/walrus/walrus_grammar/ruby_directive.rb +0 -35
- data/lib/walrus/walrus_grammar/ruby_expression.rb +0 -37
- data/lib/walrus/walrus_grammar/set_directive.rb +0 -30
- data/lib/walrus/walrus_grammar/silent_directive.rb +0 -50
- data/lib/walrus/walrus_grammar/slurp_directive.rb +0 -31
- data/lib/walrus/walrus_grammar/super_directive.rb +0 -33
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus'
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
|
|
19
|
-
class NoParameterMarker
|
|
20
|
-
require 'singleton'
|
|
21
|
-
include Singleton
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end # module Walrus
|
|
25
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class AssignmentExpression
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
@lvalue.source_text + '=' + @expression.source_text
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end # class AssignmentExpression
|
|
27
|
-
|
|
28
|
-
end # class WalrusGrammar
|
|
29
|
-
end # Walrus
|
|
30
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class BlockDirective
|
|
21
|
-
|
|
22
|
-
# Returns a string containing the compiled (Ruby) version of receiver.
|
|
23
|
-
def compile(options = {})
|
|
24
|
-
inner, outer = super
|
|
25
|
-
inner = '' if inner.nil?
|
|
26
|
-
inner << "lookup_and_accumulate_placeholder(#{@identifier.to_s.to_sym.inspect})\n"
|
|
27
|
-
[inner, outer]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end # class BlockDirective
|
|
31
|
-
|
|
32
|
-
end # class WalrusGrammar
|
|
33
|
-
end # Walrus
|
|
34
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class Comment
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
'# Comment:' + @lexeme.to_s + "\n"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end # class WalrusGrammar
|
|
29
|
-
end # Walrus
|
|
30
|
-
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class DefDirective
|
|
21
|
-
|
|
22
|
-
# Returns a string containing the compiled (Ruby) version of receiver.
|
|
23
|
-
def compile(options = {})
|
|
24
|
-
internal = ''
|
|
25
|
-
|
|
26
|
-
if @params == []
|
|
27
|
-
external = "def #{@identifier.to_s}\n"
|
|
28
|
-
else
|
|
29
|
-
# this will work for the simple case where params are plain identifiers
|
|
30
|
-
params = (@params.kind_of? Array) ? @params : [@params]
|
|
31
|
-
param_list = params.collect { |param| param.compile }.join(', ')
|
|
32
|
-
external = "def #{@identifier.to_s}(#{param_list})\n"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
nested = nil
|
|
36
|
-
|
|
37
|
-
if @content.respond_to? :each
|
|
38
|
-
content = @content
|
|
39
|
-
else
|
|
40
|
-
content = [@content]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
content.each do |element|
|
|
44
|
-
if element.kind_of? WalrusGrammar::DefDirective # must handle nested def blocks here
|
|
45
|
-
inner, outer = element.compile(options)
|
|
46
|
-
nested = ['', ''] if nested.nil?
|
|
47
|
-
external << inner if inner
|
|
48
|
-
nested[1] << "\n" + outer
|
|
49
|
-
else
|
|
50
|
-
# again, may wish to forget the per-line indenting here if it breaks sensitive directive types
|
|
51
|
-
# (#ruby blocks for example, which might have here documents)
|
|
52
|
-
element.compile(options).each do |lines| # may return a single line or an array of lines
|
|
53
|
-
lines.each { |line| external << ' ' + line }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
external << "end\n\n"
|
|
59
|
-
|
|
60
|
-
if nested
|
|
61
|
-
external << nested[1]
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
internal = nil if internal == '' # better to return nil than an empty string here (which would get indented needlessly)
|
|
65
|
-
[internal, external]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
end # class DefDirective
|
|
69
|
-
|
|
70
|
-
end # class WalrusGrammar
|
|
71
|
-
end # Walrus
|
|
72
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class EchoDirective
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
|
|
24
|
-
if @expression.respond_to? :each
|
|
25
|
-
expression = @expression
|
|
26
|
-
else
|
|
27
|
-
expression = [@expression]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# TODO: potentially include line, col and file name info in the comments generated by the compiler
|
|
31
|
-
|
|
32
|
-
compiled = ''
|
|
33
|
-
first = true
|
|
34
|
-
expression.each do |expr|
|
|
35
|
-
if first
|
|
36
|
-
compiled << "accumulate(instance_eval { %s }) # Echo directive\n" % expr.compile
|
|
37
|
-
first = false
|
|
38
|
-
else
|
|
39
|
-
compiled << "accumulate(instance_eval { %s }) # Echo directive (continued)\n" % expr.compile
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
compiled
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end # class EchoDirective
|
|
47
|
-
|
|
48
|
-
end # class WalrusGrammar
|
|
49
|
-
end # Walrus
|
|
50
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class EscapeSequence
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
"accumulate(%s) \# EscapeSequence\n" % @lexeme.to_s.dump
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end # class WalrusGrammar
|
|
29
|
-
end # Walrus
|
|
30
|
-
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that the class has been defined prior to extending it
|
|
16
|
-
require 'ostruct'
|
|
17
|
-
|
|
18
|
-
module Walrus
|
|
19
|
-
class WalrusGrammar
|
|
20
|
-
|
|
21
|
-
class ImportDirective
|
|
22
|
-
|
|
23
|
-
# Returns an OpenStruct encapsulating information about the receiver for use by the compiler
|
|
24
|
-
def compile(options = {})
|
|
25
|
-
info = OpenStruct.new
|
|
26
|
-
path = Pathname.new @class_name.lexeme.to_s
|
|
27
|
-
|
|
28
|
-
if path.absolute?
|
|
29
|
-
# it will work just fine as it is
|
|
30
|
-
info.class_name = path.basename.to_s.to_class_name
|
|
31
|
-
info.require_line = "require '#{path.to_s}'"
|
|
32
|
-
else
|
|
33
|
-
dir, base = path.split
|
|
34
|
-
info.class_name = base.to_s.to_class_name
|
|
35
|
-
if dir.to_s == '.'
|
|
36
|
-
# desired template is in the same directory
|
|
37
|
-
info.require_line = "require File.join(File.dirname(__FILE__), '#{base.to_s}').to_s"
|
|
38
|
-
else
|
|
39
|
-
# desired template is in a relative directory
|
|
40
|
-
info.require_line = "require File.join(File.dirname(__FILE__), '#{dir.to_s}', '#{base.to_s}').to_s"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
info
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end # class ImportDirective
|
|
47
|
-
|
|
48
|
-
end # class WalrusGrammar
|
|
49
|
-
end # Walrus
|
|
50
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that the class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class IncludeDirective
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
inner, outer = options[:compiler_instance].compile_subtree(subtree)
|
|
24
|
-
inner = [] if inner.nil?
|
|
25
|
-
inner.unshift "\# Include (start): #{file_name.to_s}:\n"
|
|
26
|
-
[inner, outer]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end # class IncludeDirective
|
|
30
|
-
|
|
31
|
-
end # class WalrusGrammar
|
|
32
|
-
end # Walrus
|
|
33
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class InstanceVariable
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
@lexeme.source_text
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end # class InstanceVariable
|
|
27
|
-
|
|
28
|
-
end # class WalrusGrammar
|
|
29
|
-
end # Walrus
|
|
30
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class Literal
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
@lexeme.source_text
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end # class Literal
|
|
27
|
-
|
|
28
|
-
end # class WalrusGrammar
|
|
29
|
-
end # Walrus
|
|
30
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Copyright 2007 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
|
-
#
|
|
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/>.
|
|
14
|
-
|
|
15
|
-
require 'walrus/parser.rb' # make sure that RawText class has been defined prior to extending it
|
|
16
|
-
|
|
17
|
-
module Walrus
|
|
18
|
-
class WalrusGrammar
|
|
19
|
-
|
|
20
|
-
class MessageExpression
|
|
21
|
-
|
|
22
|
-
def compile(options = {})
|
|
23
|
-
# simple case
|
|
24
|
-
@target.source_text + '.' + @message.source_text
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end # class AssignmentExpression
|
|
28
|
-
|
|
29
|
-
end # class WalrusGrammar
|
|
30
|
-
end # Walrus
|
|
31
|
-
|