metal 0.0.2 → 0.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/Manifest.txt +14 -1
- data/bin/metal +63 -16
- data/bin/metal-run +16 -13
- data/config/hoe.rb +4 -2
- data/ext/metal/boot/metal_boot.h +32 -0
- data/{lib/metal/boot.metal → ext/metal/boot/metal_boot.metal} +40 -53
- data/ext/metal/boot/metal_boot.mm +1294 -0
- data/ext/metal/boot/metal_boot_extconf.rb +16 -0
- data/ext/metal/boot/metal_boot_rb.mm +20 -0
- data/ext/metal/runtime/extconf.rb +35 -0
- data/ext/metal/runtime/input.mm +99 -0
- data/ext/metal/runtime/rbinit.mm +17 -0
- data/ext/metal/runtime/runtime.mm +660 -0
- data/include/metal.h +4 -0
- data/include/metal/exception.h +15 -0
- data/include/metal/input.h +42 -0
- data/include/metal/rbcode.h +24 -0
- data/include/metal/runtime.h +97 -0
- data/lib/metal/boot.rb +1 -353
- data/lib/metal/generator.rb +313 -203
- data/lib/metal/runtime.rb +1 -386
- data/lib/metal/version.rb +1 -1
- metadata +32 -8
data/Manifest.txt
CHANGED
|
@@ -6,8 +6,21 @@ bin/metal
|
|
|
6
6
|
bin/metal-run
|
|
7
7
|
config/hoe.rb
|
|
8
8
|
config/requirements.rb
|
|
9
|
+
ext/metal/boot/metal_boot.h
|
|
10
|
+
ext/metal/boot/metal_boot.metal
|
|
11
|
+
ext/metal/boot/metal_boot.mm
|
|
12
|
+
ext/metal/boot/metal_boot_extconf.rb
|
|
13
|
+
ext/metal/boot/metal_boot_rb.mm
|
|
14
|
+
ext/metal/runtime/extconf.rb
|
|
15
|
+
ext/metal/runtime/input.mm
|
|
16
|
+
ext/metal/runtime/rbinit.mm
|
|
17
|
+
ext/metal/runtime/runtime.mm
|
|
18
|
+
include/metal.h
|
|
19
|
+
include/metal/exception.h
|
|
20
|
+
include/metal/input.h
|
|
21
|
+
include/metal/rbcode.h
|
|
22
|
+
include/metal/runtime.h
|
|
9
23
|
lib/metal.rb
|
|
10
|
-
lib/metal/boot.metal
|
|
11
24
|
lib/metal/boot.rb
|
|
12
25
|
lib/metal/generator.rb
|
|
13
26
|
lib/metal/runtime.rb
|
data/bin/metal
CHANGED
|
@@ -1,41 +1,88 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
require 'metal'
|
|
3
|
+
require 'metal/version'
|
|
4
|
+
|
|
2
5
|
require 'optparse'
|
|
3
6
|
|
|
4
7
|
opts = {
|
|
5
|
-
:
|
|
8
|
+
:name => nil,
|
|
9
|
+
:syntax_check => false,
|
|
10
|
+
:no_compile => false,
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
op = OptionParser.new
|
|
9
14
|
|
|
10
|
-
require 'metal/version'
|
|
11
15
|
op.version = Metal::VERSION::STRING
|
|
12
16
|
|
|
13
|
-
op.on('-
|
|
14
|
-
opts[:
|
|
17
|
+
op.on('-n NAME', 'output library name') {|v|
|
|
18
|
+
opts[:name] = v
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
op.on('-s', 'syntax check only') {
|
|
22
|
+
opts[:syntax_check] = true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
op.on('-E', 'omit compiling library') {
|
|
26
|
+
opts[:no_compile] = true
|
|
15
27
|
}
|
|
28
|
+
|
|
16
29
|
op.banner = "#{op.banner} <source.metal>"
|
|
17
30
|
op.parse!(ARGV)
|
|
18
31
|
|
|
19
32
|
if ARGV.length != 1
|
|
33
|
+
# Argument error
|
|
20
34
|
puts op.to_s
|
|
21
35
|
exit 1
|
|
22
36
|
end
|
|
37
|
+
|
|
23
38
|
src = ARGV[0]
|
|
39
|
+
name = opts[:name] || File.basename(src, ".metal")
|
|
24
40
|
|
|
25
|
-
require 'metal'
|
|
26
|
-
|
|
27
|
-
require 'metal/boot'
|
|
28
|
-
end
|
|
41
|
+
require 'metal/generator'
|
|
42
|
+
require 'metal/boot'
|
|
29
43
|
|
|
30
44
|
parser = MetalParser.new
|
|
31
45
|
result = parser.parse File.read(src)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
|
|
47
|
+
exit 0 if opts[:syntax_check]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
File.open("#{name}.mm", "wb") {|source|
|
|
51
|
+
File.open("#{name}.h", "wb") {|header|
|
|
52
|
+
File.open("#{name}_rb.mm", "wb") {|rbcode|
|
|
53
|
+
result.generate(name, source, header, rbcode)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
inc_dir = File.expand_path File.join(File.dirname(__FILE__), '../include')
|
|
59
|
+
|
|
60
|
+
File.open("#{name}_extconf.rb", "wb") {|file|
|
|
61
|
+
file.write <<EOF
|
|
62
|
+
require 'mkmf'
|
|
63
|
+
|
|
64
|
+
begin
|
|
65
|
+
CXX_EXT << 'mm' unless CXX_EXT.include?('mm')
|
|
66
|
+
rescue
|
|
40
67
|
end
|
|
41
68
|
|
|
69
|
+
dir_config('metal')
|
|
70
|
+
|
|
71
|
+
$CFLAGS << " -I. -I#{inc_dir} #{ENV['CFLAGS']} -Wall -g"
|
|
72
|
+
$libs << " -lobjc"
|
|
73
|
+
|
|
74
|
+
$objs = %w[#{name}.o #{name}_rb.o]
|
|
75
|
+
$srcs = %w[#{name}.mm #{name}_rb.mm]
|
|
76
|
+
|
|
77
|
+
create_makefile('#{name}')
|
|
78
|
+
EOF
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exit 0 if opts[:no_compile]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
load "#{name}_extconf.rb"
|
|
85
|
+
|
|
86
|
+
#system(ENV['make'] || 'make')
|
|
87
|
+
system( (ENV['make'] || 'make') + " -j2")
|
|
88
|
+
|
data/bin/metal-run
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
if ARGV.length
|
|
4
|
-
puts "Usage: #{File.basename($0)} <
|
|
3
|
+
if ARGV.length < 2
|
|
4
|
+
puts "Usage: #{File.basename($0)} <parser.so/bundle>+ <target>"
|
|
5
5
|
exit 1
|
|
6
6
|
end
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
target = ARGV.pop
|
|
8
|
+
libs = ARGV
|
|
9
9
|
|
|
10
|
-
require 'rubygems'
|
|
11
10
|
require 'metal'
|
|
11
|
+
require 'metal/generator'
|
|
12
12
|
|
|
13
13
|
before = Object.constants
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
libs.each {|lib|
|
|
16
|
+
require lib
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
after = Object.constants
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
parsers = (after - before) \
|
|
19
23
|
.map {|c| Object.const_get(c) } \
|
|
20
|
-
.select {|c| c
|
|
21
|
-
.select {|c| c.public_instance_methods.map{|m|m.to_sym}.include?(:
|
|
22
|
-
.sort_by {|c| c.ancestors.length }
|
|
23
|
-
.reverse
|
|
24
|
+
.select {|c| c < Metal::ParserBase } \
|
|
25
|
+
.select {|c| c.public_instance_methods.map{|m|m.to_sym}.include?(:parse) } \
|
|
26
|
+
.sort_by {|c| -c.ancestors.length }
|
|
24
27
|
|
|
25
28
|
if parsers.empty?
|
|
26
|
-
puts "Can't find parser in #{
|
|
29
|
+
puts "Can't find parser in #{libs.join(', ')}."
|
|
27
30
|
exit 1
|
|
28
31
|
end
|
|
29
32
|
|
|
@@ -32,10 +35,10 @@ $stderr.puts "Using #{first}"
|
|
|
32
35
|
|
|
33
36
|
if target == '-'
|
|
34
37
|
$stderr.puts "Using standard input as input."
|
|
35
|
-
input = $stdin
|
|
38
|
+
input = $stdin.read
|
|
36
39
|
elsif File.file?(target)
|
|
37
40
|
$stderr.puts "Using #{target} file as input."
|
|
38
|
-
input = File.
|
|
41
|
+
input = File.read(target)
|
|
39
42
|
else
|
|
40
43
|
$stderr.puts "Using '#{target}' as input."
|
|
41
44
|
input = target
|
data/config/hoe.rb
CHANGED
|
@@ -63,8 +63,10 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
|
63
63
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
64
64
|
#p.extra_deps = EXTRA_DEPENDENCIES
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
p.spec_extras = { # A hash of extra values to set in the gemspec.
|
|
67
|
+
:extensions => %w[ext/metal/runtime/extconf.rb ext/metal/boot/metal_boot_extconf.rb]
|
|
68
|
+
}
|
|
69
|
+
end
|
|
68
70
|
|
|
69
71
|
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
|
70
72
|
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#import "metal/runtime.h"
|
|
2
|
+
@interface MetalParser : MetalParserBase
|
|
3
|
+
-(VALUE)rule_main:(Metal::Context*)ctx;
|
|
4
|
+
-(VALUE)rule_meta:(Metal::Context*)ctx;
|
|
5
|
+
-(VALUE)rule_grammar:(Metal::Context*)ctx;
|
|
6
|
+
-(VALUE)rule_precode:(Metal::Context*)ctx;
|
|
7
|
+
-(VALUE)rule_extend_attr:(Metal::Context*)ctx;
|
|
8
|
+
-(VALUE)rule_category_attr:(Metal::Context*)ctx;
|
|
9
|
+
-(VALUE)rule_rule:(Metal::Context*)ctx;
|
|
10
|
+
-(VALUE)rule_token:(Metal::Context*)ctx;
|
|
11
|
+
-(VALUE)rule_or_set:(Metal::Context*)ctx;
|
|
12
|
+
-(VALUE)rule_and_set:(Metal::Context*)ctx;
|
|
13
|
+
-(VALUE)rule_expr:(Metal::Context*)ctx;
|
|
14
|
+
-(VALUE)rule_var:(Metal::Context*)ctx;
|
|
15
|
+
-(VALUE)rule_iter:(Metal::Context*)ctx;
|
|
16
|
+
-(VALUE)rule_pred:(Metal::Context*)ctx;
|
|
17
|
+
-(VALUE)rule_literal:(Metal::Context*)ctx;
|
|
18
|
+
-(VALUE)rule_call_rule:(Metal::Context*)ctx;
|
|
19
|
+
-(VALUE)rule_other_call:(Metal::Context*)ctx;
|
|
20
|
+
-(VALUE)rule_apply_args:(Metal::Context*)ctx;
|
|
21
|
+
-(VALUE)rule_action:(Metal::Context*)ctx;
|
|
22
|
+
-(VALUE)rule_where:(Metal::Context*)ctx;
|
|
23
|
+
-(VALUE)rule_rule_name:(Metal::Context*)ctx;
|
|
24
|
+
-(VALUE)rule_var_name:(Metal::Context*)ctx;
|
|
25
|
+
-(VALUE)rule_grammar_name:(Metal::Context*)ctx;
|
|
26
|
+
-(VALUE)rule_dq_string:(Metal::Context*)ctx;
|
|
27
|
+
-(VALUE)rule_q_string:(Metal::Context*)ctx;
|
|
28
|
+
-(VALUE)rule_charclass:(Metal::Context*)ctx;
|
|
29
|
+
-(VALUE)rule_s:(Metal::Context*)ctx;
|
|
30
|
+
-(VALUE)rule_fs:(Metal::Context*)ctx;
|
|
31
|
+
-(VALUE)rule_comment:(Metal::Context*)ctx;
|
|
32
|
+
@end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
#
|
|
2
2
|
# Metal Bootstrap Parser
|
|
3
3
|
#
|
|
4
4
|
# Copyright (C) 2008 FURUHASHI Sadayuki
|
|
@@ -15,59 +15,43 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
#
|
|
18
|
-
require 'metal/generator'
|
|
19
|
-
@}
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
MetalParser {
|
|
23
|
-
|
|
21
|
+
{| include Metal::Generator |}
|
|
24
22
|
|
|
25
23
|
-main
|
|
26
|
-
|
|
24
|
+
meta:m s end {* m *}
|
|
27
25
|
|
|
28
26
|
-meta
|
|
29
|
-
|
|
27
|
+
(s grammar / s precode)*:xs {* Meta.new(xs) *}
|
|
30
28
|
|
|
31
|
-
-meta_command
|
|
32
|
-
s precode
|
|
33
|
-
|
|
34
29
|
-grammar
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
-interface_attr
|
|
39
|
-
'module' fs {* true *}
|
|
40
|
-
/ 'class' fs {* false *}
|
|
41
|
-
/ {* false *}
|
|
42
|
-
|
|
43
|
-
-extend_attr
|
|
44
|
-
'<' s grammar_name
|
|
45
|
-
|
|
46
|
-
-grammar_body
|
|
47
|
-
s (rule / grammar_command)*
|
|
48
|
-
|
|
49
|
-
-grammar_command
|
|
50
|
-
precode
|
|
51
|
-
/ mixin
|
|
30
|
+
grammar_name:n s (extend_attr / category_attr)?:ec s
|
|
31
|
+
'{' (s rule / s token / s precode)*:b s '}'
|
|
32
|
+
{* Grammar.new(n, b, *ec) *}
|
|
52
33
|
|
|
53
34
|
-precode
|
|
54
35
|
'@{' (!'@' . / '@' !'}' {*'@'*})+:s '@}' s {* Precode.new(s.join) *}
|
|
36
|
+
/ '{|' (!'|' . / '|' !'}' {*'@'*})+:s '|}' s {* Precode.new(s.join) *}
|
|
37
|
+
|
|
38
|
+
-extend_attr
|
|
39
|
+
'<' s grammar_name:e {* [e, nil] *}
|
|
55
40
|
|
|
56
|
-
-
|
|
57
|
-
'
|
|
41
|
+
-category_attr
|
|
42
|
+
'(' s grammar_name:c s ')' {* [nil, c] *}
|
|
58
43
|
|
|
59
|
-
-scoped_grammar_name
|
|
60
|
-
('::'?:s grammar_name:n {*"#{s}#{n}"*})+:xs {* xs.join *}
|
|
61
44
|
|
|
62
45
|
-rule
|
|
63
|
-
'-' s rule_name:n
|
|
64
|
-
{* Rule.new(n, r
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
|
|
46
|
+
'-' s rule_name:n fs or_set:r s
|
|
47
|
+
{* Rule.new(n, r) *}
|
|
48
|
+
|
|
49
|
+
-token
|
|
50
|
+
'NO MATCH' # FIXME
|
|
68
51
|
|
|
52
|
+
|
|
69
53
|
-or_set
|
|
70
|
-
and_set:x s (s '/' and_set)*:xs
|
|
54
|
+
('/' s)? and_set:x s (s '/' and_set)*:xs
|
|
71
55
|
{* OrSet.new([x] + xs) *}
|
|
72
56
|
|
|
73
57
|
-and_set
|
|
@@ -75,41 +59,40 @@ MetalParser {
|
|
|
75
59
|
{* AndSet.new(xs || []) *}
|
|
76
60
|
|
|
77
61
|
-expr
|
|
78
|
-
pred:p iter
|
|
62
|
+
pred:p iter?:i var?:v {* Expression.new(p, i, v) *}
|
|
63
|
+
|
|
64
|
+
-var
|
|
65
|
+
':' var_name:n {* n *}
|
|
66
|
+
|
|
67
|
+
-iter
|
|
68
|
+
'*' {* :many *}
|
|
69
|
+
/ '+' {* :many1 *}
|
|
70
|
+
/ '?' {* :may *}
|
|
79
71
|
|
|
80
72
|
-pred
|
|
81
73
|
'!' pred:p {* PredNot.new(p) *}
|
|
82
74
|
/ '&' literal:f {* PredLookahead.new(f) *}
|
|
83
75
|
/ literal
|
|
84
76
|
|
|
85
|
-
-iter :x
|
|
86
|
-
'*' {* IterMany.new(x) *}
|
|
87
|
-
/ '+' {* IterMany1.new(x) *}
|
|
88
|
-
/ '?' {* IterMay.new(x) *}
|
|
89
|
-
/ {* x *}
|
|
90
|
-
|
|
91
77
|
-literal
|
|
92
|
-
|
|
78
|
+
call_rule
|
|
93
79
|
/ action
|
|
94
80
|
/ where
|
|
95
81
|
/ q_string:s {* LiteralQuotedToken.new(s) *}
|
|
96
82
|
/ dq_string:s {* LiteralToken.new(s) *}
|
|
97
|
-
/ charclass:s {*
|
|
83
|
+
/ charclass:s {* LiteralCharclass.new(s) *}
|
|
98
84
|
/ '.' {* LiteralAny.new *}
|
|
99
85
|
/ other_call
|
|
100
86
|
/ '(' s or_set:r s ')' {* r *}
|
|
101
|
-
|
|
102
|
-
-var
|
|
103
|
-
':' var_name:n {* n *}
|
|
104
87
|
|
|
105
|
-
-
|
|
88
|
+
-call_rule
|
|
106
89
|
rule_name:r apply_args?:a {*
|
|
107
90
|
if r == "super"
|
|
108
|
-
|
|
109
|
-
elsif r == "
|
|
110
|
-
|
|
91
|
+
LiteralSuper.new(a)
|
|
92
|
+
elsif r == "end"
|
|
93
|
+
LiteralEnd.new # FIXME args
|
|
111
94
|
else
|
|
112
|
-
|
|
95
|
+
LiteralApply.new(r, a || [])
|
|
113
96
|
end *}
|
|
114
97
|
|
|
115
98
|
-other_call
|
|
@@ -120,9 +103,11 @@ MetalParser {
|
|
|
120
103
|
|
|
121
104
|
-action
|
|
122
105
|
'{*' (!'*' . / '*' !'}' {*'*'*})+:s '*}' {* Action.new(s.join) *}
|
|
106
|
+
/ '{|' (!'|' . / '|' !'}' {*'*'*})+:s '|}' {* Action.new(s.join) *}
|
|
123
107
|
|
|
124
108
|
-where
|
|
125
109
|
'?{*' (!'*' . / '*' !'}' {*'*'*})+:s '*}' {* Where.new(s.join) *}
|
|
110
|
+
/ '?{|' (!'|' . / '|' !'}' {*'*'*})+:s '|}' {* Where.new(s.join) *}
|
|
126
111
|
|
|
127
112
|
-rule_name
|
|
128
113
|
[a-z_]:x [a-zA-Z_0-9]*:xs {* ([x] + xs).join *}
|
|
@@ -153,3 +138,5 @@ MetalParser {
|
|
|
153
138
|
}
|
|
154
139
|
|
|
155
140
|
|
|
141
|
+
# vim: ft=ruby syntax=conf
|
|
142
|
+
|
|
@@ -0,0 +1,1294 @@
|
|
|
1
|
+
#import "metal_boot.h"
|
|
2
|
+
using namespace Metal;
|
|
3
|
+
static param_t const PARAM_a = param_lookup("a");
|
|
4
|
+
static param_t const PARAM_b = param_lookup("b");
|
|
5
|
+
static param_t const PARAM_c = param_lookup("c");
|
|
6
|
+
static param_t const PARAM_e = param_lookup("e");
|
|
7
|
+
static param_t const PARAM_ec = param_lookup("ec");
|
|
8
|
+
static param_t const PARAM_f = param_lookup("f");
|
|
9
|
+
static param_t const PARAM_g = param_lookup("g");
|
|
10
|
+
static param_t const PARAM_i = param_lookup("i");
|
|
11
|
+
static param_t const PARAM_m = param_lookup("m");
|
|
12
|
+
static param_t const PARAM_n = param_lookup("n");
|
|
13
|
+
static param_t const PARAM_p = param_lookup("p");
|
|
14
|
+
static param_t const PARAM_r = param_lookup("r");
|
|
15
|
+
static param_t const PARAM_s = param_lookup("s");
|
|
16
|
+
static param_t const PARAM_v = param_lookup("v");
|
|
17
|
+
static param_t const PARAM_x = param_lookup("x");
|
|
18
|
+
static param_t const PARAM_xs = param_lookup("xs");
|
|
19
|
+
@implementation MetalParser
|
|
20
|
+
-(VALUE)rule_main:(Context*)ctx {
|
|
21
|
+
return ({
|
|
22
|
+
Env env;
|
|
23
|
+
env[PARAM_m] = ({
|
|
24
|
+
ctx->apply(@selector(rule_meta:));
|
|
25
|
+
});
|
|
26
|
+
ctx->apply(@selector(rule_s:));
|
|
27
|
+
ctx->act_end();
|
|
28
|
+
ctx->act_run(env," m ",3);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
-(VALUE)rule_meta:(Context*)ctx {
|
|
32
|
+
return ({
|
|
33
|
+
Env env;
|
|
34
|
+
env[PARAM_xs] = ({
|
|
35
|
+
struct rule_meta_1_t : Lambda {
|
|
36
|
+
rule_meta_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
37
|
+
VALUE call() {
|
|
38
|
+
return ({
|
|
39
|
+
struct rule_meta_2_t : Lambda {
|
|
40
|
+
rule_meta_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
41
|
+
VALUE call() {
|
|
42
|
+
return ({
|
|
43
|
+
ctx->apply(@selector(rule_s:));
|
|
44
|
+
ctx->apply(@selector(rule_grammar:));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
} rule_meta_2(ctx, env);
|
|
48
|
+
struct rule_meta_3_t : Lambda {
|
|
49
|
+
rule_meta_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
50
|
+
VALUE call() {
|
|
51
|
+
return ({
|
|
52
|
+
ctx->apply(@selector(rule_s:));
|
|
53
|
+
ctx->apply(@selector(rule_precode:));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
} rule_meta_3(ctx, env);
|
|
57
|
+
Lambda* rule_meta_2_or[] = {
|
|
58
|
+
&rule_meta_2,
|
|
59
|
+
&rule_meta_3,
|
|
60
|
+
NULL
|
|
61
|
+
};
|
|
62
|
+
ctx->act_or(rule_meta_2_or);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} rule_meta_1(ctx, env);
|
|
66
|
+
ctx->act_many(&rule_meta_1);
|
|
67
|
+
});
|
|
68
|
+
ctx->act_run(env," Meta.new(xs) ",14);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
-(VALUE)rule_grammar:(Context*)ctx {
|
|
72
|
+
return ({
|
|
73
|
+
Env env;
|
|
74
|
+
env[PARAM_n] = ({
|
|
75
|
+
ctx->apply(@selector(rule_grammar_name:));
|
|
76
|
+
});
|
|
77
|
+
ctx->apply(@selector(rule_s:));
|
|
78
|
+
env[PARAM_ec] = ({
|
|
79
|
+
struct rule_grammar_1_t : Lambda {
|
|
80
|
+
rule_grammar_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
81
|
+
VALUE call() {
|
|
82
|
+
return ({
|
|
83
|
+
struct rule_grammar_2_t : Lambda {
|
|
84
|
+
rule_grammar_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
85
|
+
VALUE call() {
|
|
86
|
+
return ({
|
|
87
|
+
ctx->apply(@selector(rule_extend_attr:));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
} rule_grammar_2(ctx, env);
|
|
91
|
+
struct rule_grammar_3_t : Lambda {
|
|
92
|
+
rule_grammar_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
93
|
+
VALUE call() {
|
|
94
|
+
return ({
|
|
95
|
+
ctx->apply(@selector(rule_category_attr:));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
} rule_grammar_3(ctx, env);
|
|
99
|
+
Lambda* rule_grammar_2_or[] = {
|
|
100
|
+
&rule_grammar_2,
|
|
101
|
+
&rule_grammar_3,
|
|
102
|
+
NULL
|
|
103
|
+
};
|
|
104
|
+
ctx->act_or(rule_grammar_2_or);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} rule_grammar_1(ctx, env);
|
|
108
|
+
ctx->act_may(&rule_grammar_1);
|
|
109
|
+
});
|
|
110
|
+
ctx->apply(@selector(rule_s:));
|
|
111
|
+
ctx->act_char("{",1);
|
|
112
|
+
env[PARAM_b] = ({
|
|
113
|
+
struct rule_grammar_4_t : Lambda {
|
|
114
|
+
rule_grammar_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
115
|
+
VALUE call() {
|
|
116
|
+
return ({
|
|
117
|
+
struct rule_grammar_5_t : Lambda {
|
|
118
|
+
rule_grammar_5_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
119
|
+
VALUE call() {
|
|
120
|
+
return ({
|
|
121
|
+
ctx->apply(@selector(rule_s:));
|
|
122
|
+
ctx->apply(@selector(rule_rule:));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
} rule_grammar_5(ctx, env);
|
|
126
|
+
struct rule_grammar_6_t : Lambda {
|
|
127
|
+
rule_grammar_6_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
128
|
+
VALUE call() {
|
|
129
|
+
return ({
|
|
130
|
+
ctx->apply(@selector(rule_s:));
|
|
131
|
+
ctx->apply(@selector(rule_token:));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} rule_grammar_6(ctx, env);
|
|
135
|
+
struct rule_grammar_7_t : Lambda {
|
|
136
|
+
rule_grammar_7_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
137
|
+
VALUE call() {
|
|
138
|
+
return ({
|
|
139
|
+
ctx->apply(@selector(rule_s:));
|
|
140
|
+
ctx->apply(@selector(rule_precode:));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
} rule_grammar_7(ctx, env);
|
|
144
|
+
Lambda* rule_grammar_5_or[] = {
|
|
145
|
+
&rule_grammar_5,
|
|
146
|
+
&rule_grammar_6,
|
|
147
|
+
&rule_grammar_7,
|
|
148
|
+
NULL
|
|
149
|
+
};
|
|
150
|
+
ctx->act_or(rule_grammar_5_or);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
} rule_grammar_4(ctx, env);
|
|
154
|
+
ctx->act_many(&rule_grammar_4);
|
|
155
|
+
});
|
|
156
|
+
ctx->apply(@selector(rule_s:));
|
|
157
|
+
ctx->act_char("}",1);
|
|
158
|
+
ctx->act_run(env," Grammar.new(n, b, *ec) ",24);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
-(VALUE)rule_precode:(Context*)ctx {
|
|
162
|
+
return ({
|
|
163
|
+
Env env;
|
|
164
|
+
struct rule_precode_1_t : Lambda {
|
|
165
|
+
rule_precode_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
166
|
+
VALUE call() {
|
|
167
|
+
return ({
|
|
168
|
+
ctx->act_token("@{",2);
|
|
169
|
+
env[PARAM_s] = ({
|
|
170
|
+
struct rule_precode_2_t : Lambda {
|
|
171
|
+
rule_precode_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
172
|
+
VALUE call() {
|
|
173
|
+
return ({
|
|
174
|
+
struct rule_precode_3_t : Lambda {
|
|
175
|
+
rule_precode_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
176
|
+
VALUE call() {
|
|
177
|
+
return ({
|
|
178
|
+
struct rule_precode_4_t : Lambda {
|
|
179
|
+
rule_precode_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
180
|
+
VALUE call() {
|
|
181
|
+
return ({
|
|
182
|
+
ctx->act_char("@",1);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} rule_precode_4(ctx, env);
|
|
186
|
+
ctx->act_not(&rule_precode_4);
|
|
187
|
+
ctx->act_any();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
} rule_precode_3(ctx, env);
|
|
191
|
+
struct rule_precode_5_t : Lambda {
|
|
192
|
+
rule_precode_5_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
193
|
+
VALUE call() {
|
|
194
|
+
return ({
|
|
195
|
+
ctx->act_char("@",1);
|
|
196
|
+
struct rule_precode_6_t : Lambda {
|
|
197
|
+
rule_precode_6_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
198
|
+
VALUE call() {
|
|
199
|
+
return ({
|
|
200
|
+
ctx->act_char("}",1);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
} rule_precode_6(ctx, env);
|
|
204
|
+
ctx->act_not(&rule_precode_6);
|
|
205
|
+
ctx->act_run(env,"'@'",3);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
} rule_precode_5(ctx, env);
|
|
209
|
+
Lambda* rule_precode_3_or[] = {
|
|
210
|
+
&rule_precode_3,
|
|
211
|
+
&rule_precode_5,
|
|
212
|
+
NULL
|
|
213
|
+
};
|
|
214
|
+
ctx->act_or(rule_precode_3_or);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
} rule_precode_2(ctx, env);
|
|
218
|
+
ctx->act_many1(&rule_precode_2);
|
|
219
|
+
});
|
|
220
|
+
ctx->act_token("@}",2);
|
|
221
|
+
ctx->apply(@selector(rule_s:));
|
|
222
|
+
ctx->act_run(env," Precode.new(s.join) ",21);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
} rule_precode_1(ctx, env);
|
|
226
|
+
struct rule_precode_7_t : Lambda {
|
|
227
|
+
rule_precode_7_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
228
|
+
VALUE call() {
|
|
229
|
+
return ({
|
|
230
|
+
ctx->act_token("{|",2);
|
|
231
|
+
env[PARAM_s] = ({
|
|
232
|
+
struct rule_precode_8_t : Lambda {
|
|
233
|
+
rule_precode_8_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
234
|
+
VALUE call() {
|
|
235
|
+
return ({
|
|
236
|
+
struct rule_precode_9_t : Lambda {
|
|
237
|
+
rule_precode_9_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
238
|
+
VALUE call() {
|
|
239
|
+
return ({
|
|
240
|
+
struct rule_precode_10_t : Lambda {
|
|
241
|
+
rule_precode_10_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
242
|
+
VALUE call() {
|
|
243
|
+
return ({
|
|
244
|
+
ctx->act_char("|",1);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} rule_precode_10(ctx, env);
|
|
248
|
+
ctx->act_not(&rule_precode_10);
|
|
249
|
+
ctx->act_any();
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
} rule_precode_9(ctx, env);
|
|
253
|
+
struct rule_precode_11_t : Lambda {
|
|
254
|
+
rule_precode_11_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
255
|
+
VALUE call() {
|
|
256
|
+
return ({
|
|
257
|
+
ctx->act_char("|",1);
|
|
258
|
+
struct rule_precode_12_t : Lambda {
|
|
259
|
+
rule_precode_12_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
260
|
+
VALUE call() {
|
|
261
|
+
return ({
|
|
262
|
+
ctx->act_char("}",1);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
} rule_precode_12(ctx, env);
|
|
266
|
+
ctx->act_not(&rule_precode_12);
|
|
267
|
+
ctx->act_run(env,"'@'",3);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
} rule_precode_11(ctx, env);
|
|
271
|
+
Lambda* rule_precode_9_or[] = {
|
|
272
|
+
&rule_precode_9,
|
|
273
|
+
&rule_precode_11,
|
|
274
|
+
NULL
|
|
275
|
+
};
|
|
276
|
+
ctx->act_or(rule_precode_9_or);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
} rule_precode_8(ctx, env);
|
|
280
|
+
ctx->act_many1(&rule_precode_8);
|
|
281
|
+
});
|
|
282
|
+
ctx->act_token("|}",2);
|
|
283
|
+
ctx->apply(@selector(rule_s:));
|
|
284
|
+
ctx->act_run(env," Precode.new(s.join) ",21);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
} rule_precode_7(ctx, env);
|
|
288
|
+
Lambda* rule_precode_1_or[] = {
|
|
289
|
+
&rule_precode_1,
|
|
290
|
+
&rule_precode_7,
|
|
291
|
+
NULL
|
|
292
|
+
};
|
|
293
|
+
ctx->act_or(rule_precode_1_or);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
-(VALUE)rule_extend_attr:(Context*)ctx {
|
|
297
|
+
return ({
|
|
298
|
+
Env env;
|
|
299
|
+
ctx->act_char("<",1);
|
|
300
|
+
ctx->apply(@selector(rule_s:));
|
|
301
|
+
env[PARAM_e] = ({
|
|
302
|
+
ctx->apply(@selector(rule_grammar_name:));
|
|
303
|
+
});
|
|
304
|
+
ctx->act_run(env," [e, nil] ",10);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
-(VALUE)rule_category_attr:(Context*)ctx {
|
|
308
|
+
return ({
|
|
309
|
+
Env env;
|
|
310
|
+
ctx->act_char("(",1);
|
|
311
|
+
ctx->apply(@selector(rule_s:));
|
|
312
|
+
env[PARAM_c] = ({
|
|
313
|
+
ctx->apply(@selector(rule_grammar_name:));
|
|
314
|
+
});
|
|
315
|
+
ctx->apply(@selector(rule_s:));
|
|
316
|
+
ctx->act_char(")",1);
|
|
317
|
+
ctx->act_run(env," [nil, c] ",10);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
-(VALUE)rule_rule:(Context*)ctx {
|
|
321
|
+
return ({
|
|
322
|
+
Env env;
|
|
323
|
+
ctx->act_char("-",1);
|
|
324
|
+
ctx->apply(@selector(rule_s:));
|
|
325
|
+
env[PARAM_n] = ({
|
|
326
|
+
ctx->apply(@selector(rule_rule_name:));
|
|
327
|
+
});
|
|
328
|
+
ctx->apply(@selector(rule_fs:));
|
|
329
|
+
env[PARAM_r] = ({
|
|
330
|
+
ctx->apply(@selector(rule_or_set:));
|
|
331
|
+
});
|
|
332
|
+
ctx->apply(@selector(rule_s:));
|
|
333
|
+
ctx->act_run(env," Rule.new(n, r) ",16);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
-(VALUE)rule_token:(Context*)ctx {
|
|
337
|
+
return ({
|
|
338
|
+
Env env;
|
|
339
|
+
ctx->act_token("NO MATCH",8);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
-(VALUE)rule_or_set:(Context*)ctx {
|
|
343
|
+
return ({
|
|
344
|
+
Env env;
|
|
345
|
+
struct rule_or_set_1_t : Lambda {
|
|
346
|
+
rule_or_set_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
347
|
+
VALUE call() {
|
|
348
|
+
return ({
|
|
349
|
+
ctx->act_char("/",1);
|
|
350
|
+
ctx->apply(@selector(rule_s:));
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
} rule_or_set_1(ctx, env);
|
|
354
|
+
ctx->act_may(&rule_or_set_1);
|
|
355
|
+
env[PARAM_x] = ({
|
|
356
|
+
ctx->apply(@selector(rule_and_set:));
|
|
357
|
+
});
|
|
358
|
+
ctx->apply(@selector(rule_s:));
|
|
359
|
+
env[PARAM_xs] = ({
|
|
360
|
+
struct rule_or_set_2_t : Lambda {
|
|
361
|
+
rule_or_set_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
362
|
+
VALUE call() {
|
|
363
|
+
return ({
|
|
364
|
+
ctx->apply(@selector(rule_s:));
|
|
365
|
+
ctx->act_char("/",1);
|
|
366
|
+
ctx->apply(@selector(rule_and_set:));
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
} rule_or_set_2(ctx, env);
|
|
370
|
+
ctx->act_many(&rule_or_set_2);
|
|
371
|
+
});
|
|
372
|
+
ctx->act_run(env," OrSet.new([x] + xs) ",21);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
-(VALUE)rule_and_set:(Context*)ctx {
|
|
376
|
+
return ({
|
|
377
|
+
Env env;
|
|
378
|
+
ctx->apply(@selector(rule_s:));
|
|
379
|
+
env[PARAM_xs] = ({
|
|
380
|
+
struct rule_and_set_1_t : Lambda {
|
|
381
|
+
rule_and_set_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
382
|
+
VALUE call() {
|
|
383
|
+
return ({
|
|
384
|
+
env[PARAM_x] = ({
|
|
385
|
+
ctx->apply(@selector(rule_expr:));
|
|
386
|
+
});
|
|
387
|
+
env[PARAM_xs] = ({
|
|
388
|
+
struct rule_and_set_2_t : Lambda {
|
|
389
|
+
rule_and_set_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
390
|
+
VALUE call() {
|
|
391
|
+
return ({
|
|
392
|
+
ctx->apply(@selector(rule_fs:));
|
|
393
|
+
ctx->apply(@selector(rule_expr:));
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
} rule_and_set_2(ctx, env);
|
|
397
|
+
ctx->act_many(&rule_and_set_2);
|
|
398
|
+
});
|
|
399
|
+
ctx->act_run(env,"[x]+xs",6);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
} rule_and_set_1(ctx, env);
|
|
403
|
+
ctx->act_may(&rule_and_set_1);
|
|
404
|
+
});
|
|
405
|
+
ctx->act_run(env," AndSet.new(xs || []) ",22);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
-(VALUE)rule_expr:(Context*)ctx {
|
|
409
|
+
return ({
|
|
410
|
+
Env env;
|
|
411
|
+
env[PARAM_p] = ({
|
|
412
|
+
ctx->apply(@selector(rule_pred:));
|
|
413
|
+
});
|
|
414
|
+
env[PARAM_i] = ({
|
|
415
|
+
struct rule_expr_1_t : Lambda {
|
|
416
|
+
rule_expr_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
417
|
+
VALUE call() {
|
|
418
|
+
return ({
|
|
419
|
+
ctx->apply(@selector(rule_iter:));
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
} rule_expr_1(ctx, env);
|
|
423
|
+
ctx->act_may(&rule_expr_1);
|
|
424
|
+
});
|
|
425
|
+
env[PARAM_v] = ({
|
|
426
|
+
struct rule_expr_2_t : Lambda {
|
|
427
|
+
rule_expr_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
428
|
+
VALUE call() {
|
|
429
|
+
return ({
|
|
430
|
+
ctx->apply(@selector(rule_var:));
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
} rule_expr_2(ctx, env);
|
|
434
|
+
ctx->act_may(&rule_expr_2);
|
|
435
|
+
});
|
|
436
|
+
ctx->act_run(env," Expression.new(p, i, v) ",25);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
-(VALUE)rule_var:(Context*)ctx {
|
|
440
|
+
return ({
|
|
441
|
+
Env env;
|
|
442
|
+
ctx->act_char(":",1);
|
|
443
|
+
env[PARAM_n] = ({
|
|
444
|
+
ctx->apply(@selector(rule_var_name:));
|
|
445
|
+
});
|
|
446
|
+
ctx->act_run(env," n ",3);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
-(VALUE)rule_iter:(Context*)ctx {
|
|
450
|
+
return ({
|
|
451
|
+
Env env;
|
|
452
|
+
struct rule_iter_1_t : Lambda {
|
|
453
|
+
rule_iter_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
454
|
+
VALUE call() {
|
|
455
|
+
return ({
|
|
456
|
+
ctx->act_char("*",1);
|
|
457
|
+
ctx->act_run(env," :many ",8);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
} rule_iter_1(ctx, env);
|
|
461
|
+
struct rule_iter_2_t : Lambda {
|
|
462
|
+
rule_iter_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
463
|
+
VALUE call() {
|
|
464
|
+
return ({
|
|
465
|
+
ctx->act_char("+",1);
|
|
466
|
+
ctx->act_run(env," :many1 ",8);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
} rule_iter_2(ctx, env);
|
|
470
|
+
struct rule_iter_3_t : Lambda {
|
|
471
|
+
rule_iter_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
472
|
+
VALUE call() {
|
|
473
|
+
return ({
|
|
474
|
+
ctx->act_char("?",1);
|
|
475
|
+
ctx->act_run(env," :may ",8);
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
} rule_iter_3(ctx, env);
|
|
479
|
+
Lambda* rule_iter_1_or[] = {
|
|
480
|
+
&rule_iter_1,
|
|
481
|
+
&rule_iter_2,
|
|
482
|
+
&rule_iter_3,
|
|
483
|
+
NULL
|
|
484
|
+
};
|
|
485
|
+
ctx->act_or(rule_iter_1_or);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
-(VALUE)rule_pred:(Context*)ctx {
|
|
489
|
+
return ({
|
|
490
|
+
Env env;
|
|
491
|
+
struct rule_pred_1_t : Lambda {
|
|
492
|
+
rule_pred_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
493
|
+
VALUE call() {
|
|
494
|
+
return ({
|
|
495
|
+
ctx->act_char("!",1);
|
|
496
|
+
env[PARAM_p] = ({
|
|
497
|
+
ctx->apply(@selector(rule_pred:));
|
|
498
|
+
});
|
|
499
|
+
ctx->act_run(env," PredNot.new(p) ",16);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
} rule_pred_1(ctx, env);
|
|
503
|
+
struct rule_pred_2_t : Lambda {
|
|
504
|
+
rule_pred_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
505
|
+
VALUE call() {
|
|
506
|
+
return ({
|
|
507
|
+
ctx->act_char("&",1);
|
|
508
|
+
env[PARAM_f] = ({
|
|
509
|
+
ctx->apply(@selector(rule_literal:));
|
|
510
|
+
});
|
|
511
|
+
ctx->act_run(env," PredLookahead.new(f) ",22);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
} rule_pred_2(ctx, env);
|
|
515
|
+
struct rule_pred_3_t : Lambda {
|
|
516
|
+
rule_pred_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
517
|
+
VALUE call() {
|
|
518
|
+
return ({
|
|
519
|
+
ctx->apply(@selector(rule_literal:));
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
} rule_pred_3(ctx, env);
|
|
523
|
+
Lambda* rule_pred_1_or[] = {
|
|
524
|
+
&rule_pred_1,
|
|
525
|
+
&rule_pred_2,
|
|
526
|
+
&rule_pred_3,
|
|
527
|
+
NULL
|
|
528
|
+
};
|
|
529
|
+
ctx->act_or(rule_pred_1_or);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
-(VALUE)rule_literal:(Context*)ctx {
|
|
533
|
+
return ({
|
|
534
|
+
Env env;
|
|
535
|
+
struct rule_literal_1_t : Lambda {
|
|
536
|
+
rule_literal_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
537
|
+
VALUE call() {
|
|
538
|
+
return ({
|
|
539
|
+
ctx->apply(@selector(rule_call_rule:));
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
} rule_literal_1(ctx, env);
|
|
543
|
+
struct rule_literal_2_t : Lambda {
|
|
544
|
+
rule_literal_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
545
|
+
VALUE call() {
|
|
546
|
+
return ({
|
|
547
|
+
ctx->apply(@selector(rule_action:));
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
} rule_literal_2(ctx, env);
|
|
551
|
+
struct rule_literal_3_t : Lambda {
|
|
552
|
+
rule_literal_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
553
|
+
VALUE call() {
|
|
554
|
+
return ({
|
|
555
|
+
ctx->apply(@selector(rule_where:));
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
} rule_literal_3(ctx, env);
|
|
559
|
+
struct rule_literal_4_t : Lambda {
|
|
560
|
+
rule_literal_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
561
|
+
VALUE call() {
|
|
562
|
+
return ({
|
|
563
|
+
env[PARAM_s] = ({
|
|
564
|
+
ctx->apply(@selector(rule_q_string:));
|
|
565
|
+
});
|
|
566
|
+
ctx->act_run(env," LiteralQuotedToken.new(s) ",27);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
} rule_literal_4(ctx, env);
|
|
570
|
+
struct rule_literal_5_t : Lambda {
|
|
571
|
+
rule_literal_5_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
572
|
+
VALUE call() {
|
|
573
|
+
return ({
|
|
574
|
+
env[PARAM_s] = ({
|
|
575
|
+
ctx->apply(@selector(rule_dq_string:));
|
|
576
|
+
});
|
|
577
|
+
ctx->act_run(env," LiteralToken.new(s) ",21);
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
} rule_literal_5(ctx, env);
|
|
581
|
+
struct rule_literal_6_t : Lambda {
|
|
582
|
+
rule_literal_6_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
583
|
+
VALUE call() {
|
|
584
|
+
return ({
|
|
585
|
+
env[PARAM_s] = ({
|
|
586
|
+
ctx->apply(@selector(rule_charclass:));
|
|
587
|
+
});
|
|
588
|
+
ctx->act_run(env," LiteralCharclass.new(s) ",25);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
} rule_literal_6(ctx, env);
|
|
592
|
+
struct rule_literal_7_t : Lambda {
|
|
593
|
+
rule_literal_7_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
594
|
+
VALUE call() {
|
|
595
|
+
return ({
|
|
596
|
+
ctx->act_char(".",1);
|
|
597
|
+
ctx->act_run(env," LiteralAny.new ",16);
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
} rule_literal_7(ctx, env);
|
|
601
|
+
struct rule_literal_8_t : Lambda {
|
|
602
|
+
rule_literal_8_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
603
|
+
VALUE call() {
|
|
604
|
+
return ({
|
|
605
|
+
ctx->apply(@selector(rule_other_call:));
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
} rule_literal_8(ctx, env);
|
|
609
|
+
struct rule_literal_9_t : Lambda {
|
|
610
|
+
rule_literal_9_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
611
|
+
VALUE call() {
|
|
612
|
+
return ({
|
|
613
|
+
ctx->act_char("(",1);
|
|
614
|
+
ctx->apply(@selector(rule_s:));
|
|
615
|
+
env[PARAM_r] = ({
|
|
616
|
+
ctx->apply(@selector(rule_or_set:));
|
|
617
|
+
});
|
|
618
|
+
ctx->apply(@selector(rule_s:));
|
|
619
|
+
ctx->act_char(")",1);
|
|
620
|
+
ctx->act_run(env," r ",3);
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
} rule_literal_9(ctx, env);
|
|
624
|
+
Lambda* rule_literal_1_or[] = {
|
|
625
|
+
&rule_literal_1,
|
|
626
|
+
&rule_literal_2,
|
|
627
|
+
&rule_literal_3,
|
|
628
|
+
&rule_literal_4,
|
|
629
|
+
&rule_literal_5,
|
|
630
|
+
&rule_literal_6,
|
|
631
|
+
&rule_literal_7,
|
|
632
|
+
&rule_literal_8,
|
|
633
|
+
&rule_literal_9,
|
|
634
|
+
NULL
|
|
635
|
+
};
|
|
636
|
+
ctx->act_or(rule_literal_1_or);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
-(VALUE)rule_call_rule:(Context*)ctx {
|
|
640
|
+
return ({
|
|
641
|
+
Env env;
|
|
642
|
+
env[PARAM_r] = ({
|
|
643
|
+
ctx->apply(@selector(rule_rule_name:));
|
|
644
|
+
});
|
|
645
|
+
env[PARAM_a] = ({
|
|
646
|
+
struct rule_call_rule_1_t : Lambda {
|
|
647
|
+
rule_call_rule_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
648
|
+
VALUE call() {
|
|
649
|
+
return ({
|
|
650
|
+
ctx->apply(@selector(rule_apply_args:));
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
} rule_call_rule_1(ctx, env);
|
|
654
|
+
ctx->act_may(&rule_call_rule_1);
|
|
655
|
+
});
|
|
656
|
+
ctx->act_run(env,"\n"
|
|
657
|
+
" if r == \"super\"\n"
|
|
658
|
+
" LiteralSuper.new(a)\n"
|
|
659
|
+
" elsif r == \"end\"\n"
|
|
660
|
+
" LiteralEnd.new # FIXME args\n"
|
|
661
|
+
" else\n"
|
|
662
|
+
" LiteralApply.new(r, a || [])\n"
|
|
663
|
+
" end ",152);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
-(VALUE)rule_other_call:(Context*)ctx {
|
|
667
|
+
return ({
|
|
668
|
+
Env env;
|
|
669
|
+
env[PARAM_g] = ({
|
|
670
|
+
ctx->apply(@selector(rule_grammar_name:));
|
|
671
|
+
});
|
|
672
|
+
ctx->act_char(".",1);
|
|
673
|
+
env[PARAM_r] = ({
|
|
674
|
+
ctx->apply(@selector(rule_rule_name:));
|
|
675
|
+
});
|
|
676
|
+
env[PARAM_a] = ({
|
|
677
|
+
struct rule_other_call_1_t : Lambda {
|
|
678
|
+
rule_other_call_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
679
|
+
VALUE call() {
|
|
680
|
+
return ({
|
|
681
|
+
ctx->apply(@selector(rule_apply_args:));
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
} rule_other_call_1(ctx, env);
|
|
685
|
+
ctx->act_may(&rule_other_call_1);
|
|
686
|
+
});
|
|
687
|
+
ctx->act_run(env," Other.new(g, r, a || []) ",26);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
-(VALUE)rule_apply_args:(Context*)ctx {
|
|
691
|
+
return ({
|
|
692
|
+
Env env;
|
|
693
|
+
ctx->act_char("(",1);
|
|
694
|
+
env[PARAM_a] = ({
|
|
695
|
+
struct rule_apply_args_1_t : Lambda {
|
|
696
|
+
rule_apply_args_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
697
|
+
VALUE call() {
|
|
698
|
+
return ({
|
|
699
|
+
ctx->apply(@selector(rule_s:));
|
|
700
|
+
env[PARAM_x] = ({
|
|
701
|
+
ctx->apply(@selector(rule_var_name:));
|
|
702
|
+
});
|
|
703
|
+
env[PARAM_xs] = ({
|
|
704
|
+
struct rule_apply_args_2_t : Lambda {
|
|
705
|
+
rule_apply_args_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
706
|
+
VALUE call() {
|
|
707
|
+
return ({
|
|
708
|
+
ctx->act_char(",",1);
|
|
709
|
+
ctx->apply(@selector(rule_s:));
|
|
710
|
+
ctx->apply(@selector(rule_var_name:));
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
} rule_apply_args_2(ctx, env);
|
|
714
|
+
ctx->act_many(&rule_apply_args_2);
|
|
715
|
+
});
|
|
716
|
+
ctx->act_run(env,"[x] + xs",8);
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
} rule_apply_args_1(ctx, env);
|
|
720
|
+
ctx->act_may(&rule_apply_args_1);
|
|
721
|
+
});
|
|
722
|
+
ctx->act_char(")",1);
|
|
723
|
+
ctx->act_run(env," a || [] ",9);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
-(VALUE)rule_action:(Context*)ctx {
|
|
727
|
+
return ({
|
|
728
|
+
Env env;
|
|
729
|
+
struct rule_action_1_t : Lambda {
|
|
730
|
+
rule_action_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
731
|
+
VALUE call() {
|
|
732
|
+
return ({
|
|
733
|
+
ctx->act_token("{*",2);
|
|
734
|
+
env[PARAM_s] = ({
|
|
735
|
+
struct rule_action_2_t : Lambda {
|
|
736
|
+
rule_action_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
737
|
+
VALUE call() {
|
|
738
|
+
return ({
|
|
739
|
+
struct rule_action_3_t : Lambda {
|
|
740
|
+
rule_action_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
741
|
+
VALUE call() {
|
|
742
|
+
return ({
|
|
743
|
+
struct rule_action_4_t : Lambda {
|
|
744
|
+
rule_action_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
745
|
+
VALUE call() {
|
|
746
|
+
return ({
|
|
747
|
+
ctx->act_char("*",1);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
} rule_action_4(ctx, env);
|
|
751
|
+
ctx->act_not(&rule_action_4);
|
|
752
|
+
ctx->act_any();
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
} rule_action_3(ctx, env);
|
|
756
|
+
struct rule_action_5_t : Lambda {
|
|
757
|
+
rule_action_5_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
758
|
+
VALUE call() {
|
|
759
|
+
return ({
|
|
760
|
+
ctx->act_char("*",1);
|
|
761
|
+
struct rule_action_6_t : Lambda {
|
|
762
|
+
rule_action_6_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
763
|
+
VALUE call() {
|
|
764
|
+
return ({
|
|
765
|
+
ctx->act_char("}",1);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
} rule_action_6(ctx, env);
|
|
769
|
+
ctx->act_not(&rule_action_6);
|
|
770
|
+
ctx->act_run(env,"'*'",3);
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
} rule_action_5(ctx, env);
|
|
774
|
+
Lambda* rule_action_3_or[] = {
|
|
775
|
+
&rule_action_3,
|
|
776
|
+
&rule_action_5,
|
|
777
|
+
NULL
|
|
778
|
+
};
|
|
779
|
+
ctx->act_or(rule_action_3_or);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
} rule_action_2(ctx, env);
|
|
783
|
+
ctx->act_many1(&rule_action_2);
|
|
784
|
+
});
|
|
785
|
+
ctx->act_token("*}",2);
|
|
786
|
+
ctx->act_run(env," Action.new(s.join) ",20);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
} rule_action_1(ctx, env);
|
|
790
|
+
struct rule_action_7_t : Lambda {
|
|
791
|
+
rule_action_7_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
792
|
+
VALUE call() {
|
|
793
|
+
return ({
|
|
794
|
+
ctx->act_token("{|",2);
|
|
795
|
+
env[PARAM_s] = ({
|
|
796
|
+
struct rule_action_8_t : Lambda {
|
|
797
|
+
rule_action_8_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
798
|
+
VALUE call() {
|
|
799
|
+
return ({
|
|
800
|
+
struct rule_action_9_t : Lambda {
|
|
801
|
+
rule_action_9_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
802
|
+
VALUE call() {
|
|
803
|
+
return ({
|
|
804
|
+
struct rule_action_10_t : Lambda {
|
|
805
|
+
rule_action_10_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
806
|
+
VALUE call() {
|
|
807
|
+
return ({
|
|
808
|
+
ctx->act_char("|",1);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
} rule_action_10(ctx, env);
|
|
812
|
+
ctx->act_not(&rule_action_10);
|
|
813
|
+
ctx->act_any();
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
} rule_action_9(ctx, env);
|
|
817
|
+
struct rule_action_11_t : Lambda {
|
|
818
|
+
rule_action_11_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
819
|
+
VALUE call() {
|
|
820
|
+
return ({
|
|
821
|
+
ctx->act_char("|",1);
|
|
822
|
+
struct rule_action_12_t : Lambda {
|
|
823
|
+
rule_action_12_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
824
|
+
VALUE call() {
|
|
825
|
+
return ({
|
|
826
|
+
ctx->act_char("}",1);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
} rule_action_12(ctx, env);
|
|
830
|
+
ctx->act_not(&rule_action_12);
|
|
831
|
+
ctx->act_run(env,"'*'",3);
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
} rule_action_11(ctx, env);
|
|
835
|
+
Lambda* rule_action_9_or[] = {
|
|
836
|
+
&rule_action_9,
|
|
837
|
+
&rule_action_11,
|
|
838
|
+
NULL
|
|
839
|
+
};
|
|
840
|
+
ctx->act_or(rule_action_9_or);
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
} rule_action_8(ctx, env);
|
|
844
|
+
ctx->act_many1(&rule_action_8);
|
|
845
|
+
});
|
|
846
|
+
ctx->act_token("|}",2);
|
|
847
|
+
ctx->act_run(env," Action.new(s.join) ",20);
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
} rule_action_7(ctx, env);
|
|
851
|
+
Lambda* rule_action_1_or[] = {
|
|
852
|
+
&rule_action_1,
|
|
853
|
+
&rule_action_7,
|
|
854
|
+
NULL
|
|
855
|
+
};
|
|
856
|
+
ctx->act_or(rule_action_1_or);
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
-(VALUE)rule_where:(Context*)ctx {
|
|
860
|
+
return ({
|
|
861
|
+
Env env;
|
|
862
|
+
struct rule_where_1_t : Lambda {
|
|
863
|
+
rule_where_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
864
|
+
VALUE call() {
|
|
865
|
+
return ({
|
|
866
|
+
ctx->act_token("?{*",3);
|
|
867
|
+
env[PARAM_s] = ({
|
|
868
|
+
struct rule_where_2_t : Lambda {
|
|
869
|
+
rule_where_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
870
|
+
VALUE call() {
|
|
871
|
+
return ({
|
|
872
|
+
struct rule_where_3_t : Lambda {
|
|
873
|
+
rule_where_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
874
|
+
VALUE call() {
|
|
875
|
+
return ({
|
|
876
|
+
struct rule_where_4_t : Lambda {
|
|
877
|
+
rule_where_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
878
|
+
VALUE call() {
|
|
879
|
+
return ({
|
|
880
|
+
ctx->act_char("*",1);
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
} rule_where_4(ctx, env);
|
|
884
|
+
ctx->act_not(&rule_where_4);
|
|
885
|
+
ctx->act_any();
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
} rule_where_3(ctx, env);
|
|
889
|
+
struct rule_where_5_t : Lambda {
|
|
890
|
+
rule_where_5_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
891
|
+
VALUE call() {
|
|
892
|
+
return ({
|
|
893
|
+
ctx->act_char("*",1);
|
|
894
|
+
struct rule_where_6_t : Lambda {
|
|
895
|
+
rule_where_6_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
896
|
+
VALUE call() {
|
|
897
|
+
return ({
|
|
898
|
+
ctx->act_char("}",1);
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
} rule_where_6(ctx, env);
|
|
902
|
+
ctx->act_not(&rule_where_6);
|
|
903
|
+
ctx->act_run(env,"'*'",3);
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
} rule_where_5(ctx, env);
|
|
907
|
+
Lambda* rule_where_3_or[] = {
|
|
908
|
+
&rule_where_3,
|
|
909
|
+
&rule_where_5,
|
|
910
|
+
NULL
|
|
911
|
+
};
|
|
912
|
+
ctx->act_or(rule_where_3_or);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
} rule_where_2(ctx, env);
|
|
916
|
+
ctx->act_many1(&rule_where_2);
|
|
917
|
+
});
|
|
918
|
+
ctx->act_token("*}",2);
|
|
919
|
+
ctx->act_run(env," Where.new(s.join) ",19);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
} rule_where_1(ctx, env);
|
|
923
|
+
struct rule_where_7_t : Lambda {
|
|
924
|
+
rule_where_7_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
925
|
+
VALUE call() {
|
|
926
|
+
return ({
|
|
927
|
+
ctx->act_token("?{|",3);
|
|
928
|
+
env[PARAM_s] = ({
|
|
929
|
+
struct rule_where_8_t : Lambda {
|
|
930
|
+
rule_where_8_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
931
|
+
VALUE call() {
|
|
932
|
+
return ({
|
|
933
|
+
struct rule_where_9_t : Lambda {
|
|
934
|
+
rule_where_9_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
935
|
+
VALUE call() {
|
|
936
|
+
return ({
|
|
937
|
+
struct rule_where_10_t : Lambda {
|
|
938
|
+
rule_where_10_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
939
|
+
VALUE call() {
|
|
940
|
+
return ({
|
|
941
|
+
ctx->act_char("|",1);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
} rule_where_10(ctx, env);
|
|
945
|
+
ctx->act_not(&rule_where_10);
|
|
946
|
+
ctx->act_any();
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
} rule_where_9(ctx, env);
|
|
950
|
+
struct rule_where_11_t : Lambda {
|
|
951
|
+
rule_where_11_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
952
|
+
VALUE call() {
|
|
953
|
+
return ({
|
|
954
|
+
ctx->act_char("|",1);
|
|
955
|
+
struct rule_where_12_t : Lambda {
|
|
956
|
+
rule_where_12_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
957
|
+
VALUE call() {
|
|
958
|
+
return ({
|
|
959
|
+
ctx->act_char("}",1);
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
} rule_where_12(ctx, env);
|
|
963
|
+
ctx->act_not(&rule_where_12);
|
|
964
|
+
ctx->act_run(env,"'*'",3);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
} rule_where_11(ctx, env);
|
|
968
|
+
Lambda* rule_where_9_or[] = {
|
|
969
|
+
&rule_where_9,
|
|
970
|
+
&rule_where_11,
|
|
971
|
+
NULL
|
|
972
|
+
};
|
|
973
|
+
ctx->act_or(rule_where_9_or);
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
} rule_where_8(ctx, env);
|
|
977
|
+
ctx->act_many1(&rule_where_8);
|
|
978
|
+
});
|
|
979
|
+
ctx->act_token("|}",2);
|
|
980
|
+
ctx->act_run(env," Where.new(s.join) ",19);
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
} rule_where_7(ctx, env);
|
|
984
|
+
Lambda* rule_where_1_or[] = {
|
|
985
|
+
&rule_where_1,
|
|
986
|
+
&rule_where_7,
|
|
987
|
+
NULL
|
|
988
|
+
};
|
|
989
|
+
ctx->act_or(rule_where_1_or);
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
-(VALUE)rule_rule_name:(Context*)ctx {
|
|
993
|
+
return ({
|
|
994
|
+
Env env;
|
|
995
|
+
env[PARAM_x] = ({
|
|
996
|
+
ctx->act_charclass("[a-z_]",6);
|
|
997
|
+
});
|
|
998
|
+
env[PARAM_xs] = ({
|
|
999
|
+
struct rule_rule_name_1_t : Lambda {
|
|
1000
|
+
rule_rule_name_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1001
|
+
VALUE call() {
|
|
1002
|
+
return ({
|
|
1003
|
+
ctx->act_charclass("[a-zA-Z_0-9]",12);
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
} rule_rule_name_1(ctx, env);
|
|
1007
|
+
ctx->act_many(&rule_rule_name_1);
|
|
1008
|
+
});
|
|
1009
|
+
ctx->act_run(env," ([x] + xs).join ",17);
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
-(VALUE)rule_var_name:(Context*)ctx {
|
|
1013
|
+
return ({
|
|
1014
|
+
Env env;
|
|
1015
|
+
env[PARAM_x] = ({
|
|
1016
|
+
ctx->act_charclass("[a-z_]",6);
|
|
1017
|
+
});
|
|
1018
|
+
env[PARAM_xs] = ({
|
|
1019
|
+
struct rule_var_name_1_t : Lambda {
|
|
1020
|
+
rule_var_name_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1021
|
+
VALUE call() {
|
|
1022
|
+
return ({
|
|
1023
|
+
ctx->act_charclass("[a-zA-Z_0-9]",12);
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
} rule_var_name_1(ctx, env);
|
|
1027
|
+
ctx->act_many(&rule_var_name_1);
|
|
1028
|
+
});
|
|
1029
|
+
ctx->act_run(env," ([x] + xs).join ",17);
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
-(VALUE)rule_grammar_name:(Context*)ctx {
|
|
1033
|
+
return ({
|
|
1034
|
+
Env env;
|
|
1035
|
+
env[PARAM_x] = ({
|
|
1036
|
+
ctx->act_charclass("[A-Z]",5);
|
|
1037
|
+
});
|
|
1038
|
+
env[PARAM_xs] = ({
|
|
1039
|
+
struct rule_grammar_name_1_t : Lambda {
|
|
1040
|
+
rule_grammar_name_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1041
|
+
VALUE call() {
|
|
1042
|
+
return ({
|
|
1043
|
+
ctx->act_charclass("[a-zA-Z_0-9]",12);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
} rule_grammar_name_1(ctx, env);
|
|
1047
|
+
ctx->act_many(&rule_grammar_name_1);
|
|
1048
|
+
});
|
|
1049
|
+
ctx->act_run(env," ([x] + xs).join ",17);
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
-(VALUE)rule_dq_string:(Context*)ctx {
|
|
1053
|
+
return ({
|
|
1054
|
+
Env env;
|
|
1055
|
+
ctx->act_char("\"",1);
|
|
1056
|
+
env[PARAM_s] = ({
|
|
1057
|
+
struct rule_dq_string_1_t : Lambda {
|
|
1058
|
+
rule_dq_string_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1059
|
+
VALUE call() {
|
|
1060
|
+
return ({
|
|
1061
|
+
struct rule_dq_string_2_t : Lambda {
|
|
1062
|
+
rule_dq_string_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1063
|
+
VALUE call() {
|
|
1064
|
+
return ({
|
|
1065
|
+
struct rule_dq_string_3_t : Lambda {
|
|
1066
|
+
rule_dq_string_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1067
|
+
VALUE call() {
|
|
1068
|
+
return ({
|
|
1069
|
+
ctx->act_char("\"",1);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
} rule_dq_string_3(ctx, env);
|
|
1073
|
+
ctx->act_not(&rule_dq_string_3);
|
|
1074
|
+
ctx->act_any();
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
} rule_dq_string_2(ctx, env);
|
|
1078
|
+
struct rule_dq_string_4_t : Lambda {
|
|
1079
|
+
rule_dq_string_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1080
|
+
VALUE call() {
|
|
1081
|
+
return ({
|
|
1082
|
+
ctx->act_token("\\\"",2);
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
} rule_dq_string_4(ctx, env);
|
|
1086
|
+
Lambda* rule_dq_string_2_or[] = {
|
|
1087
|
+
&rule_dq_string_2,
|
|
1088
|
+
&rule_dq_string_4,
|
|
1089
|
+
NULL
|
|
1090
|
+
};
|
|
1091
|
+
ctx->act_or(rule_dq_string_2_or);
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
} rule_dq_string_1(ctx, env);
|
|
1095
|
+
ctx->act_many1(&rule_dq_string_1);
|
|
1096
|
+
});
|
|
1097
|
+
ctx->act_char("\"",1);
|
|
1098
|
+
ctx->act_run(env," s.join ",8);
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
-(VALUE)rule_q_string:(Context*)ctx {
|
|
1102
|
+
return ({
|
|
1103
|
+
Env env;
|
|
1104
|
+
ctx->act_char("'",1);
|
|
1105
|
+
env[PARAM_s] = ({
|
|
1106
|
+
struct rule_q_string_1_t : Lambda {
|
|
1107
|
+
rule_q_string_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1108
|
+
VALUE call() {
|
|
1109
|
+
return ({
|
|
1110
|
+
struct rule_q_string_2_t : Lambda {
|
|
1111
|
+
rule_q_string_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1112
|
+
VALUE call() {
|
|
1113
|
+
return ({
|
|
1114
|
+
struct rule_q_string_3_t : Lambda {
|
|
1115
|
+
rule_q_string_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1116
|
+
VALUE call() {
|
|
1117
|
+
return ({
|
|
1118
|
+
ctx->act_char("'",1);
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
} rule_q_string_3(ctx, env);
|
|
1122
|
+
ctx->act_not(&rule_q_string_3);
|
|
1123
|
+
ctx->act_any();
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
} rule_q_string_2(ctx, env);
|
|
1127
|
+
struct rule_q_string_4_t : Lambda {
|
|
1128
|
+
rule_q_string_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1129
|
+
VALUE call() {
|
|
1130
|
+
return ({
|
|
1131
|
+
ctx->act_token("\\'",2);
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
} rule_q_string_4(ctx, env);
|
|
1135
|
+
Lambda* rule_q_string_2_or[] = {
|
|
1136
|
+
&rule_q_string_2,
|
|
1137
|
+
&rule_q_string_4,
|
|
1138
|
+
NULL
|
|
1139
|
+
};
|
|
1140
|
+
ctx->act_or(rule_q_string_2_or);
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
} rule_q_string_1(ctx, env);
|
|
1144
|
+
ctx->act_many1(&rule_q_string_1);
|
|
1145
|
+
});
|
|
1146
|
+
ctx->act_char("'",1);
|
|
1147
|
+
ctx->act_run(env," s.join ",8);
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
-(VALUE)rule_charclass:(Context*)ctx {
|
|
1151
|
+
return ({
|
|
1152
|
+
Env env;
|
|
1153
|
+
ctx->act_char("[",1);
|
|
1154
|
+
env[PARAM_s] = ({
|
|
1155
|
+
struct rule_charclass_1_t : Lambda {
|
|
1156
|
+
rule_charclass_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1157
|
+
VALUE call() {
|
|
1158
|
+
return ({
|
|
1159
|
+
struct rule_charclass_2_t : Lambda {
|
|
1160
|
+
rule_charclass_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1161
|
+
VALUE call() {
|
|
1162
|
+
return ({
|
|
1163
|
+
struct rule_charclass_3_t : Lambda {
|
|
1164
|
+
rule_charclass_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1165
|
+
VALUE call() {
|
|
1166
|
+
return ({
|
|
1167
|
+
ctx->act_char("]",1);
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
} rule_charclass_3(ctx, env);
|
|
1171
|
+
ctx->act_not(&rule_charclass_3);
|
|
1172
|
+
ctx->act_any();
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
} rule_charclass_2(ctx, env);
|
|
1176
|
+
struct rule_charclass_4_t : Lambda {
|
|
1177
|
+
rule_charclass_4_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1178
|
+
VALUE call() {
|
|
1179
|
+
return ({
|
|
1180
|
+
ctx->act_token("\\]",2);
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
} rule_charclass_4(ctx, env);
|
|
1184
|
+
Lambda* rule_charclass_2_or[] = {
|
|
1185
|
+
&rule_charclass_2,
|
|
1186
|
+
&rule_charclass_4,
|
|
1187
|
+
NULL
|
|
1188
|
+
};
|
|
1189
|
+
ctx->act_or(rule_charclass_2_or);
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
} rule_charclass_1(ctx, env);
|
|
1193
|
+
ctx->act_many1(&rule_charclass_1);
|
|
1194
|
+
});
|
|
1195
|
+
ctx->act_char("]",1);
|
|
1196
|
+
ctx->act_run(env," s.join ",8);
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
-(VALUE)rule_s:(Context*)ctx {
|
|
1200
|
+
return ({
|
|
1201
|
+
Env env;
|
|
1202
|
+
struct rule_s_1_t : Lambda {
|
|
1203
|
+
rule_s_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1204
|
+
VALUE call() {
|
|
1205
|
+
return ({
|
|
1206
|
+
struct rule_s_2_t : Lambda {
|
|
1207
|
+
rule_s_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1208
|
+
VALUE call() {
|
|
1209
|
+
return ({
|
|
1210
|
+
ctx->apply(@selector(rule_comment:));
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
} rule_s_2(ctx, env);
|
|
1214
|
+
struct rule_s_3_t : Lambda {
|
|
1215
|
+
rule_s_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1216
|
+
VALUE call() {
|
|
1217
|
+
return ({
|
|
1218
|
+
ctx->act_charclass("[ \\t\\r\\n]",9);
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
} rule_s_3(ctx, env);
|
|
1222
|
+
Lambda* rule_s_2_or[] = {
|
|
1223
|
+
&rule_s_2,
|
|
1224
|
+
&rule_s_3,
|
|
1225
|
+
NULL
|
|
1226
|
+
};
|
|
1227
|
+
ctx->act_or(rule_s_2_or);
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
} rule_s_1(ctx, env);
|
|
1231
|
+
ctx->act_many(&rule_s_1);
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
-(VALUE)rule_fs:(Context*)ctx {
|
|
1235
|
+
return ({
|
|
1236
|
+
Env env;
|
|
1237
|
+
struct rule_fs_1_t : Lambda {
|
|
1238
|
+
rule_fs_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1239
|
+
VALUE call() {
|
|
1240
|
+
return ({
|
|
1241
|
+
struct rule_fs_2_t : Lambda {
|
|
1242
|
+
rule_fs_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1243
|
+
VALUE call() {
|
|
1244
|
+
return ({
|
|
1245
|
+
ctx->apply(@selector(rule_comment:));
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
} rule_fs_2(ctx, env);
|
|
1249
|
+
struct rule_fs_3_t : Lambda {
|
|
1250
|
+
rule_fs_3_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1251
|
+
VALUE call() {
|
|
1252
|
+
return ({
|
|
1253
|
+
ctx->act_charclass("[ \\t\\r\\n]",9);
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
} rule_fs_3(ctx, env);
|
|
1257
|
+
Lambda* rule_fs_2_or[] = {
|
|
1258
|
+
&rule_fs_2,
|
|
1259
|
+
&rule_fs_3,
|
|
1260
|
+
NULL
|
|
1261
|
+
};
|
|
1262
|
+
ctx->act_or(rule_fs_2_or);
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
} rule_fs_1(ctx, env);
|
|
1266
|
+
ctx->act_many1(&rule_fs_1);
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
-(VALUE)rule_comment:(Context*)ctx {
|
|
1270
|
+
return ({
|
|
1271
|
+
Env env;
|
|
1272
|
+
ctx->act_char("#",1);
|
|
1273
|
+
struct rule_comment_1_t : Lambda {
|
|
1274
|
+
rule_comment_1_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1275
|
+
VALUE call() {
|
|
1276
|
+
return ({
|
|
1277
|
+
struct rule_comment_2_t : Lambda {
|
|
1278
|
+
rule_comment_2_t(Context* _ctx, Env& _env) : Lambda(_ctx, _env) {}
|
|
1279
|
+
VALUE call() {
|
|
1280
|
+
return ({
|
|
1281
|
+
ctx->act_char("\n",1);
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
} rule_comment_2(ctx, env);
|
|
1285
|
+
ctx->act_not(&rule_comment_2);
|
|
1286
|
+
ctx->act_any();
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
} rule_comment_1(ctx, env);
|
|
1290
|
+
ctx->act_many(&rule_comment_1);
|
|
1291
|
+
ctx->act_char("\n",1);
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
@end
|