radiantcms-couchrest_model 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/radiantcms-couchrest_model.gemspec +12 -1
- data/vendor/radius/lib/radius/context.rb +139 -0
- data/vendor/radius/lib/radius/dostruct.rb +31 -0
- data/vendor/radius/lib/radius/errors.rb +24 -0
- data/vendor/radius/lib/radius/parser.rb +95 -0
- data/vendor/radius/lib/radius/parser/scan.rb +678 -0
- data/vendor/radius/lib/radius/parser/scan.rl +124 -0
- data/vendor/radius/lib/radius/parsetag.rb +23 -0
- data/vendor/radius/lib/radius/tagbinding.rb +66 -0
- data/vendor/radius/lib/radius/tagdefs.rb +78 -0
- data/vendor/radius/lib/radius/util.rb +34 -0
- metadata +12 -2
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{radiantcms-couchrest_model}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["davide-malagoli"]
|
@@ -2859,6 +2859,17 @@ a general purpose content managment system--not merely a blogging engine.}
|
|
2859
2859
|
"vendor/radius/CHANGELOG",
|
2860
2860
|
"vendor/radius/lib",
|
2861
2861
|
"vendor/radius/lib/radius19.rb",
|
2862
|
+
"vendor/radius/lib/radius/errors.rb",
|
2863
|
+
"vendor/radius/lib/radius/context.rb",
|
2864
|
+
"vendor/radius/lib/radius/dostruct.rb",
|
2865
|
+
"vendor/radius/lib/radius/parser.rb",
|
2866
|
+
"vendor/radius/lib/radius/parsetag.rb",
|
2867
|
+
"vendor/radius/lib/radius/tagbinding.rb",
|
2868
|
+
"vendor/radius/lib/radius/tagdefs.rb",
|
2869
|
+
"vendor/radius/lib/radius/util.rb",
|
2870
|
+
"vendor/radius/lib/radius/parser/",
|
2871
|
+
"vendor/radius/lib/radius/parser/scan.rb",
|
2872
|
+
"vendor/radius/lib/radius/parser/scan.rl",
|
2862
2873
|
"vendor/radius/README",
|
2863
2874
|
"vendor/radius/test",
|
2864
2875
|
"vendor/radius/test/context_test.rb",
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module Radius
|
2
|
+
#
|
3
|
+
# A context contains the tag definitions which are available for use in a template.
|
4
|
+
# See the QUICKSTART[link:files/QUICKSTART.html] for a detailed explaination its
|
5
|
+
# usage.
|
6
|
+
#
|
7
|
+
class Context
|
8
|
+
# A hash of tag definition blocks that define tags accessible on a Context.
|
9
|
+
attr_accessor :definitions # :nodoc:
|
10
|
+
attr_accessor :globals # :nodoc:
|
11
|
+
|
12
|
+
# Creates a new Context object.
|
13
|
+
def initialize(&block)
|
14
|
+
@definitions = {}
|
15
|
+
@tag_binding_stack = []
|
16
|
+
@globals = DelegatingOpenStruct.new
|
17
|
+
with(&block) if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
# Yeild an instance of self for tag definitions:
|
21
|
+
#
|
22
|
+
# context.with do |c|
|
23
|
+
# c.define_tag 'test' do
|
24
|
+
# 'test'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
def with
|
29
|
+
yield self
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
# Creates a tag definition on a context. Several options are available to you
|
34
|
+
# when creating a tag:
|
35
|
+
#
|
36
|
+
# +for+:: Specifies an object that the tag is in reference to. This is
|
37
|
+
# applicable when a block is not passed to the tag, or when the
|
38
|
+
# +expose+ option is also used.
|
39
|
+
#
|
40
|
+
# +expose+:: Specifies that child tags should be set for each of the methods
|
41
|
+
# contained in this option. May be either a single symbol/string or
|
42
|
+
# an array of symbols/strings.
|
43
|
+
#
|
44
|
+
# +attributes+:: Specifies whether or not attributes should be exposed
|
45
|
+
# automatically. Useful for ActiveRecord objects. Boolean. Defaults
|
46
|
+
# to +true+.
|
47
|
+
#
|
48
|
+
def define_tag(name, options = {}, &block)
|
49
|
+
type = Util.impartial_hash_delete(options, :type).to_s
|
50
|
+
klass = Util.constantize('Radius::TagDefinitions::' + Util.camelize(type) + 'TagFactory') rescue raise(ArgumentError.new("Undefined type `#{type}' in options hash"))
|
51
|
+
klass.new(self).define_tag(name, options, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the value of a rendered tag. Used internally by Parser#parse.
|
55
|
+
def render_tag(name, attributes = {}, &block)
|
56
|
+
if name =~ /^(.+?):(.+)$/
|
57
|
+
render_tag($1) { render_tag($2, attributes, &block) }
|
58
|
+
else
|
59
|
+
tag_definition_block = @definitions[qualified_tag_name(name.to_s)]
|
60
|
+
if tag_definition_block
|
61
|
+
stack(name, attributes, block) do |tag|
|
62
|
+
tag_definition_block.call(tag).to_s
|
63
|
+
end
|
64
|
+
else
|
65
|
+
tag_missing(name, attributes, &block)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Like method_missing for objects, but fired when a tag is undefined.
|
71
|
+
# Override in your own Context to change what happens when a tag is
|
72
|
+
# undefined. By default this method raises an UndefinedTagError.
|
73
|
+
def tag_missing(name, attributes, &block)
|
74
|
+
raise UndefinedTagError.new(name)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the state of the current render stack. Useful from inside
|
78
|
+
# a tag definition. Normally just use TagBinding#nesting.
|
79
|
+
def current_nesting
|
80
|
+
@tag_binding_stack.collect { |tag| tag.name }.join(':')
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
# A convienence method for managing the various parts of the
|
86
|
+
# tag binding stack.
|
87
|
+
def stack(name, attributes, block)
|
88
|
+
previous = @tag_binding_stack.last
|
89
|
+
previous_locals = previous.nil? ? @globals : previous.locals
|
90
|
+
locals = DelegatingOpenStruct.new(previous_locals)
|
91
|
+
binding = TagBinding.new(self, locals, name, attributes, block)
|
92
|
+
@tag_binding_stack.push(binding)
|
93
|
+
result = yield(binding)
|
94
|
+
@tag_binding_stack.pop
|
95
|
+
result
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns a fully qualified tag name based on state of the
|
99
|
+
# tag binding stack.
|
100
|
+
def qualified_tag_name(name)
|
101
|
+
nesting_parts = @tag_binding_stack.collect { |tag| tag.name }
|
102
|
+
nesting_parts << name unless nesting_parts.last == name
|
103
|
+
specific_name = nesting_parts.join(':') # specific_name always has the highest specificity
|
104
|
+
unless @definitions.has_key? specific_name
|
105
|
+
possible_matches = @definitions.keys.grep(/(^|:)#{name}$/)
|
106
|
+
specificity = possible_matches.inject({}) { |hash, tag| hash[numeric_specificity(tag, nesting_parts)] = tag; hash }
|
107
|
+
max = specificity.keys.max
|
108
|
+
if max != 0
|
109
|
+
specificity[max]
|
110
|
+
else
|
111
|
+
name
|
112
|
+
end
|
113
|
+
else
|
114
|
+
specific_name
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns the specificity for +tag_name+ at nesting defined
|
119
|
+
# by +nesting_parts+ as a number.
|
120
|
+
def numeric_specificity(tag_name, nesting_parts)
|
121
|
+
nesting_parts = nesting_parts.dup
|
122
|
+
name_parts = tag_name.split(':')
|
123
|
+
specificity = 0
|
124
|
+
value = 1
|
125
|
+
if nesting_parts.last == name_parts.last
|
126
|
+
while nesting_parts.size > 0
|
127
|
+
if nesting_parts.last == name_parts.last
|
128
|
+
specificity += value
|
129
|
+
name_parts.pop
|
130
|
+
end
|
131
|
+
nesting_parts.pop
|
132
|
+
value *= 0.1
|
133
|
+
end
|
134
|
+
specificity = 0 if (name_parts.size > 0)
|
135
|
+
end
|
136
|
+
specificity
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Radius
|
2
|
+
class DelegatingOpenStruct # :nodoc:
|
3
|
+
attr_accessor :object
|
4
|
+
|
5
|
+
def initialize(object = nil)
|
6
|
+
@object = object
|
7
|
+
@hash = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method, *args, &block)
|
11
|
+
symbol = (method.to_s =~ /^(.*?)=$/) ? $1.intern : method
|
12
|
+
if (0..1).include?(args.size)
|
13
|
+
if args.size == 1
|
14
|
+
@hash[symbol] = args.first
|
15
|
+
else
|
16
|
+
if @hash.has_key?(symbol)
|
17
|
+
@hash[symbol]
|
18
|
+
else
|
19
|
+
unless object.nil?
|
20
|
+
@object.send(method, *args, &block)
|
21
|
+
else
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Radius
|
2
|
+
|
3
|
+
# Abstract base class for all parsing errors.
|
4
|
+
class ParseError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
# Occurs when Parser cannot find an end tag for a given tag in a template or when
|
8
|
+
# tags are miss-matched in a template.
|
9
|
+
class MissingEndTagError < ParseError
|
10
|
+
# Create a new MissingEndTagError object for +tag_name+.
|
11
|
+
def initialize(tag_name)
|
12
|
+
super("end tag not found for start tag `#{tag_name}'")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Occurs when Context#render_tag cannot find the specified tag on a Context.
|
17
|
+
class UndefinedTagError < ParseError
|
18
|
+
# Create a new UndefinedTagError object for +tag_name+.
|
19
|
+
def initialize(tag_name)
|
20
|
+
super("undefined tag `#{tag_name}'")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Radius
|
2
|
+
#
|
3
|
+
# The Radius parser. Initialize a parser with a Context object that
|
4
|
+
# defines how tags should be expanded. See the QUICKSTART[link:files/QUICKSTART.html]
|
5
|
+
# for a detailed explaination of its usage.
|
6
|
+
#
|
7
|
+
class Parser
|
8
|
+
# The Context object used to expand template tags.
|
9
|
+
attr_accessor :context
|
10
|
+
|
11
|
+
# The string that prefixes all tags that are expanded by a parser
|
12
|
+
# (the part in the tag name before the first colon).
|
13
|
+
attr_accessor :tag_prefix
|
14
|
+
|
15
|
+
# Creates a new parser object initialized with a Context.
|
16
|
+
def initialize(context = Context.new, options = {})
|
17
|
+
if context.kind_of?(Hash) and options.empty?
|
18
|
+
options = context
|
19
|
+
context = options[:context] || options['context'] || Context.new
|
20
|
+
end
|
21
|
+
options = Util.symbolize_keys(options)
|
22
|
+
@context = context
|
23
|
+
@tag_prefix = options[:tag_prefix]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Parses string for tags, expands them, and returns the result.
|
27
|
+
def parse(string)
|
28
|
+
@stack = [ParseContainerTag.new { |t| Util.recurring_array_to_s(t.contents) }]
|
29
|
+
pre_parse(string)
|
30
|
+
@stack.last.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def pre_parse(text) # :nodoc:
|
36
|
+
re = %r{<#{@tag_prefix}:([\w:]+?)(\s+(?:\w+\s*=\s*(?:"[^"]*?"|'[^']*?')\s*)*|)>|</#{@tag_prefix}:([\w:]+?)\s*>}
|
37
|
+
if md = re.match(text)
|
38
|
+
start_tag, attr, end_tag = $1, $2, $3
|
39
|
+
@stack.last.contents << ParseTag.new { parse_individual(md.pre_match) }
|
40
|
+
remaining = md.post_match
|
41
|
+
if start_tag
|
42
|
+
parse_start_tag(start_tag, attr, remaining)
|
43
|
+
else
|
44
|
+
parse_end_tag(end_tag, remaining)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
if @stack.length == 1
|
48
|
+
@stack.last.contents << ParseTag.new { parse_individual(text) }
|
49
|
+
else
|
50
|
+
raise MissingEndTagError.new(@stack.last.name)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_start_tag(start_tag, attr, remaining) # :nodoc:
|
56
|
+
@stack.push(ParseContainerTag.new(start_tag, parse_attributes(attr)))
|
57
|
+
pre_parse(remaining)
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_end_tag(end_tag, remaining) # :nodoc:
|
61
|
+
popped = @stack.pop
|
62
|
+
if popped.name == end_tag
|
63
|
+
popped.on_parse do |t|
|
64
|
+
@context.render_tag(popped.name, popped.attributes) { Util.recurring_array_to_s(t.contents) }
|
65
|
+
end
|
66
|
+
tag = @stack.last
|
67
|
+
tag.contents << popped
|
68
|
+
pre_parse(remaining)
|
69
|
+
else
|
70
|
+
raise MissingEndTagError.new(popped.name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def parse_individual(text) # :nodoc:
|
75
|
+
re = %r{<#{@tag_prefix}:([\w:]+?)(\s+(?:\w+\s*=\s*(?:"[^"]*?"|'[^']*?')\s*)*|)/>}
|
76
|
+
if md = re.match(text)
|
77
|
+
attr = parse_attributes($2)
|
78
|
+
replace = @context.render_tag($1, attr)
|
79
|
+
md.pre_match + replace + parse_individual(md.post_match)
|
80
|
+
else
|
81
|
+
text || ''
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def parse_attributes(text) # :nodoc:
|
86
|
+
attr = {}
|
87
|
+
re = /(\w+?)\s*=\s*('|")(.*?)\2/
|
88
|
+
while md = re.match(text)
|
89
|
+
attr[$1] = $3
|
90
|
+
text = md.post_match
|
91
|
+
end
|
92
|
+
attr
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,678 @@
|
|
1
|
+
|
2
|
+
# line 1 "scan.rl"
|
3
|
+
|
4
|
+
# line 84 "scan.rl"
|
5
|
+
|
6
|
+
|
7
|
+
module Radius
|
8
|
+
class Scanner
|
9
|
+
def self.operate(prefix, data)
|
10
|
+
buf = ""
|
11
|
+
csel = ""
|
12
|
+
@prematch = ''
|
13
|
+
@starttag = nil
|
14
|
+
@attrs = {}
|
15
|
+
@flavor = :tasteless
|
16
|
+
@cursor = 0
|
17
|
+
@tagstart = 0
|
18
|
+
@nodes = ['']
|
19
|
+
remainder = data.dup
|
20
|
+
|
21
|
+
until remainder.length == 0
|
22
|
+
p = perform_parse(prefix, remainder)
|
23
|
+
remainder = remainder[p..-1]
|
24
|
+
end
|
25
|
+
|
26
|
+
return @nodes
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def self.perform_parse(prefix, data)
|
31
|
+
stack = []
|
32
|
+
p = 0
|
33
|
+
ts = 0
|
34
|
+
te = 0
|
35
|
+
act = 0
|
36
|
+
eof = data.length
|
37
|
+
|
38
|
+
@prefix = prefix
|
39
|
+
|
40
|
+
# line 41 "scan.rb"
|
41
|
+
class << self
|
42
|
+
attr_accessor :_parser_actions
|
43
|
+
private :_parser_actions, :_parser_actions=
|
44
|
+
end
|
45
|
+
self._parser_actions = [
|
46
|
+
0, 1, 0, 1, 1, 1, 2, 1,
|
47
|
+
3, 1, 4, 1, 5, 1, 6, 1,
|
48
|
+
7, 1, 8, 1, 9, 1, 13, 1,
|
49
|
+
14, 1, 18, 1, 20, 1, 21, 1,
|
50
|
+
22, 2, 4, 5, 2, 5, 6, 2,
|
51
|
+
8, 4, 2, 8, 9, 2, 9, 8,
|
52
|
+
2, 10, 19, 2, 11, 19, 2, 12,
|
53
|
+
19, 2, 15, 16, 2, 15, 17, 3,
|
54
|
+
4, 5, 6, 3, 8, 4, 5, 3,
|
55
|
+
15, 5, 16, 4, 8, 4, 5, 6,
|
56
|
+
4, 15, 4, 5, 16, 5, 15, 8,
|
57
|
+
4, 5, 16
|
58
|
+
]
|
59
|
+
|
60
|
+
class << self
|
61
|
+
attr_accessor :_parser_key_offsets
|
62
|
+
private :_parser_key_offsets, :_parser_key_offsets=
|
63
|
+
end
|
64
|
+
self._parser_key_offsets = [
|
65
|
+
0, 0, 11, 21, 34, 47, 61, 65,
|
66
|
+
70, 72, 74, 87, 100, 101, 103, 118,
|
67
|
+
133, 149, 155, 161, 176, 179, 182, 185,
|
68
|
+
200, 202, 204, 219, 235, 241, 247, 250,
|
69
|
+
253, 269, 285, 302, 309, 315, 331, 335,
|
70
|
+
351, 366, 369, 371, 381, 392, 402, 416,
|
71
|
+
420, 420, 421, 430, 430, 430, 432, 434,
|
72
|
+
437, 440, 442, 444
|
73
|
+
]
|
74
|
+
|
75
|
+
class << self
|
76
|
+
attr_accessor :_parser_trans_keys
|
77
|
+
private :_parser_trans_keys, :_parser_trans_keys=
|
78
|
+
end
|
79
|
+
self._parser_trans_keys = [
|
80
|
+
58, 63, 95, 45, 46, 48, 57, 65,
|
81
|
+
90, 97, 122, 63, 95, 45, 46, 48,
|
82
|
+
58, 65, 90, 97, 122, 32, 47, 62,
|
83
|
+
63, 95, 9, 13, 45, 58, 65, 90,
|
84
|
+
97, 122, 32, 47, 62, 63, 95, 9,
|
85
|
+
13, 45, 58, 65, 90, 97, 122, 32,
|
86
|
+
61, 63, 95, 9, 13, 45, 46, 48,
|
87
|
+
58, 65, 90, 97, 122, 32, 61, 9,
|
88
|
+
13, 32, 34, 39, 9, 13, 34, 92,
|
89
|
+
34, 92, 32, 47, 62, 63, 95, 9,
|
90
|
+
13, 45, 58, 65, 90, 97, 122, 32,
|
91
|
+
47, 62, 63, 95, 9, 13, 45, 58,
|
92
|
+
65, 90, 97, 122, 62, 34, 92, 32,
|
93
|
+
34, 47, 62, 63, 92, 95, 9, 13,
|
94
|
+
45, 58, 65, 90, 97, 122, 32, 34,
|
95
|
+
47, 62, 63, 92, 95, 9, 13, 45,
|
96
|
+
58, 65, 90, 97, 122, 32, 34, 61,
|
97
|
+
63, 92, 95, 9, 13, 45, 46, 48,
|
98
|
+
58, 65, 90, 97, 122, 32, 34, 61,
|
99
|
+
92, 9, 13, 32, 34, 39, 92, 9,
|
100
|
+
13, 32, 34, 47, 62, 63, 92, 95,
|
101
|
+
9, 13, 45, 58, 65, 90, 97, 122,
|
102
|
+
34, 62, 92, 34, 39, 92, 34, 39,
|
103
|
+
92, 32, 39, 47, 62, 63, 92, 95,
|
104
|
+
9, 13, 45, 58, 65, 90, 97, 122,
|
105
|
+
39, 92, 39, 92, 32, 39, 47, 62,
|
106
|
+
63, 92, 95, 9, 13, 45, 58, 65,
|
107
|
+
90, 97, 122, 32, 39, 61, 63, 92,
|
108
|
+
95, 9, 13, 45, 46, 48, 58, 65,
|
109
|
+
90, 97, 122, 32, 39, 61, 92, 9,
|
110
|
+
13, 32, 34, 39, 92, 9, 13, 34,
|
111
|
+
39, 92, 34, 39, 92, 32, 34, 39,
|
112
|
+
47, 62, 63, 92, 95, 9, 13, 45,
|
113
|
+
58, 65, 90, 97, 122, 32, 34, 39,
|
114
|
+
47, 62, 63, 92, 95, 9, 13, 45,
|
115
|
+
58, 65, 90, 97, 122, 32, 34, 39,
|
116
|
+
61, 63, 92, 95, 9, 13, 45, 46,
|
117
|
+
48, 58, 65, 90, 97, 122, 32, 34,
|
118
|
+
39, 61, 92, 9, 13, 32, 34, 39,
|
119
|
+
92, 9, 13, 32, 34, 39, 47, 62,
|
120
|
+
63, 92, 95, 9, 13, 45, 58, 65,
|
121
|
+
90, 97, 122, 34, 39, 62, 92, 32,
|
122
|
+
34, 39, 47, 62, 63, 92, 95, 9,
|
123
|
+
13, 45, 58, 65, 90, 97, 122, 32,
|
124
|
+
39, 47, 62, 63, 92, 95, 9, 13,
|
125
|
+
45, 58, 65, 90, 97, 122, 39, 62,
|
126
|
+
92, 39, 92, 63, 95, 45, 46, 48,
|
127
|
+
57, 65, 90, 97, 122, 58, 63, 95,
|
128
|
+
45, 46, 48, 57, 65, 90, 97, 122,
|
129
|
+
63, 95, 45, 46, 48, 58, 65, 90,
|
130
|
+
97, 122, 32, 62, 63, 95, 9, 13,
|
131
|
+
45, 46, 48, 58, 65, 90, 97, 122,
|
132
|
+
32, 62, 9, 13, 60, 47, 63, 95,
|
133
|
+
45, 57, 65, 90, 97, 122, 34, 92,
|
134
|
+
34, 92, 34, 39, 92, 34, 39, 92,
|
135
|
+
39, 92, 39, 92, 0
|
136
|
+
]
|
137
|
+
|
138
|
+
class << self
|
139
|
+
attr_accessor :_parser_single_lengths
|
140
|
+
private :_parser_single_lengths, :_parser_single_lengths=
|
141
|
+
end
|
142
|
+
self._parser_single_lengths = [
|
143
|
+
0, 3, 2, 5, 5, 4, 2, 3,
|
144
|
+
2, 2, 5, 5, 1, 2, 7, 7,
|
145
|
+
6, 4, 4, 7, 3, 3, 3, 7,
|
146
|
+
2, 2, 7, 6, 4, 4, 3, 3,
|
147
|
+
8, 8, 7, 5, 4, 8, 4, 8,
|
148
|
+
7, 3, 2, 2, 3, 2, 4, 2,
|
149
|
+
0, 1, 3, 0, 0, 2, 2, 3,
|
150
|
+
3, 2, 2, 0
|
151
|
+
]
|
152
|
+
|
153
|
+
class << self
|
154
|
+
attr_accessor :_parser_range_lengths
|
155
|
+
private :_parser_range_lengths, :_parser_range_lengths=
|
156
|
+
end
|
157
|
+
self._parser_range_lengths = [
|
158
|
+
0, 4, 4, 4, 4, 5, 1, 1,
|
159
|
+
0, 0, 4, 4, 0, 0, 4, 4,
|
160
|
+
5, 1, 1, 4, 0, 0, 0, 4,
|
161
|
+
0, 0, 4, 5, 1, 1, 0, 0,
|
162
|
+
4, 4, 5, 1, 1, 4, 0, 4,
|
163
|
+
4, 0, 0, 4, 4, 4, 5, 1,
|
164
|
+
0, 0, 3, 0, 0, 0, 0, 0,
|
165
|
+
0, 0, 0, 0
|
166
|
+
]
|
167
|
+
|
168
|
+
class << self
|
169
|
+
attr_accessor :_parser_index_offsets
|
170
|
+
private :_parser_index_offsets, :_parser_index_offsets=
|
171
|
+
end
|
172
|
+
self._parser_index_offsets = [
|
173
|
+
0, 0, 8, 15, 25, 35, 45, 49,
|
174
|
+
54, 57, 60, 70, 80, 82, 85, 97,
|
175
|
+
109, 121, 127, 133, 145, 149, 153, 157,
|
176
|
+
169, 172, 175, 187, 199, 205, 211, 215,
|
177
|
+
219, 232, 245, 258, 265, 271, 284, 289,
|
178
|
+
302, 314, 318, 321, 328, 336, 343, 353,
|
179
|
+
357, 358, 360, 367, 368, 369, 372, 375,
|
180
|
+
379, 383, 386, 389
|
181
|
+
]
|
182
|
+
|
183
|
+
class << self
|
184
|
+
attr_accessor :_parser_indicies
|
185
|
+
private :_parser_indicies, :_parser_indicies=
|
186
|
+
end
|
187
|
+
self._parser_indicies = [
|
188
|
+
2, 1, 1, 1, 1, 1, 1, 0,
|
189
|
+
3, 3, 3, 3, 3, 3, 0, 4,
|
190
|
+
6, 7, 5, 5, 4, 5, 5, 5,
|
191
|
+
0, 8, 10, 11, 9, 9, 8, 9,
|
192
|
+
9, 9, 0, 13, 15, 14, 14, 13,
|
193
|
+
14, 14, 14, 14, 12, 16, 17, 16,
|
194
|
+
12, 17, 18, 19, 17, 12, 21, 22,
|
195
|
+
20, 24, 25, 23, 26, 28, 29, 27,
|
196
|
+
27, 26, 27, 27, 27, 12, 30, 32,
|
197
|
+
33, 31, 31, 30, 31, 31, 31, 12,
|
198
|
+
34, 12, 35, 25, 23, 36, 24, 38,
|
199
|
+
39, 37, 25, 37, 36, 37, 37, 37,
|
200
|
+
23, 40, 24, 42, 43, 41, 25, 41,
|
201
|
+
40, 41, 41, 41, 23, 44, 24, 46,
|
202
|
+
45, 25, 45, 44, 45, 45, 45, 45,
|
203
|
+
23, 47, 24, 48, 25, 47, 23, 48,
|
204
|
+
49, 50, 25, 48, 23, 51, 21, 53,
|
205
|
+
54, 52, 22, 52, 51, 52, 52, 52,
|
206
|
+
20, 24, 55, 25, 23, 57, 58, 59,
|
207
|
+
56, 61, 35, 62, 60, 64, 24, 66,
|
208
|
+
67, 65, 68, 65, 64, 65, 65, 65,
|
209
|
+
63, 24, 68, 63, 61, 68, 63, 69,
|
210
|
+
24, 71, 72, 70, 68, 70, 69, 70,
|
211
|
+
70, 70, 63, 73, 24, 75, 74, 68,
|
212
|
+
74, 73, 74, 74, 74, 74, 63, 76,
|
213
|
+
24, 77, 68, 76, 63, 77, 78, 79,
|
214
|
+
68, 77, 63, 80, 58, 59, 56, 81,
|
215
|
+
81, 62, 60, 82, 61, 35, 84, 85,
|
216
|
+
83, 62, 83, 82, 83, 83, 83, 60,
|
217
|
+
86, 61, 35, 88, 89, 87, 62, 87,
|
218
|
+
86, 87, 87, 87, 60, 90, 61, 35,
|
219
|
+
92, 91, 62, 91, 90, 91, 91, 91,
|
220
|
+
91, 60, 93, 61, 35, 94, 62, 93,
|
221
|
+
60, 94, 95, 96, 62, 94, 60, 97,
|
222
|
+
80, 58, 99, 100, 98, 59, 98, 97,
|
223
|
+
98, 98, 98, 56, 61, 35, 101, 62,
|
224
|
+
60, 97, 57, 58, 99, 100, 98, 59,
|
225
|
+
98, 97, 98, 98, 98, 56, 103, 21,
|
226
|
+
105, 106, 104, 107, 104, 103, 104, 104,
|
227
|
+
104, 102, 24, 108, 68, 63, 21, 107,
|
228
|
+
102, 109, 109, 109, 109, 109, 109, 0,
|
229
|
+
111, 110, 110, 110, 110, 110, 110, 0,
|
230
|
+
112, 112, 112, 112, 112, 112, 0, 113,
|
231
|
+
115, 114, 114, 113, 114, 114, 114, 114,
|
232
|
+
0, 116, 117, 116, 0, 118, 120, 119,
|
233
|
+
123, 122, 122, 122, 122, 122, 121, 124,
|
234
|
+
125, 24, 25, 23, 24, 25, 23, 61,
|
235
|
+
35, 62, 60, 61, 35, 62, 60, 24,
|
236
|
+
68, 63, 24, 68, 63, 126, 0
|
237
|
+
]
|
238
|
+
|
239
|
+
class << self
|
240
|
+
attr_accessor :_parser_trans_targs
|
241
|
+
private :_parser_trans_targs, :_parser_trans_targs=
|
242
|
+
end
|
243
|
+
self._parser_trans_targs = [
|
244
|
+
49, 1, 2, 3, 4, 3, 12, 52,
|
245
|
+
4, 5, 12, 52, 49, 6, 5, 7,
|
246
|
+
6, 7, 8, 42, 9, 10, 13, 9,
|
247
|
+
10, 13, 11, 5, 12, 52, 11, 5,
|
248
|
+
12, 52, 51, 14, 15, 16, 20, 54,
|
249
|
+
15, 16, 20, 54, 17, 16, 18, 17,
|
250
|
+
18, 19, 21, 15, 16, 20, 54, 53,
|
251
|
+
22, 23, 14, 31, 22, 23, 31, 24,
|
252
|
+
26, 27, 41, 58, 25, 26, 27, 41,
|
253
|
+
58, 28, 27, 29, 28, 29, 30, 40,
|
254
|
+
23, 32, 33, 34, 38, 56, 33, 34,
|
255
|
+
38, 56, 35, 34, 36, 35, 36, 37,
|
256
|
+
39, 33, 34, 38, 56, 55, 24, 26,
|
257
|
+
27, 41, 58, 25, 57, 44, 44, 45,
|
258
|
+
46, 47, 46, 59, 47, 59, 0, 49,
|
259
|
+
50, 49, 1, 43, 49, 49, 49
|
260
|
+
]
|
261
|
+
|
262
|
+
class << self
|
263
|
+
attr_accessor :_parser_trans_actions
|
264
|
+
private :_parser_trans_actions, :_parser_trans_actions=
|
265
|
+
end
|
266
|
+
self._parser_trans_actions = [
|
267
|
+
29, 0, 3, 5, 7, 0, 7, 7,
|
268
|
+
0, 13, 0, 0, 31, 15, 0, 15,
|
269
|
+
0, 0, 0, 0, 17, 42, 17, 0,
|
270
|
+
19, 0, 9, 63, 33, 33, 0, 36,
|
271
|
+
11, 11, 0, 19, 9, 63, 33, 80,
|
272
|
+
0, 36, 11, 71, 15, 0, 15, 0,
|
273
|
+
0, 19, 0, 39, 75, 67, 85, 57,
|
274
|
+
17, 45, 42, 17, 0, 19, 0, 0,
|
275
|
+
9, 63, 33, 80, 0, 0, 36, 11,
|
276
|
+
71, 15, 0, 15, 0, 0, 0, 19,
|
277
|
+
42, 19, 9, 63, 33, 80, 0, 36,
|
278
|
+
11, 71, 15, 0, 15, 0, 0, 19,
|
279
|
+
19, 39, 75, 67, 85, 57, 17, 39,
|
280
|
+
75, 67, 85, 17, 57, 1, 0, 3,
|
281
|
+
5, 7, 0, 7, 0, 0, 0, 25,
|
282
|
+
60, 27, 1, 0, 51, 48, 54
|
283
|
+
]
|
284
|
+
|
285
|
+
class << self
|
286
|
+
attr_accessor :_parser_to_state_actions
|
287
|
+
private :_parser_to_state_actions, :_parser_to_state_actions=
|
288
|
+
end
|
289
|
+
self._parser_to_state_actions = [
|
290
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
291
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
292
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
293
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
294
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
295
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
296
|
+
21, 21, 0, 0, 0, 0, 0, 0,
|
297
|
+
0, 0, 0, 0
|
298
|
+
]
|
299
|
+
|
300
|
+
class << self
|
301
|
+
attr_accessor :_parser_from_state_actions
|
302
|
+
private :_parser_from_state_actions, :_parser_from_state_actions=
|
303
|
+
end
|
304
|
+
self._parser_from_state_actions = [
|
305
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
306
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
307
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
308
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
309
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
310
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
311
|
+
0, 23, 0, 0, 0, 0, 0, 0,
|
312
|
+
0, 0, 0, 0
|
313
|
+
]
|
314
|
+
|
315
|
+
class << self
|
316
|
+
attr_accessor :_parser_eof_trans
|
317
|
+
private :_parser_eof_trans, :_parser_eof_trans=
|
318
|
+
end
|
319
|
+
self._parser_eof_trans = [
|
320
|
+
0, 1, 1, 1, 1, 13, 13, 13,
|
321
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
322
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
323
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
324
|
+
13, 13, 13, 13, 13, 13, 13, 13,
|
325
|
+
13, 13, 13, 1, 1, 1, 1, 1,
|
326
|
+
0, 0, 122, 125, 126, 125, 126, 125,
|
327
|
+
126, 125, 126, 127
|
328
|
+
]
|
329
|
+
|
330
|
+
class << self
|
331
|
+
attr_accessor :parser_start
|
332
|
+
end
|
333
|
+
self.parser_start = 49;
|
334
|
+
class << self
|
335
|
+
attr_accessor :parser_first_final
|
336
|
+
end
|
337
|
+
self.parser_first_final = 49;
|
338
|
+
class << self
|
339
|
+
attr_accessor :parser_error
|
340
|
+
end
|
341
|
+
self.parser_error = 0;
|
342
|
+
|
343
|
+
class << self
|
344
|
+
attr_accessor :parser_en_Closeout
|
345
|
+
end
|
346
|
+
self.parser_en_Closeout = 48;
|
347
|
+
class << self
|
348
|
+
attr_accessor :parser_en_main
|
349
|
+
end
|
350
|
+
self.parser_en_main = 49;
|
351
|
+
|
352
|
+
|
353
|
+
# line 119 "scan.rl"
|
354
|
+
|
355
|
+
# line 356 "scan.rb"
|
356
|
+
begin
|
357
|
+
p ||= 0
|
358
|
+
pe ||= data.length
|
359
|
+
cs = parser_start
|
360
|
+
ts = nil
|
361
|
+
te = nil
|
362
|
+
act = 0
|
363
|
+
end
|
364
|
+
|
365
|
+
# line 120 "scan.rl"
|
366
|
+
|
367
|
+
# line 368 "scan.rb"
|
368
|
+
begin
|
369
|
+
_klen, _trans, _keys, _acts, _nacts = nil
|
370
|
+
_goto_level = 0
|
371
|
+
_resume = 10
|
372
|
+
_eof_trans = 15
|
373
|
+
_again = 20
|
374
|
+
_test_eof = 30
|
375
|
+
_out = 40
|
376
|
+
while true
|
377
|
+
_trigger_goto = false
|
378
|
+
if _goto_level <= 0
|
379
|
+
if p == pe
|
380
|
+
_goto_level = _test_eof
|
381
|
+
next
|
382
|
+
end
|
383
|
+
if cs == 0
|
384
|
+
_goto_level = _out
|
385
|
+
next
|
386
|
+
end
|
387
|
+
end
|
388
|
+
if _goto_level <= _resume
|
389
|
+
_acts = _parser_from_state_actions[cs]
|
390
|
+
_nacts = _parser_actions[_acts]
|
391
|
+
_acts += 1
|
392
|
+
while _nacts > 0
|
393
|
+
_nacts -= 1
|
394
|
+
_acts += 1
|
395
|
+
case _parser_actions[_acts - 1]
|
396
|
+
when 14 then
|
397
|
+
# line 1 "NONE"
|
398
|
+
begin
|
399
|
+
ts = p
|
400
|
+
end
|
401
|
+
# line 402 "scan.rb"
|
402
|
+
end # from state action switch
|
403
|
+
end
|
404
|
+
if _trigger_goto
|
405
|
+
next
|
406
|
+
end
|
407
|
+
_keys = _parser_key_offsets[cs]
|
408
|
+
_trans = _parser_index_offsets[cs]
|
409
|
+
_klen = _parser_single_lengths[cs]
|
410
|
+
_break_match = false
|
411
|
+
|
412
|
+
begin
|
413
|
+
if _klen > 0
|
414
|
+
_lower = _keys
|
415
|
+
_upper = _keys + _klen - 1
|
416
|
+
|
417
|
+
loop do
|
418
|
+
break if _upper < _lower
|
419
|
+
_mid = _lower + ( (_upper - _lower) >> 1 )
|
420
|
+
|
421
|
+
if data[p] < _parser_trans_keys[_mid]
|
422
|
+
_upper = _mid - 1
|
423
|
+
elsif data[p] > _parser_trans_keys[_mid]
|
424
|
+
_lower = _mid + 1
|
425
|
+
else
|
426
|
+
_trans += (_mid - _keys)
|
427
|
+
_break_match = true
|
428
|
+
break
|
429
|
+
end
|
430
|
+
end # loop
|
431
|
+
break if _break_match
|
432
|
+
_keys += _klen
|
433
|
+
_trans += _klen
|
434
|
+
end
|
435
|
+
_klen = _parser_range_lengths[cs]
|
436
|
+
if _klen > 0
|
437
|
+
_lower = _keys
|
438
|
+
_upper = _keys + (_klen << 1) - 2
|
439
|
+
loop do
|
440
|
+
break if _upper < _lower
|
441
|
+
_mid = _lower + (((_upper-_lower) >> 1) & ~1)
|
442
|
+
if data[p] < _parser_trans_keys[_mid]
|
443
|
+
_upper = _mid - 2
|
444
|
+
elsif data[p] > _parser_trans_keys[_mid+1]
|
445
|
+
_lower = _mid + 2
|
446
|
+
else
|
447
|
+
_trans += ((_mid - _keys) >> 1)
|
448
|
+
_break_match = true
|
449
|
+
break
|
450
|
+
end
|
451
|
+
end # loop
|
452
|
+
break if _break_match
|
453
|
+
_trans += _klen
|
454
|
+
end
|
455
|
+
end while false
|
456
|
+
_trans = _parser_indicies[_trans]
|
457
|
+
end
|
458
|
+
if _goto_level <= _eof_trans
|
459
|
+
cs = _parser_trans_targs[_trans]
|
460
|
+
if _parser_trans_actions[_trans] != 0
|
461
|
+
_acts = _parser_trans_actions[_trans]
|
462
|
+
_nacts = _parser_actions[_acts]
|
463
|
+
_acts += 1
|
464
|
+
while _nacts > 0
|
465
|
+
_nacts -= 1
|
466
|
+
_acts += 1
|
467
|
+
case _parser_actions[_acts - 1]
|
468
|
+
when 0 then
|
469
|
+
# line 5 "scan.rl"
|
470
|
+
begin
|
471
|
+
mark_pfx = p end
|
472
|
+
when 1 then
|
473
|
+
# line 6 "scan.rl"
|
474
|
+
begin
|
475
|
+
|
476
|
+
if data[mark_pfx..p-1] != @prefix
|
477
|
+
closing = data[mark_pfx-1,1] == '/'
|
478
|
+
@nodes.last << data[mark_pfx-(closing ? 2 : 1)..p]
|
479
|
+
begin
|
480
|
+
p += 1
|
481
|
+
_trigger_goto = true
|
482
|
+
_goto_level = _out
|
483
|
+
break
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
487
|
+
end
|
488
|
+
when 2 then
|
489
|
+
# line 13 "scan.rl"
|
490
|
+
begin
|
491
|
+
mark_stg = p end
|
492
|
+
when 3 then
|
493
|
+
# line 14 "scan.rl"
|
494
|
+
begin
|
495
|
+
@starttag = data[mark_stg..p-1] end
|
496
|
+
when 4 then
|
497
|
+
# line 15 "scan.rl"
|
498
|
+
begin
|
499
|
+
mark_attr = p end
|
500
|
+
when 5 then
|
501
|
+
# line 16 "scan.rl"
|
502
|
+
begin
|
503
|
+
|
504
|
+
@attrs[@nat] = @vat
|
505
|
+
end
|
506
|
+
when 6 then
|
507
|
+
# line 25 "scan.rl"
|
508
|
+
begin
|
509
|
+
mark_nat = p end
|
510
|
+
when 7 then
|
511
|
+
# line 26 "scan.rl"
|
512
|
+
begin
|
513
|
+
@nat = data[mark_nat..p-1] end
|
514
|
+
when 8 then
|
515
|
+
# line 27 "scan.rl"
|
516
|
+
begin
|
517
|
+
mark_vat = p end
|
518
|
+
when 9 then
|
519
|
+
# line 28 "scan.rl"
|
520
|
+
begin
|
521
|
+
@vat = data[mark_vat..p-1] end
|
522
|
+
when 10 then
|
523
|
+
# line 30 "scan.rl"
|
524
|
+
begin
|
525
|
+
@flavor = :open end
|
526
|
+
when 11 then
|
527
|
+
# line 31 "scan.rl"
|
528
|
+
begin
|
529
|
+
@flavor = :self end
|
530
|
+
when 12 then
|
531
|
+
# line 32 "scan.rl"
|
532
|
+
begin
|
533
|
+
@flavor = :close end
|
534
|
+
when 15 then
|
535
|
+
# line 1 "NONE"
|
536
|
+
begin
|
537
|
+
te = p+1
|
538
|
+
end
|
539
|
+
when 16 then
|
540
|
+
# line 70 "scan.rl"
|
541
|
+
begin
|
542
|
+
act = 1; end
|
543
|
+
when 17 then
|
544
|
+
# line 79 "scan.rl"
|
545
|
+
begin
|
546
|
+
act = 2; end
|
547
|
+
when 18 then
|
548
|
+
# line 79 "scan.rl"
|
549
|
+
begin
|
550
|
+
te = p+1
|
551
|
+
begin
|
552
|
+
@nodes.last << data[p]
|
553
|
+
@tagstart = p
|
554
|
+
end
|
555
|
+
end
|
556
|
+
when 19 then
|
557
|
+
# line 70 "scan.rl"
|
558
|
+
begin
|
559
|
+
te = p
|
560
|
+
p = p - 1; begin
|
561
|
+
tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs}
|
562
|
+
@prefix = nil
|
563
|
+
@name = nil
|
564
|
+
@flavor = :tasteless
|
565
|
+
@attrs = {}
|
566
|
+
@nodes << tag << ''
|
567
|
+
begin
|
568
|
+
p += 1
|
569
|
+
_trigger_goto = true
|
570
|
+
_goto_level = _out
|
571
|
+
break
|
572
|
+
end
|
573
|
+
|
574
|
+
end
|
575
|
+
end
|
576
|
+
when 20 then
|
577
|
+
# line 79 "scan.rl"
|
578
|
+
begin
|
579
|
+
te = p
|
580
|
+
p = p - 1; begin
|
581
|
+
@nodes.last << data[p]
|
582
|
+
@tagstart = p
|
583
|
+
end
|
584
|
+
end
|
585
|
+
when 21 then
|
586
|
+
# line 79 "scan.rl"
|
587
|
+
begin
|
588
|
+
begin p = ((te))-1; end
|
589
|
+
begin
|
590
|
+
@nodes.last << data[p]
|
591
|
+
@tagstart = p
|
592
|
+
end
|
593
|
+
end
|
594
|
+
when 22 then
|
595
|
+
# line 1 "NONE"
|
596
|
+
begin
|
597
|
+
case act
|
598
|
+
when 1 then
|
599
|
+
begin begin p = ((te))-1; end
|
600
|
+
|
601
|
+
tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs}
|
602
|
+
@prefix = nil
|
603
|
+
@name = nil
|
604
|
+
@flavor = :tasteless
|
605
|
+
@attrs = {}
|
606
|
+
@nodes << tag << ''
|
607
|
+
begin
|
608
|
+
p += 1
|
609
|
+
_trigger_goto = true
|
610
|
+
_goto_level = _out
|
611
|
+
break
|
612
|
+
end
|
613
|
+
|
614
|
+
end
|
615
|
+
when 2 then
|
616
|
+
begin begin p = ((te))-1; end
|
617
|
+
|
618
|
+
@nodes.last << data[p]
|
619
|
+
@tagstart = p
|
620
|
+
end
|
621
|
+
end
|
622
|
+
end
|
623
|
+
# line 624 "scan.rb"
|
624
|
+
end # action switch
|
625
|
+
end
|
626
|
+
end
|
627
|
+
if _trigger_goto
|
628
|
+
next
|
629
|
+
end
|
630
|
+
end
|
631
|
+
if _goto_level <= _again
|
632
|
+
_acts = _parser_to_state_actions[cs]
|
633
|
+
_nacts = _parser_actions[_acts]
|
634
|
+
_acts += 1
|
635
|
+
while _nacts > 0
|
636
|
+
_nacts -= 1
|
637
|
+
_acts += 1
|
638
|
+
case _parser_actions[_acts - 1]
|
639
|
+
when 13 then
|
640
|
+
# line 1 "NONE"
|
641
|
+
begin
|
642
|
+
ts = nil; end
|
643
|
+
# line 644 "scan.rb"
|
644
|
+
end # to state action switch
|
645
|
+
end
|
646
|
+
if _trigger_goto
|
647
|
+
next
|
648
|
+
end
|
649
|
+
if cs == 0
|
650
|
+
_goto_level = _out
|
651
|
+
next
|
652
|
+
end
|
653
|
+
p += 1
|
654
|
+
if p != pe
|
655
|
+
_goto_level = _resume
|
656
|
+
next
|
657
|
+
end
|
658
|
+
end
|
659
|
+
if _goto_level <= _test_eof
|
660
|
+
if p == eof
|
661
|
+
if _parser_eof_trans[cs] > 0
|
662
|
+
_trans = _parser_eof_trans[cs] - 1;
|
663
|
+
_goto_level = _eof_trans
|
664
|
+
next;
|
665
|
+
end
|
666
|
+
end
|
667
|
+
end
|
668
|
+
if _goto_level <= _out
|
669
|
+
break
|
670
|
+
end
|
671
|
+
end
|
672
|
+
end
|
673
|
+
|
674
|
+
# line 121 "scan.rl"
|
675
|
+
return p
|
676
|
+
end
|
677
|
+
end
|
678
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
%%{
|
2
|
+
machine parser;
|
3
|
+
|
4
|
+
|
5
|
+
action _prefix { mark_pfx = p }
|
6
|
+
action prefix {
|
7
|
+
if data[mark_pfx..p-1] != @prefix
|
8
|
+
closing = data[mark_pfx-1,1] == '/'
|
9
|
+
@nodes.last << data[mark_pfx-(closing ? 2 : 1)..p]
|
10
|
+
fbreak;
|
11
|
+
end
|
12
|
+
}
|
13
|
+
action _starttag { mark_stg = p }
|
14
|
+
action starttag { @starttag = data[mark_stg..p-1] }
|
15
|
+
action _attr { mark_attr = p }
|
16
|
+
action attr {
|
17
|
+
@attrs[@nat] = @vat
|
18
|
+
}
|
19
|
+
|
20
|
+
action prematch {
|
21
|
+
@prematch_end = p
|
22
|
+
@prematch = data[0..p] if p > 0
|
23
|
+
}
|
24
|
+
|
25
|
+
action _nameattr { mark_nat = p }
|
26
|
+
action nameattr { @nat = data[mark_nat..p-1] }
|
27
|
+
action _valattr { mark_vat = p }
|
28
|
+
action valattr { @vat = data[mark_vat..p-1] }
|
29
|
+
|
30
|
+
action opentag { @flavor = :open }
|
31
|
+
action selftag { @flavor = :self }
|
32
|
+
action closetag { @flavor = :close }
|
33
|
+
|
34
|
+
action stopparse {
|
35
|
+
@cursor = p;
|
36
|
+
fbreak;
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
Closeout := empty;
|
41
|
+
|
42
|
+
# words
|
43
|
+
PrefixChar = [\-A-Za-z0-9._?] ;
|
44
|
+
NameChar = [\-A-Za-z0-9._:?] ;
|
45
|
+
TagName = NameChar+ >_starttag %starttag;
|
46
|
+
Prefix = PrefixChar+ >_prefix %prefix;
|
47
|
+
|
48
|
+
Name = Prefix ":" TagName;
|
49
|
+
|
50
|
+
NameAttr = NameChar+ >_nameattr %nameattr;
|
51
|
+
Q1Char = ( "\\\'" | [^'] ) ;
|
52
|
+
Q1Attr = Q1Char* >_valattr %valattr;
|
53
|
+
Q2Char = ( "\\\"" | [^"] ) ;
|
54
|
+
Q2Attr = Q2Char* >_valattr %valattr;
|
55
|
+
|
56
|
+
Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'") space* >_attr %attr;
|
57
|
+
Attrs = (space+ Attr* | empty);
|
58
|
+
|
59
|
+
CloseTrailer = "/>" %selftag;
|
60
|
+
OpenTrailer = ">" %opentag;
|
61
|
+
|
62
|
+
Trailer = (OpenTrailer | CloseTrailer);
|
63
|
+
|
64
|
+
OpenOrSelfTag = Name Attrs? Trailer;
|
65
|
+
CloseTag = "/" Name space* ">" %closetag;
|
66
|
+
|
67
|
+
SomeTag = '<' (OpenOrSelfTag | CloseTag);
|
68
|
+
|
69
|
+
main := |*
|
70
|
+
SomeTag => {
|
71
|
+
tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs}
|
72
|
+
@prefix = nil
|
73
|
+
@name = nil
|
74
|
+
@flavor = :tasteless
|
75
|
+
@attrs = {}
|
76
|
+
@nodes << tag << ''
|
77
|
+
fbreak;
|
78
|
+
};
|
79
|
+
any => {
|
80
|
+
@nodes.last << data[p]
|
81
|
+
@tagstart = p
|
82
|
+
};
|
83
|
+
*|;
|
84
|
+
}%%
|
85
|
+
|
86
|
+
module Radius
|
87
|
+
class Scanner
|
88
|
+
def self.operate(prefix, data)
|
89
|
+
buf = ""
|
90
|
+
csel = ""
|
91
|
+
@prematch = ''
|
92
|
+
@starttag = nil
|
93
|
+
@attrs = {}
|
94
|
+
@flavor = :tasteless
|
95
|
+
@cursor = 0
|
96
|
+
@tagstart = 0
|
97
|
+
@nodes = ['']
|
98
|
+
remainder = data.dup
|
99
|
+
|
100
|
+
until remainder.length == 0
|
101
|
+
p = perform_parse(prefix, remainder)
|
102
|
+
remainder = remainder[p..-1]
|
103
|
+
end
|
104
|
+
|
105
|
+
return @nodes
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
def self.perform_parse(prefix, data)
|
110
|
+
stack = []
|
111
|
+
p = 0
|
112
|
+
ts = 0
|
113
|
+
te = 0
|
114
|
+
act = 0
|
115
|
+
eof = data.length
|
116
|
+
|
117
|
+
@prefix = prefix
|
118
|
+
%% write data;
|
119
|
+
%% write init;
|
120
|
+
%% write exec;
|
121
|
+
return p
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ParseTag # :nodoc:
|
2
|
+
def initialize(&b)
|
3
|
+
@block = b
|
4
|
+
end
|
5
|
+
|
6
|
+
def on_parse(&b)
|
7
|
+
@block = b
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
@block.call(self)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class ParseContainerTag < ParseTag # :nodoc:
|
16
|
+
attr_accessor :name, :attributes, :contents
|
17
|
+
|
18
|
+
def initialize(name = "", attributes = {}, contents = [], &b)
|
19
|
+
@name, @attributes, @contents = name, attributes, contents
|
20
|
+
super(&b)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Radius
|
2
|
+
#
|
3
|
+
# A tag binding is passed into each tag definition and contains helper methods for working
|
4
|
+
# with tags. Use it to gain access to the attributes that were passed to the tag, to
|
5
|
+
# render the tag contents, and to do other tasks.
|
6
|
+
#
|
7
|
+
class TagBinding
|
8
|
+
# The Context that the TagBinding is associated with. Used internally. Try not to use
|
9
|
+
# this object directly.
|
10
|
+
attr_reader :context
|
11
|
+
|
12
|
+
# The locals object for the current tag.
|
13
|
+
attr_reader :locals
|
14
|
+
|
15
|
+
# The name of the tag (as used in a template string).
|
16
|
+
attr_reader :name
|
17
|
+
|
18
|
+
# The attributes of the tag. Also aliased as TagBinding#attr.
|
19
|
+
attr_reader :attributes
|
20
|
+
alias :attr :attributes
|
21
|
+
|
22
|
+
# The render block. When called expands the contents of the tag. Use TagBinding#expand
|
23
|
+
# instead.
|
24
|
+
attr_reader :block
|
25
|
+
|
26
|
+
# Creates a new TagBinding object.
|
27
|
+
def initialize(context, locals, name, attributes, block)
|
28
|
+
@context, @locals, @name, @attributes, @block = context, locals, name, attributes, block
|
29
|
+
end
|
30
|
+
|
31
|
+
# Evaluates the current tag and returns the rendered contents.
|
32
|
+
def expand
|
33
|
+
double? ? block.call : ''
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true if the current tag is a single tag.
|
37
|
+
def single?
|
38
|
+
block.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns true if the current tag is a container tag.
|
42
|
+
def double?
|
43
|
+
not single?
|
44
|
+
end
|
45
|
+
|
46
|
+
# The globals object from which all locals objects ultimately inherit their values.
|
47
|
+
def globals
|
48
|
+
@context.globals
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns a list of the way tags are nested around the current tag as a string.
|
52
|
+
def nesting
|
53
|
+
@context.current_nesting
|
54
|
+
end
|
55
|
+
|
56
|
+
# Fires off Context#tag_missing for the current tag.
|
57
|
+
def missing!
|
58
|
+
@context.tag_missing(name, attributes, &block)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Renders the tag using the current context .
|
62
|
+
def render(tag, attributes = {}, &block)
|
63
|
+
@context.render_tag(tag, attributes, &block)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Radius
|
2
|
+
module TagDefinitions # :nodoc:
|
3
|
+
class TagFactory # :nodoc:
|
4
|
+
def initialize(context)
|
5
|
+
@context = context
|
6
|
+
end
|
7
|
+
|
8
|
+
def define_tag(name, options, &block)
|
9
|
+
options = prepare_options(name, options)
|
10
|
+
validate_params(name, options, &block)
|
11
|
+
construct_tag_set(name, options, &block)
|
12
|
+
expose_methods_as_tags(name, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Normalizes options pased to tag definition. Override in decendants to preform
|
18
|
+
# additional normalization.
|
19
|
+
def prepare_options(name, options)
|
20
|
+
options = Util.symbolize_keys(options)
|
21
|
+
options[:expose] = expand_array_option(options[:expose])
|
22
|
+
object = options[:for]
|
23
|
+
options[:attributes] = object.respond_to?(:attributes) unless options.has_key? :attributes
|
24
|
+
options[:expose] += object.attributes.keys if options[:attributes]
|
25
|
+
options
|
26
|
+
end
|
27
|
+
|
28
|
+
# Validates parameters passed to tag definition. Override in decendants to add custom
|
29
|
+
# validations.
|
30
|
+
def validate_params(name, options, &block)
|
31
|
+
unless options.has_key? :for
|
32
|
+
raise ArgumentError.new("tag definition must contain a :for option or a block") unless block
|
33
|
+
raise ArgumentError.new("tag definition must contain a :for option when used with the :expose option") unless options[:expose].empty?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Adds the tag definition to the context. Override in subclasses to add additional tags
|
38
|
+
# (child tags) when the tag is created.
|
39
|
+
def construct_tag_set(name, options, &block)
|
40
|
+
if block
|
41
|
+
@context.definitions[name.to_s] = block
|
42
|
+
else
|
43
|
+
lp = last_part(name)
|
44
|
+
@context.define_tag(name) do |tag|
|
45
|
+
if tag.single?
|
46
|
+
options[:for]
|
47
|
+
else
|
48
|
+
tag.locals.send("#{ lp }=", options[:for]) unless options[:for].nil?
|
49
|
+
tag.expand
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Exposes the methods of an object as child tags.
|
56
|
+
def expose_methods_as_tags(name, options)
|
57
|
+
options[:expose].each do |method|
|
58
|
+
tag_name = "#{name}:#{method}"
|
59
|
+
lp = last_part(name)
|
60
|
+
@context.define_tag(tag_name) do |tag|
|
61
|
+
object = tag.locals.send(lp)
|
62
|
+
object.send(method)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def expand_array_option(value)
|
70
|
+
[*value].compact.map { |m| m.to_s.intern }
|
71
|
+
end
|
72
|
+
|
73
|
+
def last_part(name)
|
74
|
+
name.split(':').last
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Radius
|
2
|
+
module Util # :nodoc:
|
3
|
+
def self.symbolize_keys(hash)
|
4
|
+
new_hash = {}
|
5
|
+
hash.keys.each do |k|
|
6
|
+
new_hash[k.to_s.intern] = hash[k]
|
7
|
+
end
|
8
|
+
new_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.impartial_hash_delete(hash, key)
|
12
|
+
string = key.to_s
|
13
|
+
symbol = string.intern
|
14
|
+
value1 = hash.delete(symbol)
|
15
|
+
value2 = hash.delete(string)
|
16
|
+
value1 || value2
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.constantize(camelized_string)
|
20
|
+
raise "invalid constant name `#{camelized_string}'" unless camelized_string.split('::').all? { |part| part =~ /^[A-Za-z]+$/ }
|
21
|
+
Object.module_eval(camelized_string)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.camelize(underscored_string)
|
25
|
+
string = ''
|
26
|
+
underscored_string.split('_').each { |part| string << part.capitalize }
|
27
|
+
string
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.recurring_array_to_s(ary)
|
31
|
+
ary.map{|x| x.is_a?(Array) ? recurring_array_to_s(x) : x.to_s }.join
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 9
|
9
|
+
version: 0.1.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- davide-malagoli
|
@@ -2403,6 +2403,16 @@ files:
|
|
2403
2403
|
- vendor/radius/ROADMAP
|
2404
2404
|
- vendor/radius/CHANGELOG
|
2405
2405
|
- vendor/radius/lib/radius19.rb
|
2406
|
+
- vendor/radius/lib/radius/errors.rb
|
2407
|
+
- vendor/radius/lib/radius/context.rb
|
2408
|
+
- vendor/radius/lib/radius/dostruct.rb
|
2409
|
+
- vendor/radius/lib/radius/parser.rb
|
2410
|
+
- vendor/radius/lib/radius/parsetag.rb
|
2411
|
+
- vendor/radius/lib/radius/tagbinding.rb
|
2412
|
+
- vendor/radius/lib/radius/tagdefs.rb
|
2413
|
+
- vendor/radius/lib/radius/util.rb
|
2414
|
+
- vendor/radius/lib/radius/parser/scan.rb
|
2415
|
+
- vendor/radius/lib/radius/parser/scan.rl
|
2406
2416
|
- vendor/radius/README
|
2407
2417
|
- vendor/radius/test/context_test.rb
|
2408
2418
|
- vendor/radius/test/dostruct_test.rb
|