less 0.8.13 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -1
- data/Rakefile +21 -3
- data/VERSION +1 -1
- data/bin/lessc +0 -8
- data/less.gemspec +138 -15
- data/lib/less.rb +67 -11
- data/lib/less/command.rb +24 -25
- data/lib/less/engine.rb +36 -140
- data/lib/less/engine/builder.rb +8 -0
- data/lib/less/engine/less.tt +374 -0
- data/lib/less/engine/nodes.rb +8 -0
- data/lib/less/engine/nodes/element.rb +150 -0
- data/lib/less/engine/nodes/entity.rb +73 -0
- data/lib/less/engine/nodes/function.rb +82 -0
- data/lib/less/engine/nodes/literal.rb +135 -0
- data/lib/less/engine/nodes/property.rb +112 -0
- data/lib/less/engine/nodes/selector.rb +39 -0
- data/lib/less/engine/parser.rb +3860 -0
- data/lib/vendor/treetop/.gitignore +7 -0
- data/lib/vendor/treetop/LICENSE +19 -0
- data/lib/vendor/treetop/README +164 -0
- data/lib/vendor/treetop/Rakefile +19 -0
- data/lib/vendor/treetop/benchmark/seqpar.gnuplot +15 -0
- data/lib/vendor/treetop/benchmark/seqpar.treetop +16 -0
- data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +107 -0
- data/lib/vendor/treetop/bin/tt +28 -0
- data/lib/vendor/treetop/lib/treetop.rb +8 -0
- data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
- data/lib/vendor/treetop/lib/treetop/compiler.rb +6 -0
- data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +42 -0
- data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +17 -0
- data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +3097 -0
- data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +408 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +19 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +23 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +31 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +28 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +19 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +55 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +45 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +55 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +68 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +20 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +113 -0
- data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +2 -0
- data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +42 -0
- data/lib/vendor/treetop/lib/treetop/runtime.rb +5 -0
- data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +109 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +4 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
- data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +90 -0
- data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
- data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
- data/lib/vendor/treetop/lib/treetop/version.rb +9 -0
- data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +36 -0
- data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +44 -0
- data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +247 -0
- data/lib/vendor/treetop/spec/compiler/choice_spec.rb +80 -0
- data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +28 -0
- data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +21 -0
- data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +84 -0
- data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +41 -0
- data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +40 -0
- data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +38 -0
- data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +35 -0
- data/lib/vendor/treetop/spec/compiler/optional_spec.rb +37 -0
- data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +19 -0
- data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +32 -0
- data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +115 -0
- data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +81 -0
- data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +37 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +7 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar.tt +7 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +7 -0
- data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +56 -0
- data/lib/vendor/treetop/spec/composition/a.treetop +11 -0
- data/lib/vendor/treetop/spec/composition/b.treetop +11 -0
- data/lib/vendor/treetop/spec/composition/c.treetop +10 -0
- data/lib/vendor/treetop/spec/composition/d.treetop +10 -0
- data/lib/vendor/treetop/spec/composition/f.treetop +17 -0
- data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +40 -0
- data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +15 -0
- data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +32 -0
- data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +101 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
- data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +68 -0
- data/lib/vendor/treetop/spec/spec_helper.rb +106 -0
- data/lib/vendor/treetop/spec/spec_suite.rb +4 -0
- data/lib/vendor/treetop/treetop.gemspec +17 -0
- data/spec/command_spec.rb +2 -6
- data/spec/css/accessors-1.0.css +18 -0
- data/spec/css/big-1.0.css +3768 -0
- data/spec/css/comments-1.0.css +9 -0
- data/spec/css/css-1.0.css +40 -0
- data/spec/css/functions-1.0.css +6 -0
- data/spec/css/import-1.0.css +11 -0
- data/spec/css/mixins-1.0.css +28 -0
- data/spec/css/operations-1.0.css +28 -0
- data/spec/css/rulesets-1.0.css +17 -0
- data/spec/css/scope-1.0.css +14 -0
- data/spec/css/strings-1.0.css +12 -0
- data/spec/css/variables-1.0.css +6 -0
- data/spec/css/whitespace-1.0.css +9 -0
- data/spec/engine_spec.rb +66 -18
- data/spec/less/accessors-1.0.less +20 -0
- data/spec/less/big-1.0.less +4810 -0
- data/spec/less/colors-1.0.less +0 -0
- data/spec/less/comments-1.0.less +46 -0
- data/spec/less/css-1.0.less +84 -0
- data/spec/less/exceptions/mixed-units-error.less +3 -0
- data/spec/less/exceptions/name-error-1.0.less +3 -0
- data/spec/less/exceptions/syntax-error-1.0.less +3 -0
- data/spec/less/functions-1.0.less +6 -0
- data/spec/less/import-1.0.less +7 -0
- data/spec/less/import/import-test-a.less +2 -0
- data/spec/less/import/import-test-b.less +8 -0
- data/spec/less/import/import-test-c.less +5 -0
- data/spec/less/mixins-1.0.less +43 -0
- data/spec/less/operations-1.0.less +39 -0
- data/spec/less/rulesets-1.0.less +30 -0
- data/spec/less/scope-1.0.less +33 -0
- data/spec/less/strings-1.0.less +14 -0
- data/spec/less/variables-1.0.less +18 -0
- data/spec/less/whitespace-1.0.less +21 -0
- data/spec/spec.css +79 -24
- data/spec/spec.less +2 -3
- data/spec/spec_helper.rb +4 -1
- metadata +136 -13
- data/lib/less/tree.rb +0 -82
- data/spec/css/less-0.8.10.css +0 -30
- data/spec/css/less-0.8.11.css +0 -31
- data/spec/css/less-0.8.12.css +0 -28
- data/spec/css/less-0.8.5.css +0 -24
- data/spec/css/less-0.8.6.css +0 -24
- data/spec/css/less-0.8.7.css +0 -24
- data/spec/css/less-0.8.8.css +0 -25
- data/spec/tree_spec.rb +0 -5
@@ -0,0 +1,112 @@
|
|
1
|
+
module Less
|
2
|
+
module Node
|
3
|
+
class Property < ::String
|
4
|
+
include Entity
|
5
|
+
|
6
|
+
attr_accessor :value
|
7
|
+
|
8
|
+
def initialize key, value = nil
|
9
|
+
super key
|
10
|
+
@value = Expression.new(value ? [value] : [])
|
11
|
+
@eval = false # Store the first evaluation in here
|
12
|
+
end
|
13
|
+
|
14
|
+
def << token
|
15
|
+
token = Node::Anonymous.new(*token) unless token.is_a? Entity or token.is_a? Operator
|
16
|
+
@value << token
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?; !@value || @value.empty? end
|
20
|
+
def eval?; @eval end
|
21
|
+
|
22
|
+
def inspect
|
23
|
+
self + (empty?? "" : ": `#{value.map {|i| i.to_s } * ' | '}`")
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
# TODO: @eval and @value should be merged
|
31
|
+
def evaluate
|
32
|
+
@eval || @eval = value.evaluate
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_css
|
36
|
+
"#{self}: #{evaluate.to_css};"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Variable < Property
|
41
|
+
def initialize key, value = nil
|
42
|
+
super key.delete('@'), value
|
43
|
+
end
|
44
|
+
|
45
|
+
def inspect
|
46
|
+
"@#{super}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
"@#{super}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_ruby
|
54
|
+
value.evaluate.to_ruby
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_css
|
58
|
+
value.evaluate.to_css
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Expression < Array
|
63
|
+
def operators; select {|i| i.is_a? Operator } end
|
64
|
+
def entities; select {|i| i.kind_of? Entity } end
|
65
|
+
def literals; select {|i| i.kind_of? Literal } end
|
66
|
+
|
67
|
+
def inspect
|
68
|
+
'[' + map {|i| i.inspect }.join(', ') + ']'
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_css
|
72
|
+
map {|i| i.to_css } * ' '
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# Evaluates the expression and instantiates a new Literal with the result
|
77
|
+
# ex: [#111, +, #111] will evaluate to a Color node, with value #222
|
78
|
+
#
|
79
|
+
# TODO: refactor the conditionals
|
80
|
+
def evaluate
|
81
|
+
if size > 2 && (entities.size == operators.size + 1)
|
82
|
+
|
83
|
+
# Create a sub-expression with all the variables/properties evaluated
|
84
|
+
evaluated = Expression.new map {|e| e.respond_to?(:evaluate) ? e.evaluate : e }
|
85
|
+
|
86
|
+
unit = evaluated.literals.map do |node|
|
87
|
+
node.unit
|
88
|
+
end.compact.uniq.tap do |ary|
|
89
|
+
raise MixedUnitsError, self * ' ' if ary.size > 1
|
90
|
+
end.join
|
91
|
+
|
92
|
+
entity = evaluated.literals.find {|e| e.unit == unit } || evaluated.first
|
93
|
+
ruby = map {|e| e.to_ruby if e.respond_to? :to_ruby }
|
94
|
+
|
95
|
+
unless ruby.include? nil
|
96
|
+
if entity
|
97
|
+
entity.class.new(eval(ruby.join), *(unit if entity.class == Node::Number))
|
98
|
+
else
|
99
|
+
first
|
100
|
+
end
|
101
|
+
else
|
102
|
+
self
|
103
|
+
end
|
104
|
+
elsif size == 1
|
105
|
+
first
|
106
|
+
else
|
107
|
+
self
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Less
|
2
|
+
module Node
|
3
|
+
class Selector < ::String
|
4
|
+
include Entity
|
5
|
+
|
6
|
+
Selectors = {
|
7
|
+
:Descendant => '',
|
8
|
+
:Child => '>',
|
9
|
+
:Adjacent => '+',
|
10
|
+
:Pseudo => ':',
|
11
|
+
:Sibling => '~'
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super Selectors[ self.class.to_s.split('::').last.to_sym ]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.[] key
|
19
|
+
Node.const_get(Selectors.find {|k, v| v == key }.first)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Descendant < Selector
|
24
|
+
def to_css; " " end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Child < Selector
|
28
|
+
def to_css; " #{self} " end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Adjacent < Selector
|
32
|
+
def to_css; " #{self} " end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Pseudo < Selector
|
36
|
+
def to_css; self end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,3860 @@
|
|
1
|
+
module Less
|
2
|
+
include Treetop::Runtime
|
3
|
+
|
4
|
+
def root
|
5
|
+
@root || :primary
|
6
|
+
end
|
7
|
+
|
8
|
+
def _nt_primary
|
9
|
+
start_index = index
|
10
|
+
if node_cache[:primary].has_key?(index)
|
11
|
+
cached = node_cache[:primary][index]
|
12
|
+
@index = cached.interval.end if cached
|
13
|
+
return cached
|
14
|
+
end
|
15
|
+
|
16
|
+
i0 = index
|
17
|
+
s1, i1 = [], index
|
18
|
+
loop do
|
19
|
+
i2 = index
|
20
|
+
r3 = _nt_declaration
|
21
|
+
if r3
|
22
|
+
r2 = r3
|
23
|
+
else
|
24
|
+
r4 = _nt_ruleset
|
25
|
+
if r4
|
26
|
+
r2 = r4
|
27
|
+
else
|
28
|
+
r5 = _nt_import
|
29
|
+
if r5
|
30
|
+
r2 = r5
|
31
|
+
else
|
32
|
+
r6 = _nt_comment
|
33
|
+
if r6
|
34
|
+
r2 = r6
|
35
|
+
else
|
36
|
+
@index = i2
|
37
|
+
r2 = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if r2
|
43
|
+
s1 << r2
|
44
|
+
else
|
45
|
+
break
|
46
|
+
end
|
47
|
+
end
|
48
|
+
if s1.empty?
|
49
|
+
@index = i1
|
50
|
+
r1 = nil
|
51
|
+
else
|
52
|
+
r1 = instantiate_node(Builder,input, i1...index, s1)
|
53
|
+
end
|
54
|
+
if r1
|
55
|
+
r0 = r1
|
56
|
+
else
|
57
|
+
s7, i7 = [], index
|
58
|
+
loop do
|
59
|
+
r8 = _nt_declaration
|
60
|
+
if r8
|
61
|
+
s7 << r8
|
62
|
+
else
|
63
|
+
break
|
64
|
+
end
|
65
|
+
end
|
66
|
+
r7 = instantiate_node(Builder,input, i7...index, s7)
|
67
|
+
if r7
|
68
|
+
r0 = r7
|
69
|
+
else
|
70
|
+
s9, i9 = [], index
|
71
|
+
loop do
|
72
|
+
r10 = _nt_import
|
73
|
+
if r10
|
74
|
+
s9 << r10
|
75
|
+
else
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
r9 = instantiate_node(Builder,input, i9...index, s9)
|
80
|
+
if r9
|
81
|
+
r0 = r9
|
82
|
+
else
|
83
|
+
s11, i11 = [], index
|
84
|
+
loop do
|
85
|
+
r12 = _nt_comment
|
86
|
+
if r12
|
87
|
+
s11 << r12
|
88
|
+
else
|
89
|
+
break
|
90
|
+
end
|
91
|
+
end
|
92
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
93
|
+
if r11
|
94
|
+
r0 = r11
|
95
|
+
else
|
96
|
+
@index = i0
|
97
|
+
r0 = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
node_cache[:primary][start_index] = r0
|
104
|
+
|
105
|
+
r0
|
106
|
+
end
|
107
|
+
|
108
|
+
module Comment0
|
109
|
+
end
|
110
|
+
|
111
|
+
module Comment1
|
112
|
+
def ws
|
113
|
+
elements[0]
|
114
|
+
end
|
115
|
+
|
116
|
+
def ws
|
117
|
+
elements[4]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
module Comment2
|
122
|
+
end
|
123
|
+
|
124
|
+
module Comment3
|
125
|
+
def ws
|
126
|
+
elements[0]
|
127
|
+
end
|
128
|
+
|
129
|
+
def ws
|
130
|
+
elements[4]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def _nt_comment
|
135
|
+
start_index = index
|
136
|
+
if node_cache[:comment].has_key?(index)
|
137
|
+
cached = node_cache[:comment][index]
|
138
|
+
@index = cached.interval.end if cached
|
139
|
+
return cached
|
140
|
+
end
|
141
|
+
|
142
|
+
i0 = index
|
143
|
+
i1, s1 = index, []
|
144
|
+
r2 = _nt_ws
|
145
|
+
s1 << r2
|
146
|
+
if r2
|
147
|
+
if has_terminal?('/*', false, index)
|
148
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
149
|
+
@index += 2
|
150
|
+
else
|
151
|
+
terminal_parse_failure('/*')
|
152
|
+
r3 = nil
|
153
|
+
end
|
154
|
+
s1 << r3
|
155
|
+
if r3
|
156
|
+
s4, i4 = [], index
|
157
|
+
loop do
|
158
|
+
i5, s5 = index, []
|
159
|
+
i6 = index
|
160
|
+
if has_terminal?('*/', false, index)
|
161
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
162
|
+
@index += 2
|
163
|
+
else
|
164
|
+
terminal_parse_failure('*/')
|
165
|
+
r7 = nil
|
166
|
+
end
|
167
|
+
if r7
|
168
|
+
r6 = nil
|
169
|
+
else
|
170
|
+
@index = i6
|
171
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
172
|
+
end
|
173
|
+
s5 << r6
|
174
|
+
if r6
|
175
|
+
if index < input_length
|
176
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
177
|
+
@index += 1
|
178
|
+
else
|
179
|
+
terminal_parse_failure("any character")
|
180
|
+
r8 = nil
|
181
|
+
end
|
182
|
+
s5 << r8
|
183
|
+
end
|
184
|
+
if s5.last
|
185
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
186
|
+
r5.extend(Comment0)
|
187
|
+
else
|
188
|
+
@index = i5
|
189
|
+
r5 = nil
|
190
|
+
end
|
191
|
+
if r5
|
192
|
+
s4 << r5
|
193
|
+
else
|
194
|
+
break
|
195
|
+
end
|
196
|
+
end
|
197
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
198
|
+
s1 << r4
|
199
|
+
if r4
|
200
|
+
if has_terminal?('*/', false, index)
|
201
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
202
|
+
@index += 2
|
203
|
+
else
|
204
|
+
terminal_parse_failure('*/')
|
205
|
+
r9 = nil
|
206
|
+
end
|
207
|
+
s1 << r9
|
208
|
+
if r9
|
209
|
+
r10 = _nt_ws
|
210
|
+
s1 << r10
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
if s1.last
|
216
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
217
|
+
r1.extend(Comment1)
|
218
|
+
else
|
219
|
+
@index = i1
|
220
|
+
r1 = nil
|
221
|
+
end
|
222
|
+
if r1
|
223
|
+
r0 = r1
|
224
|
+
else
|
225
|
+
i11, s11 = index, []
|
226
|
+
r12 = _nt_ws
|
227
|
+
s11 << r12
|
228
|
+
if r12
|
229
|
+
if has_terminal?('//', false, index)
|
230
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
231
|
+
@index += 2
|
232
|
+
else
|
233
|
+
terminal_parse_failure('//')
|
234
|
+
r13 = nil
|
235
|
+
end
|
236
|
+
s11 << r13
|
237
|
+
if r13
|
238
|
+
s14, i14 = [], index
|
239
|
+
loop do
|
240
|
+
i15, s15 = index, []
|
241
|
+
i16 = index
|
242
|
+
if has_terminal?("\n", false, index)
|
243
|
+
r17 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
244
|
+
@index += 1
|
245
|
+
else
|
246
|
+
terminal_parse_failure("\n")
|
247
|
+
r17 = nil
|
248
|
+
end
|
249
|
+
if r17
|
250
|
+
r16 = nil
|
251
|
+
else
|
252
|
+
@index = i16
|
253
|
+
r16 = instantiate_node(SyntaxNode,input, index...index)
|
254
|
+
end
|
255
|
+
s15 << r16
|
256
|
+
if r16
|
257
|
+
if index < input_length
|
258
|
+
r18 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
259
|
+
@index += 1
|
260
|
+
else
|
261
|
+
terminal_parse_failure("any character")
|
262
|
+
r18 = nil
|
263
|
+
end
|
264
|
+
s15 << r18
|
265
|
+
end
|
266
|
+
if s15.last
|
267
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
268
|
+
r15.extend(Comment2)
|
269
|
+
else
|
270
|
+
@index = i15
|
271
|
+
r15 = nil
|
272
|
+
end
|
273
|
+
if r15
|
274
|
+
s14 << r15
|
275
|
+
else
|
276
|
+
break
|
277
|
+
end
|
278
|
+
end
|
279
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
280
|
+
s11 << r14
|
281
|
+
if r14
|
282
|
+
if has_terminal?("\n", false, index)
|
283
|
+
r19 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
284
|
+
@index += 1
|
285
|
+
else
|
286
|
+
terminal_parse_failure("\n")
|
287
|
+
r19 = nil
|
288
|
+
end
|
289
|
+
s11 << r19
|
290
|
+
if r19
|
291
|
+
r20 = _nt_ws
|
292
|
+
s11 << r20
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
if s11.last
|
298
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
299
|
+
r11.extend(Comment3)
|
300
|
+
else
|
301
|
+
@index = i11
|
302
|
+
r11 = nil
|
303
|
+
end
|
304
|
+
if r11
|
305
|
+
r0 = r11
|
306
|
+
else
|
307
|
+
@index = i0
|
308
|
+
r0 = nil
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
node_cache[:comment][start_index] = r0
|
313
|
+
|
314
|
+
r0
|
315
|
+
end
|
316
|
+
|
317
|
+
module Ruleset0
|
318
|
+
def selectors
|
319
|
+
elements[0]
|
320
|
+
end
|
321
|
+
|
322
|
+
def ws
|
323
|
+
elements[2]
|
324
|
+
end
|
325
|
+
|
326
|
+
def primary
|
327
|
+
elements[3]
|
328
|
+
end
|
329
|
+
|
330
|
+
def ws
|
331
|
+
elements[4]
|
332
|
+
end
|
333
|
+
|
334
|
+
def ws
|
335
|
+
elements[6]
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
module Ruleset1
|
340
|
+
def build env
|
341
|
+
# Build the ruleset for each selector
|
342
|
+
selectors.build(env, :tree).each do |sel|
|
343
|
+
primary.build sel
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
module Ruleset2
|
349
|
+
def ws
|
350
|
+
elements[0]
|
351
|
+
end
|
352
|
+
|
353
|
+
def selectors
|
354
|
+
elements[1]
|
355
|
+
end
|
356
|
+
|
357
|
+
def ws
|
358
|
+
elements[3]
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
module Ruleset3
|
363
|
+
def build env
|
364
|
+
selectors.build(env, :path).each do |path|
|
365
|
+
rules = path.inject(env.root) do |current, node|
|
366
|
+
current.descend(node.selector, node) or raise MixinNameError, path.join
|
367
|
+
end.rules
|
368
|
+
env.rules += rules
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def _nt_ruleset
|
374
|
+
start_index = index
|
375
|
+
if node_cache[:ruleset].has_key?(index)
|
376
|
+
cached = node_cache[:ruleset][index]
|
377
|
+
@index = cached.interval.end if cached
|
378
|
+
return cached
|
379
|
+
end
|
380
|
+
|
381
|
+
i0 = index
|
382
|
+
i1, s1 = index, []
|
383
|
+
r2 = _nt_selectors
|
384
|
+
s1 << r2
|
385
|
+
if r2
|
386
|
+
if has_terminal?("{", false, index)
|
387
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
388
|
+
@index += 1
|
389
|
+
else
|
390
|
+
terminal_parse_failure("{")
|
391
|
+
r3 = nil
|
392
|
+
end
|
393
|
+
s1 << r3
|
394
|
+
if r3
|
395
|
+
r4 = _nt_ws
|
396
|
+
s1 << r4
|
397
|
+
if r4
|
398
|
+
r5 = _nt_primary
|
399
|
+
s1 << r5
|
400
|
+
if r5
|
401
|
+
r6 = _nt_ws
|
402
|
+
s1 << r6
|
403
|
+
if r6
|
404
|
+
if has_terminal?("}", false, index)
|
405
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
406
|
+
@index += 1
|
407
|
+
else
|
408
|
+
terminal_parse_failure("}")
|
409
|
+
r7 = nil
|
410
|
+
end
|
411
|
+
s1 << r7
|
412
|
+
if r7
|
413
|
+
r8 = _nt_ws
|
414
|
+
s1 << r8
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
if s1.last
|
422
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
423
|
+
r1.extend(Ruleset0)
|
424
|
+
r1.extend(Ruleset1)
|
425
|
+
else
|
426
|
+
@index = i1
|
427
|
+
r1 = nil
|
428
|
+
end
|
429
|
+
if r1
|
430
|
+
r0 = r1
|
431
|
+
else
|
432
|
+
i9, s9 = index, []
|
433
|
+
r10 = _nt_ws
|
434
|
+
s9 << r10
|
435
|
+
if r10
|
436
|
+
r11 = _nt_selectors
|
437
|
+
s9 << r11
|
438
|
+
if r11
|
439
|
+
if has_terminal?(';', false, index)
|
440
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
441
|
+
@index += 1
|
442
|
+
else
|
443
|
+
terminal_parse_failure(';')
|
444
|
+
r12 = nil
|
445
|
+
end
|
446
|
+
s9 << r12
|
447
|
+
if r12
|
448
|
+
r13 = _nt_ws
|
449
|
+
s9 << r13
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
if s9.last
|
454
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
455
|
+
r9.extend(Ruleset2)
|
456
|
+
r9.extend(Ruleset3)
|
457
|
+
else
|
458
|
+
@index = i9
|
459
|
+
r9 = nil
|
460
|
+
end
|
461
|
+
if r9
|
462
|
+
r0 = r9
|
463
|
+
else
|
464
|
+
@index = i0
|
465
|
+
r0 = nil
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
node_cache[:ruleset][start_index] = r0
|
470
|
+
|
471
|
+
r0
|
472
|
+
end
|
473
|
+
|
474
|
+
module Import0
|
475
|
+
def S
|
476
|
+
elements[1]
|
477
|
+
end
|
478
|
+
|
479
|
+
def url
|
480
|
+
elements[2]
|
481
|
+
end
|
482
|
+
|
483
|
+
def s
|
484
|
+
elements[4]
|
485
|
+
end
|
486
|
+
|
487
|
+
def ws
|
488
|
+
elements[6]
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
module Import1
|
493
|
+
def build env
|
494
|
+
path = File.join(env.root.file, url.value)
|
495
|
+
path += '.less' unless path =~ /\.less$/
|
496
|
+
if File.exist? path
|
497
|
+
imported = Less::Engine.new(File.new path).to_tree
|
498
|
+
env.rules += imported.rules
|
499
|
+
else
|
500
|
+
raise ImportError, path
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
def _nt_import
|
506
|
+
start_index = index
|
507
|
+
if node_cache[:import].has_key?(index)
|
508
|
+
cached = node_cache[:import][index]
|
509
|
+
@index = cached.interval.end if cached
|
510
|
+
return cached
|
511
|
+
end
|
512
|
+
|
513
|
+
i0, s0 = index, []
|
514
|
+
if has_terminal?("@import", false, index)
|
515
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
|
516
|
+
@index += 7
|
517
|
+
else
|
518
|
+
terminal_parse_failure("@import")
|
519
|
+
r1 = nil
|
520
|
+
end
|
521
|
+
s0 << r1
|
522
|
+
if r1
|
523
|
+
r2 = _nt_S
|
524
|
+
s0 << r2
|
525
|
+
if r2
|
526
|
+
i3 = index
|
527
|
+
r4 = _nt_string
|
528
|
+
if r4
|
529
|
+
r3 = r4
|
530
|
+
else
|
531
|
+
r5 = _nt_url
|
532
|
+
if r5
|
533
|
+
r3 = r5
|
534
|
+
else
|
535
|
+
@index = i3
|
536
|
+
r3 = nil
|
537
|
+
end
|
538
|
+
end
|
539
|
+
s0 << r3
|
540
|
+
if r3
|
541
|
+
r7 = _nt_medias
|
542
|
+
if r7
|
543
|
+
r6 = r7
|
544
|
+
else
|
545
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
546
|
+
end
|
547
|
+
s0 << r6
|
548
|
+
if r6
|
549
|
+
r8 = _nt_s
|
550
|
+
s0 << r8
|
551
|
+
if r8
|
552
|
+
if has_terminal?(';', false, index)
|
553
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
554
|
+
@index += 1
|
555
|
+
else
|
556
|
+
terminal_parse_failure(';')
|
557
|
+
r9 = nil
|
558
|
+
end
|
559
|
+
s0 << r9
|
560
|
+
if r9
|
561
|
+
r10 = _nt_ws
|
562
|
+
s0 << r10
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
if s0.last
|
570
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
571
|
+
r0.extend(Import0)
|
572
|
+
r0.extend(Import1)
|
573
|
+
else
|
574
|
+
@index = i0
|
575
|
+
r0 = nil
|
576
|
+
end
|
577
|
+
|
578
|
+
node_cache[:import][start_index] = r0
|
579
|
+
|
580
|
+
r0
|
581
|
+
end
|
582
|
+
|
583
|
+
module Url0
|
584
|
+
def path
|
585
|
+
elements[1]
|
586
|
+
end
|
587
|
+
|
588
|
+
end
|
589
|
+
|
590
|
+
module Url1
|
591
|
+
def build env = nil
|
592
|
+
Node::String.new(CGI.unescape path.text_value)
|
593
|
+
end
|
594
|
+
|
595
|
+
def value
|
596
|
+
build
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
def _nt_url
|
601
|
+
start_index = index
|
602
|
+
if node_cache[:url].has_key?(index)
|
603
|
+
cached = node_cache[:url][index]
|
604
|
+
@index = cached.interval.end if cached
|
605
|
+
return cached
|
606
|
+
end
|
607
|
+
|
608
|
+
i0, s0 = index, []
|
609
|
+
if has_terminal?('url(', false, index)
|
610
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
611
|
+
@index += 4
|
612
|
+
else
|
613
|
+
terminal_parse_failure('url(')
|
614
|
+
r1 = nil
|
615
|
+
end
|
616
|
+
s0 << r1
|
617
|
+
if r1
|
618
|
+
i2 = index
|
619
|
+
r3 = _nt_string
|
620
|
+
if r3
|
621
|
+
r2 = r3
|
622
|
+
else
|
623
|
+
s4, i4 = [], index
|
624
|
+
loop do
|
625
|
+
if has_terminal?('[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
|
626
|
+
r5 = true
|
627
|
+
@index += 1
|
628
|
+
else
|
629
|
+
r5 = nil
|
630
|
+
end
|
631
|
+
if r5
|
632
|
+
s4 << r5
|
633
|
+
else
|
634
|
+
break
|
635
|
+
end
|
636
|
+
end
|
637
|
+
if s4.empty?
|
638
|
+
@index = i4
|
639
|
+
r4 = nil
|
640
|
+
else
|
641
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
642
|
+
end
|
643
|
+
if r4
|
644
|
+
r2 = r4
|
645
|
+
else
|
646
|
+
@index = i2
|
647
|
+
r2 = nil
|
648
|
+
end
|
649
|
+
end
|
650
|
+
s0 << r2
|
651
|
+
if r2
|
652
|
+
if has_terminal?(')', false, index)
|
653
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
654
|
+
@index += 1
|
655
|
+
else
|
656
|
+
terminal_parse_failure(')')
|
657
|
+
r6 = nil
|
658
|
+
end
|
659
|
+
s0 << r6
|
660
|
+
end
|
661
|
+
end
|
662
|
+
if s0.last
|
663
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
664
|
+
r0.extend(Url0)
|
665
|
+
r0.extend(Url1)
|
666
|
+
else
|
667
|
+
@index = i0
|
668
|
+
r0 = nil
|
669
|
+
end
|
670
|
+
|
671
|
+
node_cache[:url][start_index] = r0
|
672
|
+
|
673
|
+
r0
|
674
|
+
end
|
675
|
+
|
676
|
+
module Medias0
|
677
|
+
def s
|
678
|
+
elements[0]
|
679
|
+
end
|
680
|
+
|
681
|
+
def s
|
682
|
+
elements[2]
|
683
|
+
end
|
684
|
+
|
685
|
+
end
|
686
|
+
|
687
|
+
module Medias1
|
688
|
+
end
|
689
|
+
|
690
|
+
def _nt_medias
|
691
|
+
start_index = index
|
692
|
+
if node_cache[:medias].has_key?(index)
|
693
|
+
cached = node_cache[:medias][index]
|
694
|
+
@index = cached.interval.end if cached
|
695
|
+
return cached
|
696
|
+
end
|
697
|
+
|
698
|
+
i0, s0 = index, []
|
699
|
+
s1, i1 = [], index
|
700
|
+
loop do
|
701
|
+
if has_terminal?('[-a-z]', true, index)
|
702
|
+
r2 = true
|
703
|
+
@index += 1
|
704
|
+
else
|
705
|
+
r2 = nil
|
706
|
+
end
|
707
|
+
if r2
|
708
|
+
s1 << r2
|
709
|
+
else
|
710
|
+
break
|
711
|
+
end
|
712
|
+
end
|
713
|
+
if s1.empty?
|
714
|
+
@index = i1
|
715
|
+
r1 = nil
|
716
|
+
else
|
717
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
718
|
+
end
|
719
|
+
s0 << r1
|
720
|
+
if r1
|
721
|
+
s3, i3 = [], index
|
722
|
+
loop do
|
723
|
+
i4, s4 = index, []
|
724
|
+
r5 = _nt_s
|
725
|
+
s4 << r5
|
726
|
+
if r5
|
727
|
+
if has_terminal?(',', false, index)
|
728
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
729
|
+
@index += 1
|
730
|
+
else
|
731
|
+
terminal_parse_failure(',')
|
732
|
+
r6 = nil
|
733
|
+
end
|
734
|
+
s4 << r6
|
735
|
+
if r6
|
736
|
+
r7 = _nt_s
|
737
|
+
s4 << r7
|
738
|
+
if r7
|
739
|
+
s8, i8 = [], index
|
740
|
+
loop do
|
741
|
+
if has_terminal?('[a-z]', true, index)
|
742
|
+
r9 = true
|
743
|
+
@index += 1
|
744
|
+
else
|
745
|
+
r9 = nil
|
746
|
+
end
|
747
|
+
if r9
|
748
|
+
s8 << r9
|
749
|
+
else
|
750
|
+
break
|
751
|
+
end
|
752
|
+
end
|
753
|
+
if s8.empty?
|
754
|
+
@index = i8
|
755
|
+
r8 = nil
|
756
|
+
else
|
757
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
758
|
+
end
|
759
|
+
s4 << r8
|
760
|
+
end
|
761
|
+
end
|
762
|
+
end
|
763
|
+
if s4.last
|
764
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
765
|
+
r4.extend(Medias0)
|
766
|
+
else
|
767
|
+
@index = i4
|
768
|
+
r4 = nil
|
769
|
+
end
|
770
|
+
if r4
|
771
|
+
s3 << r4
|
772
|
+
else
|
773
|
+
break
|
774
|
+
end
|
775
|
+
end
|
776
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
777
|
+
s0 << r3
|
778
|
+
end
|
779
|
+
if s0.last
|
780
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
781
|
+
r0.extend(Medias1)
|
782
|
+
else
|
783
|
+
@index = i0
|
784
|
+
r0 = nil
|
785
|
+
end
|
786
|
+
|
787
|
+
node_cache[:medias][start_index] = r0
|
788
|
+
|
789
|
+
r0
|
790
|
+
end
|
791
|
+
|
792
|
+
module Selectors0
|
793
|
+
def s
|
794
|
+
elements[0]
|
795
|
+
end
|
796
|
+
|
797
|
+
def ws
|
798
|
+
elements[2]
|
799
|
+
end
|
800
|
+
|
801
|
+
def selector
|
802
|
+
elements[3]
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
806
|
+
module Selectors1
|
807
|
+
def ws
|
808
|
+
elements[0]
|
809
|
+
end
|
810
|
+
|
811
|
+
def selector
|
812
|
+
elements[1]
|
813
|
+
end
|
814
|
+
|
815
|
+
def tail
|
816
|
+
elements[2]
|
817
|
+
end
|
818
|
+
|
819
|
+
def ws
|
820
|
+
elements[3]
|
821
|
+
end
|
822
|
+
end
|
823
|
+
|
824
|
+
module Selectors2
|
825
|
+
def build env, method
|
826
|
+
all.map do |e|
|
827
|
+
e.send(method, env) if e.respond_to? method
|
828
|
+
end.compact
|
829
|
+
end
|
830
|
+
|
831
|
+
def all
|
832
|
+
[selector] + tail.elements.map {|e| e.selector }
|
833
|
+
end
|
834
|
+
end
|
835
|
+
|
836
|
+
def _nt_selectors
|
837
|
+
start_index = index
|
838
|
+
if node_cache[:selectors].has_key?(index)
|
839
|
+
cached = node_cache[:selectors][index]
|
840
|
+
@index = cached.interval.end if cached
|
841
|
+
return cached
|
842
|
+
end
|
843
|
+
|
844
|
+
i0, s0 = index, []
|
845
|
+
r1 = _nt_ws
|
846
|
+
s0 << r1
|
847
|
+
if r1
|
848
|
+
r2 = _nt_selector
|
849
|
+
s0 << r2
|
850
|
+
if r2
|
851
|
+
s3, i3 = [], index
|
852
|
+
loop do
|
853
|
+
i4, s4 = index, []
|
854
|
+
r5 = _nt_s
|
855
|
+
s4 << r5
|
856
|
+
if r5
|
857
|
+
if has_terminal?(',', false, index)
|
858
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
859
|
+
@index += 1
|
860
|
+
else
|
861
|
+
terminal_parse_failure(',')
|
862
|
+
r6 = nil
|
863
|
+
end
|
864
|
+
s4 << r6
|
865
|
+
if r6
|
866
|
+
r7 = _nt_ws
|
867
|
+
s4 << r7
|
868
|
+
if r7
|
869
|
+
r8 = _nt_selector
|
870
|
+
s4 << r8
|
871
|
+
end
|
872
|
+
end
|
873
|
+
end
|
874
|
+
if s4.last
|
875
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
876
|
+
r4.extend(Selectors0)
|
877
|
+
else
|
878
|
+
@index = i4
|
879
|
+
r4 = nil
|
880
|
+
end
|
881
|
+
if r4
|
882
|
+
s3 << r4
|
883
|
+
else
|
884
|
+
break
|
885
|
+
end
|
886
|
+
end
|
887
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
888
|
+
s0 << r3
|
889
|
+
if r3
|
890
|
+
r9 = _nt_ws
|
891
|
+
s0 << r9
|
892
|
+
end
|
893
|
+
end
|
894
|
+
end
|
895
|
+
if s0.last
|
896
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
897
|
+
r0.extend(Selectors1)
|
898
|
+
r0.extend(Selectors2)
|
899
|
+
else
|
900
|
+
@index = i0
|
901
|
+
r0 = nil
|
902
|
+
end
|
903
|
+
|
904
|
+
node_cache[:selectors][start_index] = r0
|
905
|
+
|
906
|
+
r0
|
907
|
+
end
|
908
|
+
|
909
|
+
module Selector0
|
910
|
+
def s
|
911
|
+
elements[0]
|
912
|
+
end
|
913
|
+
|
914
|
+
def select
|
915
|
+
elements[1]
|
916
|
+
end
|
917
|
+
|
918
|
+
def element
|
919
|
+
elements[2]
|
920
|
+
end
|
921
|
+
|
922
|
+
def s
|
923
|
+
elements[3]
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
module Selector1
|
928
|
+
def tree env
|
929
|
+
elements.inject(env) do |node, e|
|
930
|
+
node << Node::Element.new(e.element.text_value, e.select.text_value)
|
931
|
+
node.last
|
932
|
+
end
|
933
|
+
end
|
934
|
+
|
935
|
+
def path env
|
936
|
+
elements.map do |e|
|
937
|
+
Node::Element.new(e.element.text_value, e.select.text_value)
|
938
|
+
end
|
939
|
+
end
|
940
|
+
end
|
941
|
+
|
942
|
+
def _nt_selector
|
943
|
+
start_index = index
|
944
|
+
if node_cache[:selector].has_key?(index)
|
945
|
+
cached = node_cache[:selector][index]
|
946
|
+
@index = cached.interval.end if cached
|
947
|
+
return cached
|
948
|
+
end
|
949
|
+
|
950
|
+
s0, i0 = [], index
|
951
|
+
loop do
|
952
|
+
i1, s1 = index, []
|
953
|
+
r2 = _nt_s
|
954
|
+
s1 << r2
|
955
|
+
if r2
|
956
|
+
r3 = _nt_select
|
957
|
+
s1 << r3
|
958
|
+
if r3
|
959
|
+
r4 = _nt_element
|
960
|
+
s1 << r4
|
961
|
+
if r4
|
962
|
+
r5 = _nt_s
|
963
|
+
s1 << r5
|
964
|
+
end
|
965
|
+
end
|
966
|
+
end
|
967
|
+
if s1.last
|
968
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
969
|
+
r1.extend(Selector0)
|
970
|
+
else
|
971
|
+
@index = i1
|
972
|
+
r1 = nil
|
973
|
+
end
|
974
|
+
if r1
|
975
|
+
s0 << r1
|
976
|
+
else
|
977
|
+
break
|
978
|
+
end
|
979
|
+
end
|
980
|
+
if s0.empty?
|
981
|
+
@index = i0
|
982
|
+
r0 = nil
|
983
|
+
else
|
984
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
985
|
+
r0.extend(Selector1)
|
986
|
+
end
|
987
|
+
|
988
|
+
node_cache[:selector][start_index] = r0
|
989
|
+
|
990
|
+
r0
|
991
|
+
end
|
992
|
+
|
993
|
+
module Declaration0
|
994
|
+
def ws
|
995
|
+
elements[0]
|
996
|
+
end
|
997
|
+
|
998
|
+
end
|
999
|
+
|
1000
|
+
module Declaration1
|
1001
|
+
def ws
|
1002
|
+
elements[0]
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
def name
|
1006
|
+
elements[1]
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
def s
|
1010
|
+
elements[2]
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
def s
|
1014
|
+
elements[4]
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
def expression
|
1018
|
+
elements[5]
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
def s
|
1022
|
+
elements[6]
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
def ws
|
1026
|
+
elements[8]
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
module Declaration2
|
1031
|
+
def build env
|
1032
|
+
env << (name.text_value =~ /^@/ ? Node::Variable : Node::Property).new(name.text_value)
|
1033
|
+
expression.build env
|
1034
|
+
end
|
1035
|
+
# Empty rule
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
module Declaration3
|
1039
|
+
def ws
|
1040
|
+
elements[0]
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
def ident
|
1044
|
+
elements[1]
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
def s
|
1048
|
+
elements[2]
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
def s
|
1052
|
+
elements[4]
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
def ws
|
1056
|
+
elements[6]
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
def _nt_declaration
|
1061
|
+
start_index = index
|
1062
|
+
if node_cache[:declaration].has_key?(index)
|
1063
|
+
cached = node_cache[:declaration][index]
|
1064
|
+
@index = cached.interval.end if cached
|
1065
|
+
return cached
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
i0 = index
|
1069
|
+
i1, s1 = index, []
|
1070
|
+
r2 = _nt_ws
|
1071
|
+
s1 << r2
|
1072
|
+
if r2
|
1073
|
+
i3 = index
|
1074
|
+
r4 = _nt_ident
|
1075
|
+
if r4
|
1076
|
+
r3 = r4
|
1077
|
+
else
|
1078
|
+
r5 = _nt_variable
|
1079
|
+
if r5
|
1080
|
+
r3 = r5
|
1081
|
+
else
|
1082
|
+
@index = i3
|
1083
|
+
r3 = nil
|
1084
|
+
end
|
1085
|
+
end
|
1086
|
+
s1 << r3
|
1087
|
+
if r3
|
1088
|
+
r6 = _nt_s
|
1089
|
+
s1 << r6
|
1090
|
+
if r6
|
1091
|
+
if has_terminal?(':', false, index)
|
1092
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1093
|
+
@index += 1
|
1094
|
+
else
|
1095
|
+
terminal_parse_failure(':')
|
1096
|
+
r7 = nil
|
1097
|
+
end
|
1098
|
+
s1 << r7
|
1099
|
+
if r7
|
1100
|
+
r8 = _nt_s
|
1101
|
+
s1 << r8
|
1102
|
+
if r8
|
1103
|
+
r9 = _nt_expression
|
1104
|
+
s1 << r9
|
1105
|
+
if r9
|
1106
|
+
r10 = _nt_s
|
1107
|
+
s1 << r10
|
1108
|
+
if r10
|
1109
|
+
i11 = index
|
1110
|
+
if has_terminal?(';', false, index)
|
1111
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1112
|
+
@index += 1
|
1113
|
+
else
|
1114
|
+
terminal_parse_failure(';')
|
1115
|
+
r12 = nil
|
1116
|
+
end
|
1117
|
+
if r12
|
1118
|
+
r11 = r12
|
1119
|
+
else
|
1120
|
+
i13, s13 = index, []
|
1121
|
+
r14 = _nt_ws
|
1122
|
+
s13 << r14
|
1123
|
+
if r14
|
1124
|
+
i15 = index
|
1125
|
+
if has_terminal?('}', false, index)
|
1126
|
+
r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1127
|
+
@index += 1
|
1128
|
+
else
|
1129
|
+
terminal_parse_failure('}')
|
1130
|
+
r16 = nil
|
1131
|
+
end
|
1132
|
+
if r16
|
1133
|
+
@index = i15
|
1134
|
+
r15 = instantiate_node(SyntaxNode,input, index...index)
|
1135
|
+
else
|
1136
|
+
r15 = nil
|
1137
|
+
end
|
1138
|
+
s13 << r15
|
1139
|
+
end
|
1140
|
+
if s13.last
|
1141
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
1142
|
+
r13.extend(Declaration0)
|
1143
|
+
else
|
1144
|
+
@index = i13
|
1145
|
+
r13 = nil
|
1146
|
+
end
|
1147
|
+
if r13
|
1148
|
+
r11 = r13
|
1149
|
+
else
|
1150
|
+
@index = i11
|
1151
|
+
r11 = nil
|
1152
|
+
end
|
1153
|
+
end
|
1154
|
+
s1 << r11
|
1155
|
+
if r11
|
1156
|
+
r17 = _nt_ws
|
1157
|
+
s1 << r17
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
end
|
1161
|
+
end
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
end
|
1165
|
+
end
|
1166
|
+
if s1.last
|
1167
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1168
|
+
r1.extend(Declaration1)
|
1169
|
+
r1.extend(Declaration2)
|
1170
|
+
else
|
1171
|
+
@index = i1
|
1172
|
+
r1 = nil
|
1173
|
+
end
|
1174
|
+
if r1
|
1175
|
+
r0 = r1
|
1176
|
+
else
|
1177
|
+
i18, s18 = index, []
|
1178
|
+
r19 = _nt_ws
|
1179
|
+
s18 << r19
|
1180
|
+
if r19
|
1181
|
+
r20 = _nt_ident
|
1182
|
+
s18 << r20
|
1183
|
+
if r20
|
1184
|
+
r21 = _nt_s
|
1185
|
+
s18 << r21
|
1186
|
+
if r21
|
1187
|
+
if has_terminal?(':', false, index)
|
1188
|
+
r22 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1189
|
+
@index += 1
|
1190
|
+
else
|
1191
|
+
terminal_parse_failure(':')
|
1192
|
+
r22 = nil
|
1193
|
+
end
|
1194
|
+
s18 << r22
|
1195
|
+
if r22
|
1196
|
+
r23 = _nt_s
|
1197
|
+
s18 << r23
|
1198
|
+
if r23
|
1199
|
+
if has_terminal?(';', false, index)
|
1200
|
+
r24 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1201
|
+
@index += 1
|
1202
|
+
else
|
1203
|
+
terminal_parse_failure(';')
|
1204
|
+
r24 = nil
|
1205
|
+
end
|
1206
|
+
s18 << r24
|
1207
|
+
if r24
|
1208
|
+
r25 = _nt_ws
|
1209
|
+
s18 << r25
|
1210
|
+
end
|
1211
|
+
end
|
1212
|
+
end
|
1213
|
+
end
|
1214
|
+
end
|
1215
|
+
end
|
1216
|
+
if s18.last
|
1217
|
+
r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
|
1218
|
+
r18.extend(Declaration3)
|
1219
|
+
else
|
1220
|
+
@index = i18
|
1221
|
+
r18 = nil
|
1222
|
+
end
|
1223
|
+
if r18
|
1224
|
+
r0 = r18
|
1225
|
+
else
|
1226
|
+
@index = i0
|
1227
|
+
r0 = nil
|
1228
|
+
end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
node_cache[:declaration][start_index] = r0
|
1232
|
+
|
1233
|
+
r0
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
module Expression0
|
1237
|
+
def entity
|
1238
|
+
elements[0]
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
def expression
|
1242
|
+
elements[2]
|
1243
|
+
end
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
def _nt_expression
|
1247
|
+
start_index = index
|
1248
|
+
if node_cache[:expression].has_key?(index)
|
1249
|
+
cached = node_cache[:expression][index]
|
1250
|
+
@index = cached.interval.end if cached
|
1251
|
+
return cached
|
1252
|
+
end
|
1253
|
+
|
1254
|
+
i0 = index
|
1255
|
+
i1, s1 = index, []
|
1256
|
+
r2 = _nt_entity
|
1257
|
+
s1 << r2
|
1258
|
+
if r2
|
1259
|
+
i3 = index
|
1260
|
+
r4 = _nt_operator
|
1261
|
+
if r4
|
1262
|
+
r3 = r4
|
1263
|
+
else
|
1264
|
+
r5 = _nt_S
|
1265
|
+
if r5
|
1266
|
+
r3 = r5
|
1267
|
+
else
|
1268
|
+
@index = i3
|
1269
|
+
r3 = nil
|
1270
|
+
end
|
1271
|
+
end
|
1272
|
+
s1 << r3
|
1273
|
+
if r3
|
1274
|
+
r6 = _nt_expression
|
1275
|
+
s1 << r6
|
1276
|
+
end
|
1277
|
+
end
|
1278
|
+
if s1.last
|
1279
|
+
r1 = instantiate_node(Builder,input, i1...index, s1)
|
1280
|
+
r1.extend(Expression0)
|
1281
|
+
else
|
1282
|
+
@index = i1
|
1283
|
+
r1 = nil
|
1284
|
+
end
|
1285
|
+
if r1
|
1286
|
+
r0 = r1
|
1287
|
+
else
|
1288
|
+
r7 = _nt_entity
|
1289
|
+
if r7
|
1290
|
+
r0 = r7
|
1291
|
+
else
|
1292
|
+
@index = i0
|
1293
|
+
r0 = nil
|
1294
|
+
end
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
node_cache[:expression][start_index] = r0
|
1298
|
+
|
1299
|
+
r0
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
def _nt_entity
|
1303
|
+
start_index = index
|
1304
|
+
if node_cache[:entity].has_key?(index)
|
1305
|
+
cached = node_cache[:entity][index]
|
1306
|
+
@index = cached.interval.end if cached
|
1307
|
+
return cached
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
i0 = index
|
1311
|
+
r1 = _nt_function
|
1312
|
+
if r1
|
1313
|
+
r0 = r1
|
1314
|
+
else
|
1315
|
+
r2 = _nt_fonts
|
1316
|
+
if r2
|
1317
|
+
r0 = r2
|
1318
|
+
else
|
1319
|
+
r3 = _nt_keyword
|
1320
|
+
if r3
|
1321
|
+
r0 = r3
|
1322
|
+
else
|
1323
|
+
r4 = _nt_accessor
|
1324
|
+
if r4
|
1325
|
+
r0 = r4
|
1326
|
+
else
|
1327
|
+
r5 = _nt_variable
|
1328
|
+
if r5
|
1329
|
+
r0 = r5
|
1330
|
+
else
|
1331
|
+
r6 = _nt_literal
|
1332
|
+
if r6
|
1333
|
+
r0 = r6
|
1334
|
+
else
|
1335
|
+
r7 = _nt_important
|
1336
|
+
if r7
|
1337
|
+
r0 = r7
|
1338
|
+
else
|
1339
|
+
@index = i0
|
1340
|
+
r0 = nil
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
end
|
1344
|
+
end
|
1345
|
+
end
|
1346
|
+
end
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
node_cache[:entity][start_index] = r0
|
1350
|
+
|
1351
|
+
r0
|
1352
|
+
end
|
1353
|
+
|
1354
|
+
module Fonts0
|
1355
|
+
def s
|
1356
|
+
elements[0]
|
1357
|
+
end
|
1358
|
+
|
1359
|
+
def s
|
1360
|
+
elements[2]
|
1361
|
+
end
|
1362
|
+
|
1363
|
+
def font
|
1364
|
+
elements[3]
|
1365
|
+
end
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
module Fonts1
|
1369
|
+
def font
|
1370
|
+
elements[0]
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
def family
|
1374
|
+
elements[1]
|
1375
|
+
end
|
1376
|
+
end
|
1377
|
+
|
1378
|
+
module Fonts2
|
1379
|
+
def build env
|
1380
|
+
fonts = ([font] + family.elements.map {|f| f.font }).map do |font|
|
1381
|
+
font.build env
|
1382
|
+
end
|
1383
|
+
env.identifiers.last << Node::FontFamily.new(fonts)
|
1384
|
+
end
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
def _nt_fonts
|
1388
|
+
start_index = index
|
1389
|
+
if node_cache[:fonts].has_key?(index)
|
1390
|
+
cached = node_cache[:fonts][index]
|
1391
|
+
@index = cached.interval.end if cached
|
1392
|
+
return cached
|
1393
|
+
end
|
1394
|
+
|
1395
|
+
i0, s0 = index, []
|
1396
|
+
r1 = _nt_font
|
1397
|
+
s0 << r1
|
1398
|
+
if r1
|
1399
|
+
s2, i2 = [], index
|
1400
|
+
loop do
|
1401
|
+
i3, s3 = index, []
|
1402
|
+
r4 = _nt_s
|
1403
|
+
s3 << r4
|
1404
|
+
if r4
|
1405
|
+
if has_terminal?(',', false, index)
|
1406
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1407
|
+
@index += 1
|
1408
|
+
else
|
1409
|
+
terminal_parse_failure(',')
|
1410
|
+
r5 = nil
|
1411
|
+
end
|
1412
|
+
s3 << r5
|
1413
|
+
if r5
|
1414
|
+
r6 = _nt_s
|
1415
|
+
s3 << r6
|
1416
|
+
if r6
|
1417
|
+
r7 = _nt_font
|
1418
|
+
s3 << r7
|
1419
|
+
end
|
1420
|
+
end
|
1421
|
+
end
|
1422
|
+
if s3.last
|
1423
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1424
|
+
r3.extend(Fonts0)
|
1425
|
+
else
|
1426
|
+
@index = i3
|
1427
|
+
r3 = nil
|
1428
|
+
end
|
1429
|
+
if r3
|
1430
|
+
s2 << r3
|
1431
|
+
else
|
1432
|
+
break
|
1433
|
+
end
|
1434
|
+
end
|
1435
|
+
if s2.empty?
|
1436
|
+
@index = i2
|
1437
|
+
r2 = nil
|
1438
|
+
else
|
1439
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1440
|
+
end
|
1441
|
+
s0 << r2
|
1442
|
+
end
|
1443
|
+
if s0.last
|
1444
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1445
|
+
r0.extend(Fonts1)
|
1446
|
+
r0.extend(Fonts2)
|
1447
|
+
else
|
1448
|
+
@index = i0
|
1449
|
+
r0 = nil
|
1450
|
+
end
|
1451
|
+
|
1452
|
+
node_cache[:fonts][start_index] = r0
|
1453
|
+
|
1454
|
+
r0
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
module Font0
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
module Font1
|
1461
|
+
def build env
|
1462
|
+
Node::Keyword.new(text_value)
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
module Font2
|
1467
|
+
def build env
|
1468
|
+
Node::String.new(text_value)
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
|
1472
|
+
def _nt_font
|
1473
|
+
start_index = index
|
1474
|
+
if node_cache[:font].has_key?(index)
|
1475
|
+
cached = node_cache[:font][index]
|
1476
|
+
@index = cached.interval.end if cached
|
1477
|
+
return cached
|
1478
|
+
end
|
1479
|
+
|
1480
|
+
i0 = index
|
1481
|
+
i1, s1 = index, []
|
1482
|
+
if has_terminal?('[a-zA-Z]', true, index)
|
1483
|
+
r2 = true
|
1484
|
+
@index += 1
|
1485
|
+
else
|
1486
|
+
r2 = nil
|
1487
|
+
end
|
1488
|
+
s1 << r2
|
1489
|
+
if r2
|
1490
|
+
s3, i3 = [], index
|
1491
|
+
loop do
|
1492
|
+
if has_terminal?('[-a-zA-Z0-9]', true, index)
|
1493
|
+
r4 = true
|
1494
|
+
@index += 1
|
1495
|
+
else
|
1496
|
+
r4 = nil
|
1497
|
+
end
|
1498
|
+
if r4
|
1499
|
+
s3 << r4
|
1500
|
+
else
|
1501
|
+
break
|
1502
|
+
end
|
1503
|
+
end
|
1504
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1505
|
+
s1 << r3
|
1506
|
+
end
|
1507
|
+
if s1.last
|
1508
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1509
|
+
r1.extend(Font0)
|
1510
|
+
r1.extend(Font1)
|
1511
|
+
else
|
1512
|
+
@index = i1
|
1513
|
+
r1 = nil
|
1514
|
+
end
|
1515
|
+
if r1
|
1516
|
+
r0 = r1
|
1517
|
+
else
|
1518
|
+
r5 = _nt_string
|
1519
|
+
r5.extend(Font2)
|
1520
|
+
if r5
|
1521
|
+
r0 = r5
|
1522
|
+
else
|
1523
|
+
@index = i0
|
1524
|
+
r0 = nil
|
1525
|
+
end
|
1526
|
+
end
|
1527
|
+
|
1528
|
+
node_cache[:font][start_index] = r0
|
1529
|
+
|
1530
|
+
r0
|
1531
|
+
end
|
1532
|
+
|
1533
|
+
module Ident0
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
def _nt_ident
|
1537
|
+
start_index = index
|
1538
|
+
if node_cache[:ident].has_key?(index)
|
1539
|
+
cached = node_cache[:ident][index]
|
1540
|
+
@index = cached.interval.end if cached
|
1541
|
+
return cached
|
1542
|
+
end
|
1543
|
+
|
1544
|
+
i0, s0 = index, []
|
1545
|
+
if has_terminal?('-', false, index)
|
1546
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1547
|
+
@index += 1
|
1548
|
+
else
|
1549
|
+
terminal_parse_failure('-')
|
1550
|
+
r2 = nil
|
1551
|
+
end
|
1552
|
+
if r2
|
1553
|
+
r1 = r2
|
1554
|
+
else
|
1555
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
1556
|
+
end
|
1557
|
+
s0 << r1
|
1558
|
+
if r1
|
1559
|
+
s3, i3 = [], index
|
1560
|
+
loop do
|
1561
|
+
if has_terminal?('[-a-z0-9_]', true, index)
|
1562
|
+
r4 = true
|
1563
|
+
@index += 1
|
1564
|
+
else
|
1565
|
+
r4 = nil
|
1566
|
+
end
|
1567
|
+
if r4
|
1568
|
+
s3 << r4
|
1569
|
+
else
|
1570
|
+
break
|
1571
|
+
end
|
1572
|
+
end
|
1573
|
+
if s3.empty?
|
1574
|
+
@index = i3
|
1575
|
+
r3 = nil
|
1576
|
+
else
|
1577
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1578
|
+
end
|
1579
|
+
s0 << r3
|
1580
|
+
end
|
1581
|
+
if s0.last
|
1582
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1583
|
+
r0.extend(Ident0)
|
1584
|
+
else
|
1585
|
+
@index = i0
|
1586
|
+
r0 = nil
|
1587
|
+
end
|
1588
|
+
|
1589
|
+
node_cache[:ident][start_index] = r0
|
1590
|
+
|
1591
|
+
r0
|
1592
|
+
end
|
1593
|
+
|
1594
|
+
module Variable0
|
1595
|
+
end
|
1596
|
+
|
1597
|
+
module Variable1
|
1598
|
+
def build env
|
1599
|
+
env.identifiers.last << env.nearest(text_value)
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
def _nt_variable
|
1604
|
+
start_index = index
|
1605
|
+
if node_cache[:variable].has_key?(index)
|
1606
|
+
cached = node_cache[:variable][index]
|
1607
|
+
@index = cached.interval.end if cached
|
1608
|
+
return cached
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
i0, s0 = index, []
|
1612
|
+
if has_terminal?('@', false, index)
|
1613
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1614
|
+
@index += 1
|
1615
|
+
else
|
1616
|
+
terminal_parse_failure('@')
|
1617
|
+
r1 = nil
|
1618
|
+
end
|
1619
|
+
s0 << r1
|
1620
|
+
if r1
|
1621
|
+
s2, i2 = [], index
|
1622
|
+
loop do
|
1623
|
+
if has_terminal?('[-a-zA-Z0-9_]', true, index)
|
1624
|
+
r3 = true
|
1625
|
+
@index += 1
|
1626
|
+
else
|
1627
|
+
r3 = nil
|
1628
|
+
end
|
1629
|
+
if r3
|
1630
|
+
s2 << r3
|
1631
|
+
else
|
1632
|
+
break
|
1633
|
+
end
|
1634
|
+
end
|
1635
|
+
if s2.empty?
|
1636
|
+
@index = i2
|
1637
|
+
r2 = nil
|
1638
|
+
else
|
1639
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1640
|
+
end
|
1641
|
+
s0 << r2
|
1642
|
+
end
|
1643
|
+
if s0.last
|
1644
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1645
|
+
r0.extend(Variable0)
|
1646
|
+
r0.extend(Variable1)
|
1647
|
+
else
|
1648
|
+
@index = i0
|
1649
|
+
r0 = nil
|
1650
|
+
end
|
1651
|
+
|
1652
|
+
node_cache[:variable][start_index] = r0
|
1653
|
+
|
1654
|
+
r0
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
module Element0
|
1658
|
+
def ident
|
1659
|
+
elements[1]
|
1660
|
+
end
|
1661
|
+
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
module Element1
|
1665
|
+
end
|
1666
|
+
|
1667
|
+
def _nt_element
|
1668
|
+
start_index = index
|
1669
|
+
if node_cache[:element].has_key?(index)
|
1670
|
+
cached = node_cache[:element][index]
|
1671
|
+
@index = cached.interval.end if cached
|
1672
|
+
return cached
|
1673
|
+
end
|
1674
|
+
|
1675
|
+
i0 = index
|
1676
|
+
i1, s1 = index, []
|
1677
|
+
i2 = index
|
1678
|
+
r3 = _nt_class_id
|
1679
|
+
if r3
|
1680
|
+
r2 = r3
|
1681
|
+
else
|
1682
|
+
r4 = _nt_tag
|
1683
|
+
if r4
|
1684
|
+
r2 = r4
|
1685
|
+
else
|
1686
|
+
r5 = _nt_ident
|
1687
|
+
if r5
|
1688
|
+
r2 = r5
|
1689
|
+
else
|
1690
|
+
@index = i2
|
1691
|
+
r2 = nil
|
1692
|
+
end
|
1693
|
+
end
|
1694
|
+
end
|
1695
|
+
s1 << r2
|
1696
|
+
if r2
|
1697
|
+
s6, i6 = [], index
|
1698
|
+
loop do
|
1699
|
+
r7 = _nt_attribute
|
1700
|
+
if r7
|
1701
|
+
s6 << r7
|
1702
|
+
else
|
1703
|
+
break
|
1704
|
+
end
|
1705
|
+
end
|
1706
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1707
|
+
s1 << r6
|
1708
|
+
if r6
|
1709
|
+
i9, s9 = index, []
|
1710
|
+
if has_terminal?('(', false, index)
|
1711
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1712
|
+
@index += 1
|
1713
|
+
else
|
1714
|
+
terminal_parse_failure('(')
|
1715
|
+
r10 = nil
|
1716
|
+
end
|
1717
|
+
s9 << r10
|
1718
|
+
if r10
|
1719
|
+
r11 = _nt_ident
|
1720
|
+
s9 << r11
|
1721
|
+
if r11
|
1722
|
+
if has_terminal?(')', false, index)
|
1723
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1724
|
+
@index += 1
|
1725
|
+
else
|
1726
|
+
terminal_parse_failure(')')
|
1727
|
+
r12 = nil
|
1728
|
+
end
|
1729
|
+
s9 << r12
|
1730
|
+
end
|
1731
|
+
end
|
1732
|
+
if s9.last
|
1733
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1734
|
+
r9.extend(Element0)
|
1735
|
+
else
|
1736
|
+
@index = i9
|
1737
|
+
r9 = nil
|
1738
|
+
end
|
1739
|
+
if r9
|
1740
|
+
r8 = r9
|
1741
|
+
else
|
1742
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
1743
|
+
end
|
1744
|
+
s1 << r8
|
1745
|
+
end
|
1746
|
+
end
|
1747
|
+
if s1.last
|
1748
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1749
|
+
r1.extend(Element1)
|
1750
|
+
else
|
1751
|
+
@index = i1
|
1752
|
+
r1 = nil
|
1753
|
+
end
|
1754
|
+
if r1
|
1755
|
+
r0 = r1
|
1756
|
+
else
|
1757
|
+
if has_terminal?('@media', false, index)
|
1758
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + 6))
|
1759
|
+
@index += 6
|
1760
|
+
else
|
1761
|
+
terminal_parse_failure('@media')
|
1762
|
+
r13 = nil
|
1763
|
+
end
|
1764
|
+
if r13
|
1765
|
+
r0 = r13
|
1766
|
+
else
|
1767
|
+
if has_terminal?('@font-face', false, index)
|
1768
|
+
r14 = instantiate_node(SyntaxNode,input, index...(index + 10))
|
1769
|
+
@index += 10
|
1770
|
+
else
|
1771
|
+
terminal_parse_failure('@font-face')
|
1772
|
+
r14 = nil
|
1773
|
+
end
|
1774
|
+
if r14
|
1775
|
+
r0 = r14
|
1776
|
+
else
|
1777
|
+
@index = i0
|
1778
|
+
r0 = nil
|
1779
|
+
end
|
1780
|
+
end
|
1781
|
+
end
|
1782
|
+
|
1783
|
+
node_cache[:element][start_index] = r0
|
1784
|
+
|
1785
|
+
r0
|
1786
|
+
end
|
1787
|
+
|
1788
|
+
module ClassId0
|
1789
|
+
end
|
1790
|
+
|
1791
|
+
module ClassId1
|
1792
|
+
def id
|
1793
|
+
elements[1]
|
1794
|
+
end
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
def _nt_class_id
|
1798
|
+
start_index = index
|
1799
|
+
if node_cache[:class_id].has_key?(index)
|
1800
|
+
cached = node_cache[:class_id][index]
|
1801
|
+
@index = cached.interval.end if cached
|
1802
|
+
return cached
|
1803
|
+
end
|
1804
|
+
|
1805
|
+
i0 = index
|
1806
|
+
i1, s1 = index, []
|
1807
|
+
r3 = _nt_tag
|
1808
|
+
if r3
|
1809
|
+
r2 = r3
|
1810
|
+
else
|
1811
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
1812
|
+
end
|
1813
|
+
s1 << r2
|
1814
|
+
if r2
|
1815
|
+
s4, i4 = [], index
|
1816
|
+
loop do
|
1817
|
+
r5 = _nt_class
|
1818
|
+
if r5
|
1819
|
+
s4 << r5
|
1820
|
+
else
|
1821
|
+
break
|
1822
|
+
end
|
1823
|
+
end
|
1824
|
+
if s4.empty?
|
1825
|
+
@index = i4
|
1826
|
+
r4 = nil
|
1827
|
+
else
|
1828
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1829
|
+
end
|
1830
|
+
s1 << r4
|
1831
|
+
end
|
1832
|
+
if s1.last
|
1833
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1834
|
+
r1.extend(ClassId0)
|
1835
|
+
else
|
1836
|
+
@index = i1
|
1837
|
+
r1 = nil
|
1838
|
+
end
|
1839
|
+
if r1
|
1840
|
+
r0 = r1
|
1841
|
+
else
|
1842
|
+
i6, s6 = index, []
|
1843
|
+
r8 = _nt_tag
|
1844
|
+
if r8
|
1845
|
+
r7 = r8
|
1846
|
+
else
|
1847
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1848
|
+
end
|
1849
|
+
s6 << r7
|
1850
|
+
if r7
|
1851
|
+
r9 = _nt_id
|
1852
|
+
s6 << r9
|
1853
|
+
end
|
1854
|
+
if s6.last
|
1855
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1856
|
+
r6.extend(ClassId1)
|
1857
|
+
else
|
1858
|
+
@index = i6
|
1859
|
+
r6 = nil
|
1860
|
+
end
|
1861
|
+
if r6
|
1862
|
+
r0 = r6
|
1863
|
+
else
|
1864
|
+
@index = i0
|
1865
|
+
r0 = nil
|
1866
|
+
end
|
1867
|
+
end
|
1868
|
+
|
1869
|
+
node_cache[:class_id][start_index] = r0
|
1870
|
+
|
1871
|
+
r0
|
1872
|
+
end
|
1873
|
+
|
1874
|
+
module Attribute0
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
module Attribute1
|
1878
|
+
end
|
1879
|
+
|
1880
|
+
def _nt_attribute
|
1881
|
+
start_index = index
|
1882
|
+
if node_cache[:attribute].has_key?(index)
|
1883
|
+
cached = node_cache[:attribute][index]
|
1884
|
+
@index = cached.interval.end if cached
|
1885
|
+
return cached
|
1886
|
+
end
|
1887
|
+
|
1888
|
+
i0, s0 = index, []
|
1889
|
+
if has_terminal?('[', false, index)
|
1890
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1891
|
+
@index += 1
|
1892
|
+
else
|
1893
|
+
terminal_parse_failure('[')
|
1894
|
+
r1 = nil
|
1895
|
+
end
|
1896
|
+
s0 << r1
|
1897
|
+
if r1
|
1898
|
+
s2, i2 = [], index
|
1899
|
+
loop do
|
1900
|
+
if has_terminal?('[a-z]', true, index)
|
1901
|
+
r3 = true
|
1902
|
+
@index += 1
|
1903
|
+
else
|
1904
|
+
r3 = nil
|
1905
|
+
end
|
1906
|
+
if r3
|
1907
|
+
s2 << r3
|
1908
|
+
else
|
1909
|
+
break
|
1910
|
+
end
|
1911
|
+
end
|
1912
|
+
if s2.empty?
|
1913
|
+
@index = i2
|
1914
|
+
r2 = nil
|
1915
|
+
else
|
1916
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1917
|
+
end
|
1918
|
+
s0 << r2
|
1919
|
+
if r2
|
1920
|
+
i5, s5 = index, []
|
1921
|
+
if has_terminal?('[|~]', true, index)
|
1922
|
+
r7 = true
|
1923
|
+
@index += 1
|
1924
|
+
else
|
1925
|
+
r7 = nil
|
1926
|
+
end
|
1927
|
+
if r7
|
1928
|
+
r6 = r7
|
1929
|
+
else
|
1930
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
1931
|
+
end
|
1932
|
+
s5 << r6
|
1933
|
+
if r6
|
1934
|
+
if has_terminal?('=', false, index)
|
1935
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1936
|
+
@index += 1
|
1937
|
+
else
|
1938
|
+
terminal_parse_failure('=')
|
1939
|
+
r8 = nil
|
1940
|
+
end
|
1941
|
+
s5 << r8
|
1942
|
+
end
|
1943
|
+
if s5.last
|
1944
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1945
|
+
r5.extend(Attribute0)
|
1946
|
+
else
|
1947
|
+
@index = i5
|
1948
|
+
r5 = nil
|
1949
|
+
end
|
1950
|
+
if r5
|
1951
|
+
r4 = r5
|
1952
|
+
else
|
1953
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1954
|
+
end
|
1955
|
+
s0 << r4
|
1956
|
+
if r4
|
1957
|
+
i9 = index
|
1958
|
+
r10 = _nt_tag
|
1959
|
+
if r10
|
1960
|
+
r9 = r10
|
1961
|
+
else
|
1962
|
+
r11 = _nt_string
|
1963
|
+
if r11
|
1964
|
+
r9 = r11
|
1965
|
+
else
|
1966
|
+
@index = i9
|
1967
|
+
r9 = nil
|
1968
|
+
end
|
1969
|
+
end
|
1970
|
+
s0 << r9
|
1971
|
+
if r9
|
1972
|
+
if has_terminal?(']', false, index)
|
1973
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1974
|
+
@index += 1
|
1975
|
+
else
|
1976
|
+
terminal_parse_failure(']')
|
1977
|
+
r12 = nil
|
1978
|
+
end
|
1979
|
+
s0 << r12
|
1980
|
+
end
|
1981
|
+
end
|
1982
|
+
end
|
1983
|
+
end
|
1984
|
+
if s0.last
|
1985
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1986
|
+
r0.extend(Attribute1)
|
1987
|
+
else
|
1988
|
+
@index = i0
|
1989
|
+
r0 = nil
|
1990
|
+
end
|
1991
|
+
|
1992
|
+
node_cache[:attribute][start_index] = r0
|
1993
|
+
|
1994
|
+
r0
|
1995
|
+
end
|
1996
|
+
|
1997
|
+
module Class0
|
1998
|
+
end
|
1999
|
+
|
2000
|
+
def _nt_class
|
2001
|
+
start_index = index
|
2002
|
+
if node_cache[:class].has_key?(index)
|
2003
|
+
cached = node_cache[:class][index]
|
2004
|
+
@index = cached.interval.end if cached
|
2005
|
+
return cached
|
2006
|
+
end
|
2007
|
+
|
2008
|
+
i0, s0 = index, []
|
2009
|
+
if has_terminal?('.', false, index)
|
2010
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2011
|
+
@index += 1
|
2012
|
+
else
|
2013
|
+
terminal_parse_failure('.')
|
2014
|
+
r1 = nil
|
2015
|
+
end
|
2016
|
+
s0 << r1
|
2017
|
+
if r1
|
2018
|
+
if has_terminal?('[_a-z]', true, index)
|
2019
|
+
r2 = true
|
2020
|
+
@index += 1
|
2021
|
+
else
|
2022
|
+
r2 = nil
|
2023
|
+
end
|
2024
|
+
s0 << r2
|
2025
|
+
if r2
|
2026
|
+
s3, i3 = [], index
|
2027
|
+
loop do
|
2028
|
+
if has_terminal?('[-a-zA-Z0-9_]', true, index)
|
2029
|
+
r4 = true
|
2030
|
+
@index += 1
|
2031
|
+
else
|
2032
|
+
r4 = nil
|
2033
|
+
end
|
2034
|
+
if r4
|
2035
|
+
s3 << r4
|
2036
|
+
else
|
2037
|
+
break
|
2038
|
+
end
|
2039
|
+
end
|
2040
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2041
|
+
s0 << r3
|
2042
|
+
end
|
2043
|
+
end
|
2044
|
+
if s0.last
|
2045
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2046
|
+
r0.extend(Class0)
|
2047
|
+
else
|
2048
|
+
@index = i0
|
2049
|
+
r0 = nil
|
2050
|
+
end
|
2051
|
+
|
2052
|
+
node_cache[:class][start_index] = r0
|
2053
|
+
|
2054
|
+
r0
|
2055
|
+
end
|
2056
|
+
|
2057
|
+
module Id0
|
2058
|
+
end
|
2059
|
+
|
2060
|
+
def _nt_id
|
2061
|
+
start_index = index
|
2062
|
+
if node_cache[:id].has_key?(index)
|
2063
|
+
cached = node_cache[:id][index]
|
2064
|
+
@index = cached.interval.end if cached
|
2065
|
+
return cached
|
2066
|
+
end
|
2067
|
+
|
2068
|
+
i0, s0 = index, []
|
2069
|
+
if has_terminal?('#', false, index)
|
2070
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2071
|
+
@index += 1
|
2072
|
+
else
|
2073
|
+
terminal_parse_failure('#')
|
2074
|
+
r1 = nil
|
2075
|
+
end
|
2076
|
+
s0 << r1
|
2077
|
+
if r1
|
2078
|
+
if has_terminal?('[_a-z]', true, index)
|
2079
|
+
r2 = true
|
2080
|
+
@index += 1
|
2081
|
+
else
|
2082
|
+
r2 = nil
|
2083
|
+
end
|
2084
|
+
s0 << r2
|
2085
|
+
if r2
|
2086
|
+
s3, i3 = [], index
|
2087
|
+
loop do
|
2088
|
+
if has_terminal?('[-a-zA-Z0-9_]', true, index)
|
2089
|
+
r4 = true
|
2090
|
+
@index += 1
|
2091
|
+
else
|
2092
|
+
r4 = nil
|
2093
|
+
end
|
2094
|
+
if r4
|
2095
|
+
s3 << r4
|
2096
|
+
else
|
2097
|
+
break
|
2098
|
+
end
|
2099
|
+
end
|
2100
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2101
|
+
s0 << r3
|
2102
|
+
end
|
2103
|
+
end
|
2104
|
+
if s0.last
|
2105
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2106
|
+
r0.extend(Id0)
|
2107
|
+
else
|
2108
|
+
@index = i0
|
2109
|
+
r0 = nil
|
2110
|
+
end
|
2111
|
+
|
2112
|
+
node_cache[:id][start_index] = r0
|
2113
|
+
|
2114
|
+
r0
|
2115
|
+
end
|
2116
|
+
|
2117
|
+
module Tag0
|
2118
|
+
end
|
2119
|
+
|
2120
|
+
def _nt_tag
|
2121
|
+
start_index = index
|
2122
|
+
if node_cache[:tag].has_key?(index)
|
2123
|
+
cached = node_cache[:tag][index]
|
2124
|
+
@index = cached.interval.end if cached
|
2125
|
+
return cached
|
2126
|
+
end
|
2127
|
+
|
2128
|
+
i0 = index
|
2129
|
+
i1, s1 = index, []
|
2130
|
+
if has_terminal?('[a-zA-Z]', true, index)
|
2131
|
+
r2 = true
|
2132
|
+
@index += 1
|
2133
|
+
else
|
2134
|
+
r2 = nil
|
2135
|
+
end
|
2136
|
+
s1 << r2
|
2137
|
+
if r2
|
2138
|
+
s3, i3 = [], index
|
2139
|
+
loop do
|
2140
|
+
if has_terminal?('[-a-zA-Z]', true, index)
|
2141
|
+
r4 = true
|
2142
|
+
@index += 1
|
2143
|
+
else
|
2144
|
+
r4 = nil
|
2145
|
+
end
|
2146
|
+
if r4
|
2147
|
+
s3 << r4
|
2148
|
+
else
|
2149
|
+
break
|
2150
|
+
end
|
2151
|
+
end
|
2152
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2153
|
+
s1 << r3
|
2154
|
+
if r3
|
2155
|
+
if has_terminal?('[0-9]', true, index)
|
2156
|
+
r6 = true
|
2157
|
+
@index += 1
|
2158
|
+
else
|
2159
|
+
r6 = nil
|
2160
|
+
end
|
2161
|
+
if r6
|
2162
|
+
r5 = r6
|
2163
|
+
else
|
2164
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
2165
|
+
end
|
2166
|
+
s1 << r5
|
2167
|
+
end
|
2168
|
+
end
|
2169
|
+
if s1.last
|
2170
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2171
|
+
r1.extend(Tag0)
|
2172
|
+
else
|
2173
|
+
@index = i1
|
2174
|
+
r1 = nil
|
2175
|
+
end
|
2176
|
+
if r1
|
2177
|
+
r0 = r1
|
2178
|
+
else
|
2179
|
+
if has_terminal?('*', false, index)
|
2180
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2181
|
+
@index += 1
|
2182
|
+
else
|
2183
|
+
terminal_parse_failure('*')
|
2184
|
+
r7 = nil
|
2185
|
+
end
|
2186
|
+
if r7
|
2187
|
+
r0 = r7
|
2188
|
+
else
|
2189
|
+
@index = i0
|
2190
|
+
r0 = nil
|
2191
|
+
end
|
2192
|
+
end
|
2193
|
+
|
2194
|
+
node_cache[:tag][start_index] = r0
|
2195
|
+
|
2196
|
+
r0
|
2197
|
+
end
|
2198
|
+
|
2199
|
+
module Select0
|
2200
|
+
def s
|
2201
|
+
elements[0]
|
2202
|
+
end
|
2203
|
+
|
2204
|
+
def s
|
2205
|
+
elements[2]
|
2206
|
+
end
|
2207
|
+
end
|
2208
|
+
|
2209
|
+
def _nt_select
|
2210
|
+
start_index = index
|
2211
|
+
if node_cache[:select].has_key?(index)
|
2212
|
+
cached = node_cache[:select][index]
|
2213
|
+
@index = cached.interval.end if cached
|
2214
|
+
return cached
|
2215
|
+
end
|
2216
|
+
|
2217
|
+
i1 = index
|
2218
|
+
i2, s2 = index, []
|
2219
|
+
r3 = _nt_s
|
2220
|
+
s2 << r3
|
2221
|
+
if r3
|
2222
|
+
if has_terminal?('[:+>]', true, index)
|
2223
|
+
r4 = true
|
2224
|
+
@index += 1
|
2225
|
+
else
|
2226
|
+
r4 = nil
|
2227
|
+
end
|
2228
|
+
s2 << r4
|
2229
|
+
if r4
|
2230
|
+
r5 = _nt_s
|
2231
|
+
s2 << r5
|
2232
|
+
end
|
2233
|
+
end
|
2234
|
+
if s2.last
|
2235
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
2236
|
+
r2.extend(Select0)
|
2237
|
+
else
|
2238
|
+
@index = i2
|
2239
|
+
r2 = nil
|
2240
|
+
end
|
2241
|
+
if r2
|
2242
|
+
r1 = r2
|
2243
|
+
else
|
2244
|
+
r6 = _nt_S
|
2245
|
+
if r6
|
2246
|
+
r1 = r6
|
2247
|
+
else
|
2248
|
+
@index = i1
|
2249
|
+
r1 = nil
|
2250
|
+
end
|
2251
|
+
end
|
2252
|
+
if r1
|
2253
|
+
r0 = r1
|
2254
|
+
else
|
2255
|
+
r0 = instantiate_node(SyntaxNode,input, index...index)
|
2256
|
+
end
|
2257
|
+
|
2258
|
+
node_cache[:select][start_index] = r0
|
2259
|
+
|
2260
|
+
r0
|
2261
|
+
end
|
2262
|
+
|
2263
|
+
module Accessor0
|
2264
|
+
def ident
|
2265
|
+
elements[0]
|
2266
|
+
end
|
2267
|
+
|
2268
|
+
def attr
|
2269
|
+
elements[2]
|
2270
|
+
end
|
2271
|
+
|
2272
|
+
end
|
2273
|
+
|
2274
|
+
module Accessor1
|
2275
|
+
def build env
|
2276
|
+
env.identifiers.last << env.nearest(ident.text_value)[attr.text_value.delete(%q["'])].evaluate
|
2277
|
+
end
|
2278
|
+
end
|
2279
|
+
|
2280
|
+
def _nt_accessor
|
2281
|
+
start_index = index
|
2282
|
+
if node_cache[:accessor].has_key?(index)
|
2283
|
+
cached = node_cache[:accessor][index]
|
2284
|
+
@index = cached.interval.end if cached
|
2285
|
+
return cached
|
2286
|
+
end
|
2287
|
+
|
2288
|
+
i0, s0 = index, []
|
2289
|
+
i1 = index
|
2290
|
+
r2 = _nt_class_id
|
2291
|
+
if r2
|
2292
|
+
r1 = r2
|
2293
|
+
else
|
2294
|
+
r3 = _nt_tag
|
2295
|
+
if r3
|
2296
|
+
r1 = r3
|
2297
|
+
else
|
2298
|
+
@index = i1
|
2299
|
+
r1 = nil
|
2300
|
+
end
|
2301
|
+
end
|
2302
|
+
s0 << r1
|
2303
|
+
if r1
|
2304
|
+
if has_terminal?('[', false, index)
|
2305
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2306
|
+
@index += 1
|
2307
|
+
else
|
2308
|
+
terminal_parse_failure('[')
|
2309
|
+
r4 = nil
|
2310
|
+
end
|
2311
|
+
s0 << r4
|
2312
|
+
if r4
|
2313
|
+
i5 = index
|
2314
|
+
r6 = _nt_string
|
2315
|
+
if r6
|
2316
|
+
r5 = r6
|
2317
|
+
else
|
2318
|
+
r7 = _nt_variable
|
2319
|
+
if r7
|
2320
|
+
r5 = r7
|
2321
|
+
else
|
2322
|
+
@index = i5
|
2323
|
+
r5 = nil
|
2324
|
+
end
|
2325
|
+
end
|
2326
|
+
s0 << r5
|
2327
|
+
if r5
|
2328
|
+
if has_terminal?(']', false, index)
|
2329
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2330
|
+
@index += 1
|
2331
|
+
else
|
2332
|
+
terminal_parse_failure(']')
|
2333
|
+
r8 = nil
|
2334
|
+
end
|
2335
|
+
s0 << r8
|
2336
|
+
end
|
2337
|
+
end
|
2338
|
+
end
|
2339
|
+
if s0.last
|
2340
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2341
|
+
r0.extend(Accessor0)
|
2342
|
+
r0.extend(Accessor1)
|
2343
|
+
else
|
2344
|
+
@index = i0
|
2345
|
+
r0 = nil
|
2346
|
+
end
|
2347
|
+
|
2348
|
+
node_cache[:accessor][start_index] = r0
|
2349
|
+
|
2350
|
+
r0
|
2351
|
+
end
|
2352
|
+
|
2353
|
+
module Operator0
|
2354
|
+
def S
|
2355
|
+
elements[0]
|
2356
|
+
end
|
2357
|
+
|
2358
|
+
def S
|
2359
|
+
elements[2]
|
2360
|
+
end
|
2361
|
+
end
|
2362
|
+
|
2363
|
+
module Operator1
|
2364
|
+
def build env
|
2365
|
+
env.identifiers.last << Node::Operator.new(text_value.strip)
|
2366
|
+
end
|
2367
|
+
end
|
2368
|
+
|
2369
|
+
module Operator2
|
2370
|
+
def build env
|
2371
|
+
env.identifiers.last << Node::Operator.new(text_value)
|
2372
|
+
end
|
2373
|
+
end
|
2374
|
+
|
2375
|
+
def _nt_operator
|
2376
|
+
start_index = index
|
2377
|
+
if node_cache[:operator].has_key?(index)
|
2378
|
+
cached = node_cache[:operator][index]
|
2379
|
+
@index = cached.interval.end if cached
|
2380
|
+
return cached
|
2381
|
+
end
|
2382
|
+
|
2383
|
+
i0 = index
|
2384
|
+
i1, s1 = index, []
|
2385
|
+
r2 = _nt_S
|
2386
|
+
s1 << r2
|
2387
|
+
if r2
|
2388
|
+
if has_terminal?('[-+*/]', true, index)
|
2389
|
+
r3 = true
|
2390
|
+
@index += 1
|
2391
|
+
else
|
2392
|
+
r3 = nil
|
2393
|
+
end
|
2394
|
+
s1 << r3
|
2395
|
+
if r3
|
2396
|
+
r4 = _nt_S
|
2397
|
+
s1 << r4
|
2398
|
+
end
|
2399
|
+
end
|
2400
|
+
if s1.last
|
2401
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2402
|
+
r1.extend(Operator0)
|
2403
|
+
r1.extend(Operator1)
|
2404
|
+
else
|
2405
|
+
@index = i1
|
2406
|
+
r1 = nil
|
2407
|
+
end
|
2408
|
+
if r1
|
2409
|
+
r0 = r1
|
2410
|
+
else
|
2411
|
+
if has_terminal?('[-+*/]', true, index)
|
2412
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2413
|
+
r5.extend(Operator2)
|
2414
|
+
@index += 1
|
2415
|
+
else
|
2416
|
+
r5 = nil
|
2417
|
+
end
|
2418
|
+
if r5
|
2419
|
+
r0 = r5
|
2420
|
+
else
|
2421
|
+
@index = i0
|
2422
|
+
r0 = nil
|
2423
|
+
end
|
2424
|
+
end
|
2425
|
+
|
2426
|
+
node_cache[:operator][start_index] = r0
|
2427
|
+
|
2428
|
+
r0
|
2429
|
+
end
|
2430
|
+
|
2431
|
+
module Literal0
|
2432
|
+
def dimension
|
2433
|
+
elements[2]
|
2434
|
+
end
|
2435
|
+
end
|
2436
|
+
|
2437
|
+
module Literal1
|
2438
|
+
def build env
|
2439
|
+
env.identifiers.last << Node::Anonymous.new(text_value)
|
2440
|
+
end
|
2441
|
+
end
|
2442
|
+
|
2443
|
+
module Literal2
|
2444
|
+
def number
|
2445
|
+
elements[0]
|
2446
|
+
end
|
2447
|
+
|
2448
|
+
def unit
|
2449
|
+
elements[1]
|
2450
|
+
end
|
2451
|
+
end
|
2452
|
+
|
2453
|
+
module Literal3
|
2454
|
+
def build env
|
2455
|
+
env.identifiers.last << Node::Number.new(number.text_value, unit.text_value)
|
2456
|
+
end
|
2457
|
+
end
|
2458
|
+
|
2459
|
+
module Literal4
|
2460
|
+
def build env
|
2461
|
+
env.identifiers.last << Node::String.new(text_value)
|
2462
|
+
end
|
2463
|
+
end
|
2464
|
+
|
2465
|
+
def _nt_literal
|
2466
|
+
start_index = index
|
2467
|
+
if node_cache[:literal].has_key?(index)
|
2468
|
+
cached = node_cache[:literal][index]
|
2469
|
+
@index = cached.interval.end if cached
|
2470
|
+
return cached
|
2471
|
+
end
|
2472
|
+
|
2473
|
+
i0 = index
|
2474
|
+
r1 = _nt_color
|
2475
|
+
if r1
|
2476
|
+
r0 = r1
|
2477
|
+
else
|
2478
|
+
i2, s2 = index, []
|
2479
|
+
i3 = index
|
2480
|
+
r4 = _nt_dimension
|
2481
|
+
if r4
|
2482
|
+
r3 = r4
|
2483
|
+
else
|
2484
|
+
s5, i5 = [], index
|
2485
|
+
loop do
|
2486
|
+
if has_terminal?('[-a-z]', true, index)
|
2487
|
+
r6 = true
|
2488
|
+
@index += 1
|
2489
|
+
else
|
2490
|
+
r6 = nil
|
2491
|
+
end
|
2492
|
+
if r6
|
2493
|
+
s5 << r6
|
2494
|
+
else
|
2495
|
+
break
|
2496
|
+
end
|
2497
|
+
end
|
2498
|
+
if s5.empty?
|
2499
|
+
@index = i5
|
2500
|
+
r5 = nil
|
2501
|
+
else
|
2502
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
2503
|
+
end
|
2504
|
+
if r5
|
2505
|
+
r3 = r5
|
2506
|
+
else
|
2507
|
+
@index = i3
|
2508
|
+
r3 = nil
|
2509
|
+
end
|
2510
|
+
end
|
2511
|
+
s2 << r3
|
2512
|
+
if r3
|
2513
|
+
if has_terminal?('/', false, index)
|
2514
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2515
|
+
@index += 1
|
2516
|
+
else
|
2517
|
+
terminal_parse_failure('/')
|
2518
|
+
r7 = nil
|
2519
|
+
end
|
2520
|
+
s2 << r7
|
2521
|
+
if r7
|
2522
|
+
r8 = _nt_dimension
|
2523
|
+
s2 << r8
|
2524
|
+
end
|
2525
|
+
end
|
2526
|
+
if s2.last
|
2527
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
2528
|
+
r2.extend(Literal0)
|
2529
|
+
r2.extend(Literal1)
|
2530
|
+
else
|
2531
|
+
@index = i2
|
2532
|
+
r2 = nil
|
2533
|
+
end
|
2534
|
+
if r2
|
2535
|
+
r0 = r2
|
2536
|
+
else
|
2537
|
+
i9, s9 = index, []
|
2538
|
+
r10 = _nt_number
|
2539
|
+
s9 << r10
|
2540
|
+
if r10
|
2541
|
+
r11 = _nt_unit
|
2542
|
+
s9 << r11
|
2543
|
+
end
|
2544
|
+
if s9.last
|
2545
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
2546
|
+
r9.extend(Literal2)
|
2547
|
+
r9.extend(Literal3)
|
2548
|
+
else
|
2549
|
+
@index = i9
|
2550
|
+
r9 = nil
|
2551
|
+
end
|
2552
|
+
if r9
|
2553
|
+
r0 = r9
|
2554
|
+
else
|
2555
|
+
r12 = _nt_string
|
2556
|
+
r12.extend(Literal4)
|
2557
|
+
if r12
|
2558
|
+
r0 = r12
|
2559
|
+
else
|
2560
|
+
@index = i0
|
2561
|
+
r0 = nil
|
2562
|
+
end
|
2563
|
+
end
|
2564
|
+
end
|
2565
|
+
end
|
2566
|
+
|
2567
|
+
node_cache[:literal][start_index] = r0
|
2568
|
+
|
2569
|
+
r0
|
2570
|
+
end
|
2571
|
+
|
2572
|
+
module Important0
|
2573
|
+
def build env
|
2574
|
+
env.identifiers.last << Node::Keyword.new(text_value)
|
2575
|
+
end
|
2576
|
+
end
|
2577
|
+
|
2578
|
+
def _nt_important
|
2579
|
+
start_index = index
|
2580
|
+
if node_cache[:important].has_key?(index)
|
2581
|
+
cached = node_cache[:important][index]
|
2582
|
+
@index = cached.interval.end if cached
|
2583
|
+
return cached
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
if has_terminal?('!important', false, index)
|
2587
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 10))
|
2588
|
+
r0.extend(Important0)
|
2589
|
+
@index += 10
|
2590
|
+
else
|
2591
|
+
terminal_parse_failure('!important')
|
2592
|
+
r0 = nil
|
2593
|
+
end
|
2594
|
+
|
2595
|
+
node_cache[:important][start_index] = r0
|
2596
|
+
|
2597
|
+
r0
|
2598
|
+
end
|
2599
|
+
|
2600
|
+
module Keyword0
|
2601
|
+
end
|
2602
|
+
|
2603
|
+
module Keyword1
|
2604
|
+
def build env
|
2605
|
+
env.identifiers.last << Node::Keyword.new(text_value)
|
2606
|
+
end
|
2607
|
+
end
|
2608
|
+
|
2609
|
+
def _nt_keyword
|
2610
|
+
start_index = index
|
2611
|
+
if node_cache[:keyword].has_key?(index)
|
2612
|
+
cached = node_cache[:keyword][index]
|
2613
|
+
@index = cached.interval.end if cached
|
2614
|
+
return cached
|
2615
|
+
end
|
2616
|
+
|
2617
|
+
i0, s0 = index, []
|
2618
|
+
if has_terminal?('[a-zA-Z]', true, index)
|
2619
|
+
r1 = true
|
2620
|
+
@index += 1
|
2621
|
+
else
|
2622
|
+
r1 = nil
|
2623
|
+
end
|
2624
|
+
s0 << r1
|
2625
|
+
if r1
|
2626
|
+
s2, i2 = [], index
|
2627
|
+
loop do
|
2628
|
+
if has_terminal?('[-a-zA-Z]', true, index)
|
2629
|
+
r3 = true
|
2630
|
+
@index += 1
|
2631
|
+
else
|
2632
|
+
r3 = nil
|
2633
|
+
end
|
2634
|
+
if r3
|
2635
|
+
s2 << r3
|
2636
|
+
else
|
2637
|
+
break
|
2638
|
+
end
|
2639
|
+
end
|
2640
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
2641
|
+
s0 << r2
|
2642
|
+
if r2
|
2643
|
+
i4 = index
|
2644
|
+
r5 = _nt_ns
|
2645
|
+
if r5
|
2646
|
+
r4 = nil
|
2647
|
+
else
|
2648
|
+
@index = i4
|
2649
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
2650
|
+
end
|
2651
|
+
s0 << r4
|
2652
|
+
end
|
2653
|
+
end
|
2654
|
+
if s0.last
|
2655
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2656
|
+
r0.extend(Keyword0)
|
2657
|
+
r0.extend(Keyword1)
|
2658
|
+
else
|
2659
|
+
@index = i0
|
2660
|
+
r0 = nil
|
2661
|
+
end
|
2662
|
+
|
2663
|
+
node_cache[:keyword][start_index] = r0
|
2664
|
+
|
2665
|
+
r0
|
2666
|
+
end
|
2667
|
+
|
2668
|
+
module String0
|
2669
|
+
end
|
2670
|
+
|
2671
|
+
module String1
|
2672
|
+
def content
|
2673
|
+
elements[1]
|
2674
|
+
end
|
2675
|
+
|
2676
|
+
end
|
2677
|
+
|
2678
|
+
module String2
|
2679
|
+
def value
|
2680
|
+
text_value[1...-1]
|
2681
|
+
end
|
2682
|
+
end
|
2683
|
+
|
2684
|
+
module String3
|
2685
|
+
end
|
2686
|
+
|
2687
|
+
module String4
|
2688
|
+
def content
|
2689
|
+
elements[1]
|
2690
|
+
end
|
2691
|
+
|
2692
|
+
end
|
2693
|
+
|
2694
|
+
module String5
|
2695
|
+
def value
|
2696
|
+
text_value[1...-1]
|
2697
|
+
end
|
2698
|
+
end
|
2699
|
+
|
2700
|
+
def _nt_string
|
2701
|
+
start_index = index
|
2702
|
+
if node_cache[:string].has_key?(index)
|
2703
|
+
cached = node_cache[:string][index]
|
2704
|
+
@index = cached.interval.end if cached
|
2705
|
+
return cached
|
2706
|
+
end
|
2707
|
+
|
2708
|
+
i0 = index
|
2709
|
+
i1, s1 = index, []
|
2710
|
+
if has_terminal?("'", false, index)
|
2711
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2712
|
+
@index += 1
|
2713
|
+
else
|
2714
|
+
terminal_parse_failure("'")
|
2715
|
+
r2 = nil
|
2716
|
+
end
|
2717
|
+
s1 << r2
|
2718
|
+
if r2
|
2719
|
+
s3, i3 = [], index
|
2720
|
+
loop do
|
2721
|
+
i4, s4 = index, []
|
2722
|
+
i5 = index
|
2723
|
+
if has_terminal?("'", false, index)
|
2724
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2725
|
+
@index += 1
|
2726
|
+
else
|
2727
|
+
terminal_parse_failure("'")
|
2728
|
+
r6 = nil
|
2729
|
+
end
|
2730
|
+
if r6
|
2731
|
+
r5 = nil
|
2732
|
+
else
|
2733
|
+
@index = i5
|
2734
|
+
r5 = instantiate_node(SyntaxNode,input, index...index)
|
2735
|
+
end
|
2736
|
+
s4 << r5
|
2737
|
+
if r5
|
2738
|
+
if index < input_length
|
2739
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2740
|
+
@index += 1
|
2741
|
+
else
|
2742
|
+
terminal_parse_failure("any character")
|
2743
|
+
r7 = nil
|
2744
|
+
end
|
2745
|
+
s4 << r7
|
2746
|
+
end
|
2747
|
+
if s4.last
|
2748
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
2749
|
+
r4.extend(String0)
|
2750
|
+
else
|
2751
|
+
@index = i4
|
2752
|
+
r4 = nil
|
2753
|
+
end
|
2754
|
+
if r4
|
2755
|
+
s3 << r4
|
2756
|
+
else
|
2757
|
+
break
|
2758
|
+
end
|
2759
|
+
end
|
2760
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2761
|
+
s1 << r3
|
2762
|
+
if r3
|
2763
|
+
if has_terminal?("'", false, index)
|
2764
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2765
|
+
@index += 1
|
2766
|
+
else
|
2767
|
+
terminal_parse_failure("'")
|
2768
|
+
r8 = nil
|
2769
|
+
end
|
2770
|
+
s1 << r8
|
2771
|
+
end
|
2772
|
+
end
|
2773
|
+
if s1.last
|
2774
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2775
|
+
r1.extend(String1)
|
2776
|
+
r1.extend(String2)
|
2777
|
+
else
|
2778
|
+
@index = i1
|
2779
|
+
r1 = nil
|
2780
|
+
end
|
2781
|
+
if r1
|
2782
|
+
r0 = r1
|
2783
|
+
else
|
2784
|
+
i9, s9 = index, []
|
2785
|
+
if has_terminal?('["]', true, index)
|
2786
|
+
r10 = true
|
2787
|
+
@index += 1
|
2788
|
+
else
|
2789
|
+
r10 = nil
|
2790
|
+
end
|
2791
|
+
s9 << r10
|
2792
|
+
if r10
|
2793
|
+
s11, i11 = [], index
|
2794
|
+
loop do
|
2795
|
+
i12, s12 = index, []
|
2796
|
+
i13 = index
|
2797
|
+
if has_terminal?('["]', true, index)
|
2798
|
+
r14 = true
|
2799
|
+
@index += 1
|
2800
|
+
else
|
2801
|
+
r14 = nil
|
2802
|
+
end
|
2803
|
+
if r14
|
2804
|
+
r13 = nil
|
2805
|
+
else
|
2806
|
+
@index = i13
|
2807
|
+
r13 = instantiate_node(SyntaxNode,input, index...index)
|
2808
|
+
end
|
2809
|
+
s12 << r13
|
2810
|
+
if r13
|
2811
|
+
if index < input_length
|
2812
|
+
r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2813
|
+
@index += 1
|
2814
|
+
else
|
2815
|
+
terminal_parse_failure("any character")
|
2816
|
+
r15 = nil
|
2817
|
+
end
|
2818
|
+
s12 << r15
|
2819
|
+
end
|
2820
|
+
if s12.last
|
2821
|
+
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
2822
|
+
r12.extend(String3)
|
2823
|
+
else
|
2824
|
+
@index = i12
|
2825
|
+
r12 = nil
|
2826
|
+
end
|
2827
|
+
if r12
|
2828
|
+
s11 << r12
|
2829
|
+
else
|
2830
|
+
break
|
2831
|
+
end
|
2832
|
+
end
|
2833
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
2834
|
+
s9 << r11
|
2835
|
+
if r11
|
2836
|
+
if has_terminal?('["]', true, index)
|
2837
|
+
r16 = true
|
2838
|
+
@index += 1
|
2839
|
+
else
|
2840
|
+
r16 = nil
|
2841
|
+
end
|
2842
|
+
s9 << r16
|
2843
|
+
end
|
2844
|
+
end
|
2845
|
+
if s9.last
|
2846
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
2847
|
+
r9.extend(String4)
|
2848
|
+
r9.extend(String5)
|
2849
|
+
else
|
2850
|
+
@index = i9
|
2851
|
+
r9 = nil
|
2852
|
+
end
|
2853
|
+
if r9
|
2854
|
+
r0 = r9
|
2855
|
+
else
|
2856
|
+
@index = i0
|
2857
|
+
r0 = nil
|
2858
|
+
end
|
2859
|
+
end
|
2860
|
+
|
2861
|
+
node_cache[:string][start_index] = r0
|
2862
|
+
|
2863
|
+
r0
|
2864
|
+
end
|
2865
|
+
|
2866
|
+
module Dimension0
|
2867
|
+
def number
|
2868
|
+
elements[0]
|
2869
|
+
end
|
2870
|
+
|
2871
|
+
def unit
|
2872
|
+
elements[1]
|
2873
|
+
end
|
2874
|
+
end
|
2875
|
+
|
2876
|
+
def _nt_dimension
|
2877
|
+
start_index = index
|
2878
|
+
if node_cache[:dimension].has_key?(index)
|
2879
|
+
cached = node_cache[:dimension][index]
|
2880
|
+
@index = cached.interval.end if cached
|
2881
|
+
return cached
|
2882
|
+
end
|
2883
|
+
|
2884
|
+
i0, s0 = index, []
|
2885
|
+
r1 = _nt_number
|
2886
|
+
s0 << r1
|
2887
|
+
if r1
|
2888
|
+
r2 = _nt_unit
|
2889
|
+
s0 << r2
|
2890
|
+
end
|
2891
|
+
if s0.last
|
2892
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2893
|
+
r0.extend(Dimension0)
|
2894
|
+
else
|
2895
|
+
@index = i0
|
2896
|
+
r0 = nil
|
2897
|
+
end
|
2898
|
+
|
2899
|
+
node_cache[:dimension][start_index] = r0
|
2900
|
+
|
2901
|
+
r0
|
2902
|
+
end
|
2903
|
+
|
2904
|
+
module Number0
|
2905
|
+
end
|
2906
|
+
|
2907
|
+
module Number1
|
2908
|
+
end
|
2909
|
+
|
2910
|
+
def _nt_number
|
2911
|
+
start_index = index
|
2912
|
+
if node_cache[:number].has_key?(index)
|
2913
|
+
cached = node_cache[:number][index]
|
2914
|
+
@index = cached.interval.end if cached
|
2915
|
+
return cached
|
2916
|
+
end
|
2917
|
+
|
2918
|
+
i0 = index
|
2919
|
+
i1, s1 = index, []
|
2920
|
+
if has_terminal?('-', false, index)
|
2921
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2922
|
+
@index += 1
|
2923
|
+
else
|
2924
|
+
terminal_parse_failure('-')
|
2925
|
+
r3 = nil
|
2926
|
+
end
|
2927
|
+
if r3
|
2928
|
+
r2 = r3
|
2929
|
+
else
|
2930
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
2931
|
+
end
|
2932
|
+
s1 << r2
|
2933
|
+
if r2
|
2934
|
+
s4, i4 = [], index
|
2935
|
+
loop do
|
2936
|
+
if has_terminal?('[0-9]', true, index)
|
2937
|
+
r5 = true
|
2938
|
+
@index += 1
|
2939
|
+
else
|
2940
|
+
r5 = nil
|
2941
|
+
end
|
2942
|
+
if r5
|
2943
|
+
s4 << r5
|
2944
|
+
else
|
2945
|
+
break
|
2946
|
+
end
|
2947
|
+
end
|
2948
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
2949
|
+
s1 << r4
|
2950
|
+
if r4
|
2951
|
+
if has_terminal?('.', false, index)
|
2952
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2953
|
+
@index += 1
|
2954
|
+
else
|
2955
|
+
terminal_parse_failure('.')
|
2956
|
+
r6 = nil
|
2957
|
+
end
|
2958
|
+
s1 << r6
|
2959
|
+
if r6
|
2960
|
+
s7, i7 = [], index
|
2961
|
+
loop do
|
2962
|
+
if has_terminal?('[0-9]', true, index)
|
2963
|
+
r8 = true
|
2964
|
+
@index += 1
|
2965
|
+
else
|
2966
|
+
r8 = nil
|
2967
|
+
end
|
2968
|
+
if r8
|
2969
|
+
s7 << r8
|
2970
|
+
else
|
2971
|
+
break
|
2972
|
+
end
|
2973
|
+
end
|
2974
|
+
if s7.empty?
|
2975
|
+
@index = i7
|
2976
|
+
r7 = nil
|
2977
|
+
else
|
2978
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
2979
|
+
end
|
2980
|
+
s1 << r7
|
2981
|
+
end
|
2982
|
+
end
|
2983
|
+
end
|
2984
|
+
if s1.last
|
2985
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2986
|
+
r1.extend(Number0)
|
2987
|
+
else
|
2988
|
+
@index = i1
|
2989
|
+
r1 = nil
|
2990
|
+
end
|
2991
|
+
if r1
|
2992
|
+
r0 = r1
|
2993
|
+
else
|
2994
|
+
i9, s9 = index, []
|
2995
|
+
if has_terminal?('-', false, index)
|
2996
|
+
r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
2997
|
+
@index += 1
|
2998
|
+
else
|
2999
|
+
terminal_parse_failure('-')
|
3000
|
+
r11 = nil
|
3001
|
+
end
|
3002
|
+
if r11
|
3003
|
+
r10 = r11
|
3004
|
+
else
|
3005
|
+
r10 = instantiate_node(SyntaxNode,input, index...index)
|
3006
|
+
end
|
3007
|
+
s9 << r10
|
3008
|
+
if r10
|
3009
|
+
s12, i12 = [], index
|
3010
|
+
loop do
|
3011
|
+
if has_terminal?('[0-9]', true, index)
|
3012
|
+
r13 = true
|
3013
|
+
@index += 1
|
3014
|
+
else
|
3015
|
+
r13 = nil
|
3016
|
+
end
|
3017
|
+
if r13
|
3018
|
+
s12 << r13
|
3019
|
+
else
|
3020
|
+
break
|
3021
|
+
end
|
3022
|
+
end
|
3023
|
+
if s12.empty?
|
3024
|
+
@index = i12
|
3025
|
+
r12 = nil
|
3026
|
+
else
|
3027
|
+
r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
|
3028
|
+
end
|
3029
|
+
s9 << r12
|
3030
|
+
end
|
3031
|
+
if s9.last
|
3032
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
3033
|
+
r9.extend(Number1)
|
3034
|
+
else
|
3035
|
+
@index = i9
|
3036
|
+
r9 = nil
|
3037
|
+
end
|
3038
|
+
if r9
|
3039
|
+
r0 = r9
|
3040
|
+
else
|
3041
|
+
@index = i0
|
3042
|
+
r0 = nil
|
3043
|
+
end
|
3044
|
+
end
|
3045
|
+
|
3046
|
+
node_cache[:number][start_index] = r0
|
3047
|
+
|
3048
|
+
r0
|
3049
|
+
end
|
3050
|
+
|
3051
|
+
def _nt_unit
|
3052
|
+
start_index = index
|
3053
|
+
if node_cache[:unit].has_key?(index)
|
3054
|
+
cached = node_cache[:unit][index]
|
3055
|
+
@index = cached.interval.end if cached
|
3056
|
+
return cached
|
3057
|
+
end
|
3058
|
+
|
3059
|
+
i1 = index
|
3060
|
+
if has_terminal?('px', false, index)
|
3061
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3062
|
+
@index += 2
|
3063
|
+
else
|
3064
|
+
terminal_parse_failure('px')
|
3065
|
+
r2 = nil
|
3066
|
+
end
|
3067
|
+
if r2
|
3068
|
+
r1 = r2
|
3069
|
+
else
|
3070
|
+
if has_terminal?('em', false, index)
|
3071
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3072
|
+
@index += 2
|
3073
|
+
else
|
3074
|
+
terminal_parse_failure('em')
|
3075
|
+
r3 = nil
|
3076
|
+
end
|
3077
|
+
if r3
|
3078
|
+
r1 = r3
|
3079
|
+
else
|
3080
|
+
if has_terminal?('pc', false, index)
|
3081
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3082
|
+
@index += 2
|
3083
|
+
else
|
3084
|
+
terminal_parse_failure('pc')
|
3085
|
+
r4 = nil
|
3086
|
+
end
|
3087
|
+
if r4
|
3088
|
+
r1 = r4
|
3089
|
+
else
|
3090
|
+
if has_terminal?('%', false, index)
|
3091
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3092
|
+
@index += 1
|
3093
|
+
else
|
3094
|
+
terminal_parse_failure('%')
|
3095
|
+
r5 = nil
|
3096
|
+
end
|
3097
|
+
if r5
|
3098
|
+
r1 = r5
|
3099
|
+
else
|
3100
|
+
if has_terminal?('pt', false, index)
|
3101
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3102
|
+
@index += 2
|
3103
|
+
else
|
3104
|
+
terminal_parse_failure('pt')
|
3105
|
+
r6 = nil
|
3106
|
+
end
|
3107
|
+
if r6
|
3108
|
+
r1 = r6
|
3109
|
+
else
|
3110
|
+
if has_terminal?('cm', false, index)
|
3111
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3112
|
+
@index += 2
|
3113
|
+
else
|
3114
|
+
terminal_parse_failure('cm')
|
3115
|
+
r7 = nil
|
3116
|
+
end
|
3117
|
+
if r7
|
3118
|
+
r1 = r7
|
3119
|
+
else
|
3120
|
+
if has_terminal?('mm', false, index)
|
3121
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
3122
|
+
@index += 2
|
3123
|
+
else
|
3124
|
+
terminal_parse_failure('mm')
|
3125
|
+
r8 = nil
|
3126
|
+
end
|
3127
|
+
if r8
|
3128
|
+
r1 = r8
|
3129
|
+
else
|
3130
|
+
@index = i1
|
3131
|
+
r1 = nil
|
3132
|
+
end
|
3133
|
+
end
|
3134
|
+
end
|
3135
|
+
end
|
3136
|
+
end
|
3137
|
+
end
|
3138
|
+
end
|
3139
|
+
if r1
|
3140
|
+
r0 = r1
|
3141
|
+
else
|
3142
|
+
r0 = instantiate_node(SyntaxNode,input, index...index)
|
3143
|
+
end
|
3144
|
+
|
3145
|
+
node_cache[:unit][start_index] = r0
|
3146
|
+
|
3147
|
+
r0
|
3148
|
+
end
|
3149
|
+
|
3150
|
+
module Color0
|
3151
|
+
def hex
|
3152
|
+
elements[1]
|
3153
|
+
end
|
3154
|
+
end
|
3155
|
+
|
3156
|
+
module Color1
|
3157
|
+
def build env
|
3158
|
+
env.identifiers.last << Node::Color.new(hex.text_value)
|
3159
|
+
end
|
3160
|
+
end
|
3161
|
+
|
3162
|
+
module Color2
|
3163
|
+
end
|
3164
|
+
|
3165
|
+
module Color3
|
3166
|
+
def fn
|
3167
|
+
elements[0]
|
3168
|
+
end
|
3169
|
+
|
3170
|
+
def arguments
|
3171
|
+
elements[2]
|
3172
|
+
end
|
3173
|
+
|
3174
|
+
end
|
3175
|
+
|
3176
|
+
module Color4
|
3177
|
+
def build env
|
3178
|
+
args = arguments.build env
|
3179
|
+
env.identifiers.last << Node::Function.new(fn.text_value, args.flatten)
|
3180
|
+
end
|
3181
|
+
end
|
3182
|
+
|
3183
|
+
def _nt_color
|
3184
|
+
start_index = index
|
3185
|
+
if node_cache[:color].has_key?(index)
|
3186
|
+
cached = node_cache[:color][index]
|
3187
|
+
@index = cached.interval.end if cached
|
3188
|
+
return cached
|
3189
|
+
end
|
3190
|
+
|
3191
|
+
i0 = index
|
3192
|
+
i1, s1 = index, []
|
3193
|
+
if has_terminal?('#', false, index)
|
3194
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3195
|
+
@index += 1
|
3196
|
+
else
|
3197
|
+
terminal_parse_failure('#')
|
3198
|
+
r2 = nil
|
3199
|
+
end
|
3200
|
+
s1 << r2
|
3201
|
+
if r2
|
3202
|
+
r3 = _nt_hex
|
3203
|
+
s1 << r3
|
3204
|
+
end
|
3205
|
+
if s1.last
|
3206
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3207
|
+
r1.extend(Color0)
|
3208
|
+
r1.extend(Color1)
|
3209
|
+
else
|
3210
|
+
@index = i1
|
3211
|
+
r1 = nil
|
3212
|
+
end
|
3213
|
+
if r1
|
3214
|
+
r0 = r1
|
3215
|
+
else
|
3216
|
+
i4, s4 = index, []
|
3217
|
+
i5, s5 = index, []
|
3218
|
+
i6 = index
|
3219
|
+
if has_terminal?('hsl', false, index)
|
3220
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
3221
|
+
@index += 3
|
3222
|
+
else
|
3223
|
+
terminal_parse_failure('hsl')
|
3224
|
+
r7 = nil
|
3225
|
+
end
|
3226
|
+
if r7
|
3227
|
+
r6 = r7
|
3228
|
+
else
|
3229
|
+
if has_terminal?('rgb', false, index)
|
3230
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
3231
|
+
@index += 3
|
3232
|
+
else
|
3233
|
+
terminal_parse_failure('rgb')
|
3234
|
+
r8 = nil
|
3235
|
+
end
|
3236
|
+
if r8
|
3237
|
+
r6 = r8
|
3238
|
+
else
|
3239
|
+
@index = i6
|
3240
|
+
r6 = nil
|
3241
|
+
end
|
3242
|
+
end
|
3243
|
+
s5 << r6
|
3244
|
+
if r6
|
3245
|
+
if has_terminal?('a', false, index)
|
3246
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3247
|
+
@index += 1
|
3248
|
+
else
|
3249
|
+
terminal_parse_failure('a')
|
3250
|
+
r10 = nil
|
3251
|
+
end
|
3252
|
+
if r10
|
3253
|
+
r9 = r10
|
3254
|
+
else
|
3255
|
+
r9 = instantiate_node(SyntaxNode,input, index...index)
|
3256
|
+
end
|
3257
|
+
s5 << r9
|
3258
|
+
end
|
3259
|
+
if s5.last
|
3260
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
3261
|
+
r5.extend(Color2)
|
3262
|
+
else
|
3263
|
+
@index = i5
|
3264
|
+
r5 = nil
|
3265
|
+
end
|
3266
|
+
s4 << r5
|
3267
|
+
if r5
|
3268
|
+
if has_terminal?('(', false, index)
|
3269
|
+
r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3270
|
+
@index += 1
|
3271
|
+
else
|
3272
|
+
terminal_parse_failure('(')
|
3273
|
+
r11 = nil
|
3274
|
+
end
|
3275
|
+
s4 << r11
|
3276
|
+
if r11
|
3277
|
+
r12 = _nt_arguments
|
3278
|
+
s4 << r12
|
3279
|
+
if r12
|
3280
|
+
if has_terminal?(')', false, index)
|
3281
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3282
|
+
@index += 1
|
3283
|
+
else
|
3284
|
+
terminal_parse_failure(')')
|
3285
|
+
r13 = nil
|
3286
|
+
end
|
3287
|
+
s4 << r13
|
3288
|
+
end
|
3289
|
+
end
|
3290
|
+
end
|
3291
|
+
if s4.last
|
3292
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
3293
|
+
r4.extend(Color3)
|
3294
|
+
r4.extend(Color4)
|
3295
|
+
else
|
3296
|
+
@index = i4
|
3297
|
+
r4 = nil
|
3298
|
+
end
|
3299
|
+
if r4
|
3300
|
+
r0 = r4
|
3301
|
+
else
|
3302
|
+
@index = i0
|
3303
|
+
r0 = nil
|
3304
|
+
end
|
3305
|
+
end
|
3306
|
+
|
3307
|
+
node_cache[:color][start_index] = r0
|
3308
|
+
|
3309
|
+
r0
|
3310
|
+
end
|
3311
|
+
|
3312
|
+
module Hex0
|
3313
|
+
end
|
3314
|
+
|
3315
|
+
def _nt_hex
|
3316
|
+
start_index = index
|
3317
|
+
if node_cache[:hex].has_key?(index)
|
3318
|
+
cached = node_cache[:hex][index]
|
3319
|
+
@index = cached.interval.end if cached
|
3320
|
+
return cached
|
3321
|
+
end
|
3322
|
+
|
3323
|
+
i0, s0 = index, []
|
3324
|
+
if has_terminal?('[a-fA-F0-9]', true, index)
|
3325
|
+
r1 = true
|
3326
|
+
@index += 1
|
3327
|
+
else
|
3328
|
+
r1 = nil
|
3329
|
+
end
|
3330
|
+
s0 << r1
|
3331
|
+
if r1
|
3332
|
+
if has_terminal?('[a-fA-F0-9]', true, index)
|
3333
|
+
r2 = true
|
3334
|
+
@index += 1
|
3335
|
+
else
|
3336
|
+
r2 = nil
|
3337
|
+
end
|
3338
|
+
s0 << r2
|
3339
|
+
if r2
|
3340
|
+
s3, i3 = [], index
|
3341
|
+
loop do
|
3342
|
+
if has_terminal?('[a-fA-F0-9]', true, index)
|
3343
|
+
r4 = true
|
3344
|
+
@index += 1
|
3345
|
+
else
|
3346
|
+
r4 = nil
|
3347
|
+
end
|
3348
|
+
if r4
|
3349
|
+
s3 << r4
|
3350
|
+
else
|
3351
|
+
break
|
3352
|
+
end
|
3353
|
+
end
|
3354
|
+
if s3.empty?
|
3355
|
+
@index = i3
|
3356
|
+
r3 = nil
|
3357
|
+
else
|
3358
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
3359
|
+
end
|
3360
|
+
s0 << r3
|
3361
|
+
end
|
3362
|
+
end
|
3363
|
+
if s0.last
|
3364
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3365
|
+
r0.extend(Hex0)
|
3366
|
+
else
|
3367
|
+
@index = i0
|
3368
|
+
r0 = nil
|
3369
|
+
end
|
3370
|
+
|
3371
|
+
node_cache[:hex][start_index] = r0
|
3372
|
+
|
3373
|
+
r0
|
3374
|
+
end
|
3375
|
+
|
3376
|
+
module Function0
|
3377
|
+
def name
|
3378
|
+
elements[0]
|
3379
|
+
end
|
3380
|
+
|
3381
|
+
def arguments
|
3382
|
+
elements[2]
|
3383
|
+
end
|
3384
|
+
|
3385
|
+
end
|
3386
|
+
|
3387
|
+
module Function1
|
3388
|
+
def build env
|
3389
|
+
args = arguments.build env
|
3390
|
+
env.identifiers.last << Node::Function.new(name.text_value, [args].flatten)
|
3391
|
+
end
|
3392
|
+
end
|
3393
|
+
|
3394
|
+
def _nt_function
|
3395
|
+
start_index = index
|
3396
|
+
if node_cache[:function].has_key?(index)
|
3397
|
+
cached = node_cache[:function][index]
|
3398
|
+
@index = cached.interval.end if cached
|
3399
|
+
return cached
|
3400
|
+
end
|
3401
|
+
|
3402
|
+
i0, s0 = index, []
|
3403
|
+
s1, i1 = [], index
|
3404
|
+
loop do
|
3405
|
+
if has_terminal?('[-a-zA-Z_]', true, index)
|
3406
|
+
r2 = true
|
3407
|
+
@index += 1
|
3408
|
+
else
|
3409
|
+
r2 = nil
|
3410
|
+
end
|
3411
|
+
if r2
|
3412
|
+
s1 << r2
|
3413
|
+
else
|
3414
|
+
break
|
3415
|
+
end
|
3416
|
+
end
|
3417
|
+
if s1.empty?
|
3418
|
+
@index = i1
|
3419
|
+
r1 = nil
|
3420
|
+
else
|
3421
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3422
|
+
end
|
3423
|
+
s0 << r1
|
3424
|
+
if r1
|
3425
|
+
if has_terminal?('(', false, index)
|
3426
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3427
|
+
@index += 1
|
3428
|
+
else
|
3429
|
+
terminal_parse_failure('(')
|
3430
|
+
r3 = nil
|
3431
|
+
end
|
3432
|
+
s0 << r3
|
3433
|
+
if r3
|
3434
|
+
r4 = _nt_arguments
|
3435
|
+
s0 << r4
|
3436
|
+
if r4
|
3437
|
+
if has_terminal?(')', false, index)
|
3438
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3439
|
+
@index += 1
|
3440
|
+
else
|
3441
|
+
terminal_parse_failure(')')
|
3442
|
+
r5 = nil
|
3443
|
+
end
|
3444
|
+
s0 << r5
|
3445
|
+
end
|
3446
|
+
end
|
3447
|
+
end
|
3448
|
+
if s0.last
|
3449
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3450
|
+
r0.extend(Function0)
|
3451
|
+
r0.extend(Function1)
|
3452
|
+
else
|
3453
|
+
@index = i0
|
3454
|
+
r0 = nil
|
3455
|
+
end
|
3456
|
+
|
3457
|
+
node_cache[:function][start_index] = r0
|
3458
|
+
|
3459
|
+
r0
|
3460
|
+
end
|
3461
|
+
|
3462
|
+
module Arguments0
|
3463
|
+
def argument
|
3464
|
+
elements[0]
|
3465
|
+
end
|
3466
|
+
|
3467
|
+
def s
|
3468
|
+
elements[1]
|
3469
|
+
end
|
3470
|
+
|
3471
|
+
def s
|
3472
|
+
elements[3]
|
3473
|
+
end
|
3474
|
+
|
3475
|
+
def arguments
|
3476
|
+
elements[4]
|
3477
|
+
end
|
3478
|
+
end
|
3479
|
+
|
3480
|
+
module Arguments1
|
3481
|
+
def build env
|
3482
|
+
elements.map do |e|
|
3483
|
+
e.build env if e.respond_to? :build
|
3484
|
+
end.compact
|
3485
|
+
end
|
3486
|
+
end
|
3487
|
+
|
3488
|
+
def _nt_arguments
|
3489
|
+
start_index = index
|
3490
|
+
if node_cache[:arguments].has_key?(index)
|
3491
|
+
cached = node_cache[:arguments][index]
|
3492
|
+
@index = cached.interval.end if cached
|
3493
|
+
return cached
|
3494
|
+
end
|
3495
|
+
|
3496
|
+
i0 = index
|
3497
|
+
i1, s1 = index, []
|
3498
|
+
r2 = _nt_argument
|
3499
|
+
s1 << r2
|
3500
|
+
if r2
|
3501
|
+
r3 = _nt_s
|
3502
|
+
s1 << r3
|
3503
|
+
if r3
|
3504
|
+
if has_terminal?(',', false, index)
|
3505
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3506
|
+
@index += 1
|
3507
|
+
else
|
3508
|
+
terminal_parse_failure(',')
|
3509
|
+
r4 = nil
|
3510
|
+
end
|
3511
|
+
s1 << r4
|
3512
|
+
if r4
|
3513
|
+
r5 = _nt_s
|
3514
|
+
s1 << r5
|
3515
|
+
if r5
|
3516
|
+
r6 = _nt_arguments
|
3517
|
+
s1 << r6
|
3518
|
+
end
|
3519
|
+
end
|
3520
|
+
end
|
3521
|
+
end
|
3522
|
+
if s1.last
|
3523
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3524
|
+
r1.extend(Arguments0)
|
3525
|
+
r1.extend(Arguments1)
|
3526
|
+
else
|
3527
|
+
@index = i1
|
3528
|
+
r1 = nil
|
3529
|
+
end
|
3530
|
+
if r1
|
3531
|
+
r0 = r1
|
3532
|
+
else
|
3533
|
+
r7 = _nt_argument
|
3534
|
+
if r7
|
3535
|
+
r0 = r7
|
3536
|
+
else
|
3537
|
+
@index = i0
|
3538
|
+
r0 = nil
|
3539
|
+
end
|
3540
|
+
end
|
3541
|
+
|
3542
|
+
node_cache[:arguments][start_index] = r0
|
3543
|
+
|
3544
|
+
r0
|
3545
|
+
end
|
3546
|
+
|
3547
|
+
module Argument0
|
3548
|
+
def build env
|
3549
|
+
Node::Color.new text_value
|
3550
|
+
end
|
3551
|
+
end
|
3552
|
+
|
3553
|
+
module Argument1
|
3554
|
+
def number
|
3555
|
+
elements[0]
|
3556
|
+
end
|
3557
|
+
|
3558
|
+
def unit
|
3559
|
+
elements[1]
|
3560
|
+
end
|
3561
|
+
end
|
3562
|
+
|
3563
|
+
module Argument2
|
3564
|
+
def build env
|
3565
|
+
Node::Number.new number.text_value, unit.text_value
|
3566
|
+
end
|
3567
|
+
end
|
3568
|
+
|
3569
|
+
module Argument3
|
3570
|
+
def build env
|
3571
|
+
Node::String.new text_value
|
3572
|
+
end
|
3573
|
+
end
|
3574
|
+
|
3575
|
+
module Argument4
|
3576
|
+
def dimension
|
3577
|
+
elements[2]
|
3578
|
+
end
|
3579
|
+
end
|
3580
|
+
|
3581
|
+
module Argument5
|
3582
|
+
def build env
|
3583
|
+
Node::Anonymous.new text_value
|
3584
|
+
end
|
3585
|
+
end
|
3586
|
+
|
3587
|
+
module Argument6
|
3588
|
+
def build env
|
3589
|
+
Node::String.new text_value
|
3590
|
+
end
|
3591
|
+
end
|
3592
|
+
|
3593
|
+
def _nt_argument
|
3594
|
+
start_index = index
|
3595
|
+
if node_cache[:argument].has_key?(index)
|
3596
|
+
cached = node_cache[:argument][index]
|
3597
|
+
@index = cached.interval.end if cached
|
3598
|
+
return cached
|
3599
|
+
end
|
3600
|
+
|
3601
|
+
i0 = index
|
3602
|
+
r1 = _nt_color
|
3603
|
+
r1.extend(Argument0)
|
3604
|
+
if r1
|
3605
|
+
r0 = r1
|
3606
|
+
else
|
3607
|
+
i2, s2 = index, []
|
3608
|
+
r3 = _nt_number
|
3609
|
+
s2 << r3
|
3610
|
+
if r3
|
3611
|
+
r4 = _nt_unit
|
3612
|
+
s2 << r4
|
3613
|
+
end
|
3614
|
+
if s2.last
|
3615
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
3616
|
+
r2.extend(Argument1)
|
3617
|
+
r2.extend(Argument2)
|
3618
|
+
else
|
3619
|
+
@index = i2
|
3620
|
+
r2 = nil
|
3621
|
+
end
|
3622
|
+
if r2
|
3623
|
+
r0 = r2
|
3624
|
+
else
|
3625
|
+
r5 = _nt_string
|
3626
|
+
r5.extend(Argument3)
|
3627
|
+
if r5
|
3628
|
+
r0 = r5
|
3629
|
+
else
|
3630
|
+
i6, s6 = index, []
|
3631
|
+
s7, i7 = [], index
|
3632
|
+
loop do
|
3633
|
+
if has_terminal?('[a-zA-Z]', true, index)
|
3634
|
+
r8 = true
|
3635
|
+
@index += 1
|
3636
|
+
else
|
3637
|
+
r8 = nil
|
3638
|
+
end
|
3639
|
+
if r8
|
3640
|
+
s7 << r8
|
3641
|
+
else
|
3642
|
+
break
|
3643
|
+
end
|
3644
|
+
end
|
3645
|
+
if s7.empty?
|
3646
|
+
@index = i7
|
3647
|
+
r7 = nil
|
3648
|
+
else
|
3649
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
3650
|
+
end
|
3651
|
+
s6 << r7
|
3652
|
+
if r7
|
3653
|
+
if has_terminal?('=', false, index)
|
3654
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3655
|
+
@index += 1
|
3656
|
+
else
|
3657
|
+
terminal_parse_failure('=')
|
3658
|
+
r9 = nil
|
3659
|
+
end
|
3660
|
+
s6 << r9
|
3661
|
+
if r9
|
3662
|
+
r10 = _nt_dimension
|
3663
|
+
s6 << r10
|
3664
|
+
end
|
3665
|
+
end
|
3666
|
+
if s6.last
|
3667
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
3668
|
+
r6.extend(Argument4)
|
3669
|
+
r6.extend(Argument5)
|
3670
|
+
else
|
3671
|
+
@index = i6
|
3672
|
+
r6 = nil
|
3673
|
+
end
|
3674
|
+
if r6
|
3675
|
+
r0 = r6
|
3676
|
+
else
|
3677
|
+
s11, i11 = [], index
|
3678
|
+
loop do
|
3679
|
+
if has_terminal?('[-a-zA-Z0-9_%$/.&=:;#+?]', true, index)
|
3680
|
+
r12 = true
|
3681
|
+
@index += 1
|
3682
|
+
else
|
3683
|
+
r12 = nil
|
3684
|
+
end
|
3685
|
+
if r12
|
3686
|
+
s11 << r12
|
3687
|
+
else
|
3688
|
+
break
|
3689
|
+
end
|
3690
|
+
end
|
3691
|
+
if s11.empty?
|
3692
|
+
@index = i11
|
3693
|
+
r11 = nil
|
3694
|
+
else
|
3695
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
3696
|
+
r11.extend(Argument6)
|
3697
|
+
end
|
3698
|
+
if r11
|
3699
|
+
r0 = r11
|
3700
|
+
else
|
3701
|
+
@index = i0
|
3702
|
+
r0 = nil
|
3703
|
+
end
|
3704
|
+
end
|
3705
|
+
end
|
3706
|
+
end
|
3707
|
+
end
|
3708
|
+
|
3709
|
+
node_cache[:argument][start_index] = r0
|
3710
|
+
|
3711
|
+
r0
|
3712
|
+
end
|
3713
|
+
|
3714
|
+
def _nt_s
|
3715
|
+
start_index = index
|
3716
|
+
if node_cache[:s].has_key?(index)
|
3717
|
+
cached = node_cache[:s][index]
|
3718
|
+
@index = cached.interval.end if cached
|
3719
|
+
return cached
|
3720
|
+
end
|
3721
|
+
|
3722
|
+
s0, i0 = [], index
|
3723
|
+
loop do
|
3724
|
+
if has_terminal?('[ ]', true, index)
|
3725
|
+
r1 = true
|
3726
|
+
@index += 1
|
3727
|
+
else
|
3728
|
+
r1 = nil
|
3729
|
+
end
|
3730
|
+
if r1
|
3731
|
+
s0 << r1
|
3732
|
+
else
|
3733
|
+
break
|
3734
|
+
end
|
3735
|
+
end
|
3736
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3737
|
+
|
3738
|
+
node_cache[:s][start_index] = r0
|
3739
|
+
|
3740
|
+
r0
|
3741
|
+
end
|
3742
|
+
|
3743
|
+
def _nt_S
|
3744
|
+
start_index = index
|
3745
|
+
if node_cache[:S].has_key?(index)
|
3746
|
+
cached = node_cache[:S][index]
|
3747
|
+
@index = cached.interval.end if cached
|
3748
|
+
return cached
|
3749
|
+
end
|
3750
|
+
|
3751
|
+
s0, i0 = [], index
|
3752
|
+
loop do
|
3753
|
+
if has_terminal?('[ ]', true, index)
|
3754
|
+
r1 = true
|
3755
|
+
@index += 1
|
3756
|
+
else
|
3757
|
+
r1 = nil
|
3758
|
+
end
|
3759
|
+
if r1
|
3760
|
+
s0 << r1
|
3761
|
+
else
|
3762
|
+
break
|
3763
|
+
end
|
3764
|
+
end
|
3765
|
+
if s0.empty?
|
3766
|
+
@index = i0
|
3767
|
+
r0 = nil
|
3768
|
+
else
|
3769
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3770
|
+
end
|
3771
|
+
|
3772
|
+
node_cache[:S][start_index] = r0
|
3773
|
+
|
3774
|
+
r0
|
3775
|
+
end
|
3776
|
+
|
3777
|
+
def _nt_ws
|
3778
|
+
start_index = index
|
3779
|
+
if node_cache[:ws].has_key?(index)
|
3780
|
+
cached = node_cache[:ws][index]
|
3781
|
+
@index = cached.interval.end if cached
|
3782
|
+
return cached
|
3783
|
+
end
|
3784
|
+
|
3785
|
+
s0, i0 = [], index
|
3786
|
+
loop do
|
3787
|
+
if has_terminal?('[\\n ]', true, index)
|
3788
|
+
r1 = true
|
3789
|
+
@index += 1
|
3790
|
+
else
|
3791
|
+
r1 = nil
|
3792
|
+
end
|
3793
|
+
if r1
|
3794
|
+
s0 << r1
|
3795
|
+
else
|
3796
|
+
break
|
3797
|
+
end
|
3798
|
+
end
|
3799
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3800
|
+
|
3801
|
+
node_cache[:ws][start_index] = r0
|
3802
|
+
|
3803
|
+
r0
|
3804
|
+
end
|
3805
|
+
|
3806
|
+
module Ns0
|
3807
|
+
end
|
3808
|
+
|
3809
|
+
def _nt_ns
|
3810
|
+
start_index = index
|
3811
|
+
if node_cache[:ns].has_key?(index)
|
3812
|
+
cached = node_cache[:ns][index]
|
3813
|
+
@index = cached.interval.end if cached
|
3814
|
+
return cached
|
3815
|
+
end
|
3816
|
+
|
3817
|
+
i0, s0 = index, []
|
3818
|
+
i1 = index
|
3819
|
+
if has_terminal?('[ ;]', true, index)
|
3820
|
+
r2 = true
|
3821
|
+
@index += 1
|
3822
|
+
else
|
3823
|
+
r2 = nil
|
3824
|
+
end
|
3825
|
+
if r2
|
3826
|
+
r1 = nil
|
3827
|
+
else
|
3828
|
+
@index = i1
|
3829
|
+
r1 = instantiate_node(SyntaxNode,input, index...index)
|
3830
|
+
end
|
3831
|
+
s0 << r1
|
3832
|
+
if r1
|
3833
|
+
if index < input_length
|
3834
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3835
|
+
@index += 1
|
3836
|
+
else
|
3837
|
+
terminal_parse_failure("any character")
|
3838
|
+
r3 = nil
|
3839
|
+
end
|
3840
|
+
s0 << r3
|
3841
|
+
end
|
3842
|
+
if s0.last
|
3843
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3844
|
+
r0.extend(Ns0)
|
3845
|
+
else
|
3846
|
+
@index = i0
|
3847
|
+
r0 = nil
|
3848
|
+
end
|
3849
|
+
|
3850
|
+
node_cache[:ns][start_index] = r0
|
3851
|
+
|
3852
|
+
r0
|
3853
|
+
end
|
3854
|
+
|
3855
|
+
end
|
3856
|
+
|
3857
|
+
class LessParser < Treetop::Runtime::CompiledParser
|
3858
|
+
include Less
|
3859
|
+
end
|
3860
|
+
|