radius-ts 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,28 +1,33 @@
1
1
  = Change Log
2
- === 1.1.0-ts
2
+
3
+ == -ts fork
4
+ * JavaScanner, much faster when using JRuby
5
+ * apply patches from jlong/radius upstream (detailed below)
6
+
7
+ == edge
8
+ * Support for Rubinius [jlong]
9
+ * Support for Ruby 1.9 [aemadrid]
10
+ * More tests [aemadrid]
11
+ * Fixed issue #5 - problem with other namespace tags [jemmyw]
12
+ * Switched to Jeweler for better gem management [jlong]
13
+ * Allow operation in a threaded environment (parser per-thread, shared context)
3
14
  * Allow switching scanners that tokenize templates.
4
15
  * Include SquiggleScanner to parse tags that look like "{ hello /}"
5
16
 
6
- === 1.0.0-ts
7
- * Create a fork that is threadsafe (per-parser).
8
- * Bump revision to 1.0.0 since the API is stable
9
-
10
- === 0.6.1
11
- * Fixed a problem with non-tags that have no prefix or tagname (see test_parse_chirpy_bird)
17
+ == 0.6.1
18
+ * Fixed a problem with non-tags that have no prefix or tag name (see test_parse_chirpy_bird)
12
19
 
13
- === 0.6.0 (private release)
20
+ == 0.6.0 (private release)
14
21
  * Split radius.rb into multiple files.
15
- * Port the really hairy regexes from Radius::Parser to a single Ragel machine.
22
+ * Ported the really hairy regexes from Radius::Parser to a single Ragel machine.
16
23
  * Added and refactored tests.
17
24
  * Refactored Rakefile and other administrativia.
18
25
 
19
- === 0.5.1
20
- * Fixed a problem with parsing quotes where a single tag preceding a double tag would consume the start
21
- tag of the double tag if both contained attributes.
26
+ == 0.5.1
27
+ * Fixed a problem with parsing quotes where a single tag preceding a double tag would consume the start tag of the double tag if both contained attributes.
22
28
 
23
- === 0.5.0
24
- * Created a DSL for tag definitions (introducing a DSL makes this version of Radiant incompatible with
25
- the last). The DSL has the following features:
29
+ == 0.5.0
30
+ * Created a DSL for tag definitions (introducing a DSL makes this version of Radiant incompatible with the last). The DSL has the following features:
26
31
  - full support for nested tags
27
32
  - global and local tag variables
28
33
  - Contexts can now be defined dynamically (instead of being subclassed)
@@ -32,10 +37,10 @@
32
37
  * Updated documentation to reflect the changes.
33
38
  * Updated the version number to reflect the maturity of the code base.
34
39
 
35
- === 0.0.2
40
+ == 0.0.2
36
41
  * Refactored Parser to use Context#render_tag instead of #send when rendering tags defined on a Context.
37
42
  * UndefinedTagError is now thrown when Parser tries to render a tag which doesn't exist on a Context.
38
43
  * Added Context#tag_missing which works like method_method missing on Object, but is tag specific.
39
44
 
40
- === 0.0.1
45
+ == 0.0.1
41
46
  * First release.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2006-2010, John W. Long
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.rdoc CHANGED
@@ -1,9 +1,10 @@
1
1
  = Radius -- Powerful Tag-Based Templates
2
2
 
3
- Radius is a powerful tag-based template language for Ruby inspired by the template languages
4
- used in MovableType[http://www.movabletype.org] and TextPattern[http://www.textpattern.com].
5
- It uses tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail,
6
- etc...).
3
+ Radius is a powerful tag-based template language for Ruby inspired by the
4
+ template languages used in MovableType[http://www.movabletype.org] and
5
+ TextPattern[http://www.textpattern.com]. It uses tags similar to XML, but can
6
+ be used to generate any form of plain text (HTML, e-mail, etc...).
7
+
7
8
 
8
9
  == Usage
9
10
 
@@ -60,30 +61,11 @@ It is recommended that you install Radius using the RubyGems packaging system:
60
61
 
61
62
  % gem install --remote radius
62
63
 
63
- You can also install Radius by copying lib/radius.rb into the Ruby load path.
64
-
65
64
 
66
65
  == License
67
66
 
68
- Radius is free software and may be redistributed under the terms of the MIT-LICENSE:
69
-
70
- Copyright (c) 2006-2009, John W. Long
71
-
72
- Permission is hereby granted, free of charge, to any person obtaining a copy of this
73
- software and associated documentation files (the "Software"), to deal in the Software
74
- without restriction, including without limitation the rights to use, copy, modify, merge,
75
- publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
76
- to whom the Software is furnished to do so, subject to the following conditions:
77
-
78
- The above copyright notice and this permission notice shall be included in all copies or
79
- substantial portions of the Software.
80
-
81
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
82
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
83
- PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
84
- FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
85
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
86
- DEALINGS IN THE SOFTWARE.
67
+ Radius is released under the MIT license and is copyright (c) 2006-2010
68
+ John W. Long. A copy of the MIT license can be found in the LICENSE file.
87
69
 
88
70
 
89
71
  == Roadmap
data/Rakefile CHANGED
@@ -1,34 +1,8 @@
1
- %w(rubygems rake rake/clean fileutils newgem rubigen hoe).each { |f| require f }
2
-
3
- require 'lib/radius/version'
4
-
5
- # Generate all the Rake tasks
6
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
- Hoe.spec 'radius-ts' do |p|
8
- p.version = Radius::Version.to_s
9
- p.url = "http://github.com/xtoddx/radius-ts"
10
- p.developer('Todd Willey', 'todd@rubidine.com')
11
- p.author = [
12
- "John W. Long (me@johnwlong.com)",
13
- "David Chelimsky (dchelimsky@gmail.com)",
14
- "Bryce Kerley (bkerley@brycekerley.net)",
15
- "Todd Willey (todd@rubidine.com)"
16
- ]
17
- p.changes = p.paragraphs_of("CHANGELOG", 1..2).join("\n\n")
18
- p.rubyforge_name = p.name
19
- p.extra_dev_deps = [
20
- ['newgem', ">= #{::Newgem::VERSION}"]
21
- ]
22
- p.readme_file = 'README.rdoc'
23
- p.extra_rdoc_files |= %w(README.rdoc QUICKSTART.rdoc)
24
- p.clean_globs |= %w(**/.DS_Store tmp *.log) # Remove these files on "rake clean"
25
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
26
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
27
- p.rsync_args = '-av --delete --ignore-errors'
28
- p.test_globs = "test/**/*_test.rb"
29
- p.summary = "Radius templating language with thread safety patches."
30
- p.description = "A templating lanuage based on MovableType and TextPattern. Originally implemented by John Long."
31
- end
32
-
33
- require 'newgem/tasks' # load /tasks/*.rake
34
- Dir['tasks/**/*.rake'].each { |t| load t }
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ require File.dirname(__FILE__) + '/lib/radius/version'
5
+
6
+ Dir['tasks/**/*.rake'].each { |t| load t }
7
+
8
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0
data/lib/radius/parser.rb CHANGED
@@ -7,7 +7,7 @@ module Radius
7
7
  class Parser
8
8
  # The Context object used to expand template tags.
9
9
  attr_accessor :context
10
-
10
+
11
11
  # The string that prefixes all tags that are expanded by a parser
12
12
  # (the part in the tag name before the first colon).
13
13
  attr_accessor :tag_prefix
@@ -23,17 +23,17 @@ module Radius
23
23
  options = Utility.symbolize_keys(options)
24
24
  self.context = context ? context.dup : Context.new
25
25
  self.tag_prefix = options[:tag_prefix] || 'radius'
26
- self.scanner = options[:scanner] || Radius::Scanner.new
26
+ self.scanner = options[:scanner] || default_scanner
27
27
  end
28
-
28
+
29
29
  # Parses string for tags, expands them, and returns the result.
30
30
  def parse(string)
31
- @stack = [ParseContainerTag.new { |t| t.contents.to_s }]
31
+ @stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ]
32
32
  tokenize(string)
33
33
  stack_up
34
34
  @stack.last.to_s
35
35
  end
36
-
36
+
37
37
  protected
38
38
  # Convert the string into a list of text blocks and scanners (tokens)
39
39
  def tokenize(string)
@@ -54,7 +54,7 @@ module Radius
54
54
  when :close
55
55
  popped = @stack.pop
56
56
  raise WrongEndTagError.new(popped.name, t[:name], @stack) if popped.name != t[:name]
57
- popped.on_parse { |b| @context.render_tag(popped.name, popped.attributes) { b.contents.to_s } }
57
+ popped.on_parse { |b| @context.render_tag(popped.name, popped.attributes) { Utility.array_to_s(b.contents) } }
58
58
  @stack.last.contents << popped
59
59
  when :tasteless
60
60
  raise TastelessTagError.new(t, @stack)
@@ -64,5 +64,16 @@ module Radius
64
64
  end
65
65
  raise MissingEndTagError.new(@stack.last.name, @stack) if @stack.length != 1
66
66
  end
67
+
68
+ def default_scanner
69
+ if RUBY_PLATFORM == 'java'
70
+ require 'java'
71
+ require 'radius/parser/java_scanner.jar'
72
+ ::Radius.send(:include_package, 'radius.parser')
73
+ Radius::JavaScanner.new(JRuby.runtime)
74
+ else
75
+ Radius::Scanner.new
76
+ end
77
+ end
67
78
  end
68
79
  end
Binary file
@@ -0,0 +1,634 @@
1
+
2
+ // line 1 "JavaScanner.rl"
3
+
4
+ // line 84 "JavaScanner.rl"
5
+
6
+
7
+ package radius.parser;
8
+
9
+ import java.util.HashMap;
10
+ import java.util.LinkedList;
11
+ import org.jruby.Ruby; // runtime
12
+ import org.jruby.RubyObject;
13
+ import org.jruby.runtime.builtin.IRubyObject;
14
+ import org.jruby.RubyArray;
15
+ import org.jruby.RubyString;
16
+ import org.jruby.RubyHash;
17
+ import org.jruby.RubySymbol;
18
+
19
+ public class JavaScanner {
20
+
21
+ Ruby runtime = null;
22
+ RubyArray rv = null;
23
+
24
+ void pass_through(String str) {
25
+ RubyObject last = ((RubyObject)rv.last());
26
+ if ( rv.size() > 0 && last != null && (last instanceof RubyString) ){
27
+ // XXX concat changes for ruby 1.9
28
+ ((RubyString) last).concat(RubyString.newString(runtime, str));
29
+ } else {
30
+ rv.append(RubyString.newString(runtime, str));
31
+ }
32
+ }
33
+
34
+ void tag(String prefix, String name, RubyHash attr, RubySymbol flavor) {
35
+ RubyHash tag = RubyHash.newHash(runtime);
36
+ tag.op_aset(
37
+ runtime.getCurrentContext(),
38
+ RubySymbol.newSymbol(runtime, "prefix"),
39
+ RubyString.newString(runtime, prefix)
40
+ );
41
+ tag.op_aset(
42
+ runtime.getCurrentContext(),
43
+ RubySymbol.newSymbol(runtime, "name"),
44
+ RubyString.newString(runtime, name)
45
+ );
46
+ tag.op_aset(
47
+ runtime.getCurrentContext(),
48
+ RubySymbol.newSymbol(runtime, "attrs"),
49
+ attr
50
+ );
51
+ tag.op_aset(
52
+ runtime.getCurrentContext(),
53
+ RubySymbol.newSymbol(runtime, "flavor"),
54
+ flavor
55
+ );
56
+ rv.append(tag);
57
+ }
58
+
59
+ public JavaScanner(Ruby runtime) {
60
+ this.runtime = runtime;
61
+ }
62
+
63
+
64
+ // line 65 "JavaScanner.java"
65
+ private static byte[] init__parser_actions_0()
66
+ {
67
+ return new byte [] {
68
+ 0, 1, 0, 1, 3, 1, 4, 1, 5, 1, 6, 1,
69
+ 7, 1, 8, 1, 9, 1, 10, 1, 14, 1, 15, 1,
70
+ 19, 1, 21, 1, 22, 1, 23, 2, 1, 2, 2, 5,
71
+ 6, 2, 6, 7, 2, 9, 5, 2, 9, 10, 2, 10,
72
+ 9, 2, 11, 20, 2, 12, 20, 2, 13, 20, 2, 16,
73
+ 17, 2, 16, 18, 3, 5, 6, 7, 3, 9, 5, 6,
74
+ 3, 16, 6, 17, 4, 9, 5, 6, 7, 4, 16, 5,
75
+ 6, 17, 5, 16, 9, 5, 6, 17
76
+ };
77
+ }
78
+
79
+ private static final byte _parser_actions[] = init__parser_actions_0();
80
+
81
+
82
+ private static short[] init__parser_key_offsets_0()
83
+ {
84
+ return new short [] {
85
+ 0, 0, 11, 21, 34, 47, 61, 65, 70, 72, 74, 87,
86
+ 100, 101, 103, 118, 133, 149, 155, 161, 176, 179, 182, 185,
87
+ 200, 202, 204, 219, 235, 241, 247, 250, 253, 269, 285, 302,
88
+ 309, 315, 331, 335, 351, 366, 369, 371, 381, 392, 402, 416,
89
+ 420, 420, 421, 430, 430, 430, 432, 434, 437, 440, 442, 444
90
+ };
91
+ }
92
+
93
+ private static final short _parser_key_offsets[] = init__parser_key_offsets_0();
94
+
95
+
96
+ private static char[] init__parser_trans_keys_0()
97
+ {
98
+ return new char [] {
99
+ 58, 63, 95, 45, 46, 48, 57, 65, 90, 97, 122, 63,
100
+ 95, 45, 46, 48, 58, 65, 90, 97, 122, 32, 47, 62,
101
+ 63, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 47,
102
+ 62, 63, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32,
103
+ 61, 63, 95, 9, 13, 45, 46, 48, 58, 65, 90, 97,
104
+ 122, 32, 61, 9, 13, 32, 34, 39, 9, 13, 34, 92,
105
+ 34, 92, 32, 47, 62, 63, 95, 9, 13, 45, 58, 65,
106
+ 90, 97, 122, 32, 47, 62, 63, 95, 9, 13, 45, 58,
107
+ 65, 90, 97, 122, 62, 34, 92, 32, 34, 47, 62, 63,
108
+ 92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 34,
109
+ 47, 62, 63, 92, 95, 9, 13, 45, 58, 65, 90, 97,
110
+ 122, 32, 34, 61, 63, 92, 95, 9, 13, 45, 46, 48,
111
+ 58, 65, 90, 97, 122, 32, 34, 61, 92, 9, 13, 32,
112
+ 34, 39, 92, 9, 13, 32, 34, 47, 62, 63, 92, 95,
113
+ 9, 13, 45, 58, 65, 90, 97, 122, 34, 62, 92, 34,
114
+ 39, 92, 34, 39, 92, 32, 39, 47, 62, 63, 92, 95,
115
+ 9, 13, 45, 58, 65, 90, 97, 122, 39, 92, 39, 92,
116
+ 32, 39, 47, 62, 63, 92, 95, 9, 13, 45, 58, 65,
117
+ 90, 97, 122, 32, 39, 61, 63, 92, 95, 9, 13, 45,
118
+ 46, 48, 58, 65, 90, 97, 122, 32, 39, 61, 92, 9,
119
+ 13, 32, 34, 39, 92, 9, 13, 34, 39, 92, 34, 39,
120
+ 92, 32, 34, 39, 47, 62, 63, 92, 95, 9, 13, 45,
121
+ 58, 65, 90, 97, 122, 32, 34, 39, 47, 62, 63, 92,
122
+ 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 34, 39,
123
+ 61, 63, 92, 95, 9, 13, 45, 46, 48, 58, 65, 90,
124
+ 97, 122, 32, 34, 39, 61, 92, 9, 13, 32, 34, 39,
125
+ 92, 9, 13, 32, 34, 39, 47, 62, 63, 92, 95, 9,
126
+ 13, 45, 58, 65, 90, 97, 122, 34, 39, 62, 92, 32,
127
+ 34, 39, 47, 62, 63, 92, 95, 9, 13, 45, 58, 65,
128
+ 90, 97, 122, 32, 39, 47, 62, 63, 92, 95, 9, 13,
129
+ 45, 58, 65, 90, 97, 122, 39, 62, 92, 39, 92, 63,
130
+ 95, 45, 46, 48, 57, 65, 90, 97, 122, 58, 63, 95,
131
+ 45, 46, 48, 57, 65, 90, 97, 122, 63, 95, 45, 46,
132
+ 48, 58, 65, 90, 97, 122, 32, 62, 63, 95, 9, 13,
133
+ 45, 46, 48, 58, 65, 90, 97, 122, 32, 62, 9, 13,
134
+ 60, 47, 63, 95, 45, 57, 65, 90, 97, 122, 34, 92,
135
+ 34, 92, 34, 39, 92, 34, 39, 92, 39, 92, 39, 92,
136
+ 0
137
+ };
138
+ }
139
+
140
+ private static final char _parser_trans_keys[] = init__parser_trans_keys_0();
141
+
142
+
143
+ private static byte[] init__parser_single_lengths_0()
144
+ {
145
+ return new byte [] {
146
+ 0, 3, 2, 5, 5, 4, 2, 3, 2, 2, 5, 5,
147
+ 1, 2, 7, 7, 6, 4, 4, 7, 3, 3, 3, 7,
148
+ 2, 2, 7, 6, 4, 4, 3, 3, 8, 8, 7, 5,
149
+ 4, 8, 4, 8, 7, 3, 2, 2, 3, 2, 4, 2,
150
+ 0, 1, 3, 0, 0, 2, 2, 3, 3, 2, 2, 0
151
+ };
152
+ }
153
+
154
+ private static final byte _parser_single_lengths[] = init__parser_single_lengths_0();
155
+
156
+
157
+ private static byte[] init__parser_range_lengths_0()
158
+ {
159
+ return new byte [] {
160
+ 0, 4, 4, 4, 4, 5, 1, 1, 0, 0, 4, 4,
161
+ 0, 0, 4, 4, 5, 1, 1, 4, 0, 0, 0, 4,
162
+ 0, 0, 4, 5, 1, 1, 0, 0, 4, 4, 5, 1,
163
+ 1, 4, 0, 4, 4, 0, 0, 4, 4, 4, 5, 1,
164
+ 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0
165
+ };
166
+ }
167
+
168
+ private static final byte _parser_range_lengths[] = init__parser_range_lengths_0();
169
+
170
+
171
+ private static short[] init__parser_index_offsets_0()
172
+ {
173
+ return new short [] {
174
+ 0, 0, 8, 15, 25, 35, 45, 49, 54, 57, 60, 70,
175
+ 80, 82, 85, 97, 109, 121, 127, 133, 145, 149, 153, 157,
176
+ 169, 172, 175, 187, 199, 205, 211, 215, 219, 232, 245, 258,
177
+ 265, 271, 284, 289, 302, 314, 318, 321, 328, 336, 343, 353,
178
+ 357, 358, 360, 367, 368, 369, 372, 375, 379, 383, 386, 389
179
+ };
180
+ }
181
+
182
+ private static final short _parser_index_offsets[] = init__parser_index_offsets_0();
183
+
184
+
185
+ private static byte[] init__parser_indicies_0()
186
+ {
187
+ return new byte [] {
188
+ 2, 1, 1, 1, 1, 1, 1, 0, 3, 3, 3, 3,
189
+ 3, 3, 0, 4, 6, 7, 5, 5, 4, 5, 5, 5,
190
+ 0, 8, 10, 11, 9, 9, 8, 9, 9, 9, 0, 13,
191
+ 15, 14, 14, 13, 14, 14, 14, 14, 12, 16, 17, 16,
192
+ 12, 17, 18, 19, 17, 12, 21, 22, 20, 24, 25, 23,
193
+ 26, 28, 29, 27, 27, 26, 27, 27, 27, 12, 30, 32,
194
+ 33, 31, 31, 30, 31, 31, 31, 12, 34, 12, 35, 25,
195
+ 23, 36, 24, 38, 39, 37, 25, 37, 36, 37, 37, 37,
196
+ 23, 40, 24, 42, 43, 41, 25, 41, 40, 41, 41, 41,
197
+ 23, 44, 24, 46, 45, 25, 45, 44, 45, 45, 45, 45,
198
+ 23, 47, 24, 48, 25, 47, 23, 48, 49, 50, 25, 48,
199
+ 23, 51, 21, 53, 54, 52, 22, 52, 51, 52, 52, 52,
200
+ 20, 24, 55, 25, 23, 57, 58, 59, 56, 61, 35, 62,
201
+ 60, 64, 24, 66, 67, 65, 68, 65, 64, 65, 65, 65,
202
+ 63, 24, 68, 63, 61, 68, 63, 69, 24, 71, 72, 70,
203
+ 68, 70, 69, 70, 70, 70, 63, 73, 24, 75, 74, 68,
204
+ 74, 73, 74, 74, 74, 74, 63, 76, 24, 77, 68, 76,
205
+ 63, 77, 78, 79, 68, 77, 63, 80, 58, 59, 56, 81,
206
+ 81, 62, 60, 82, 61, 35, 84, 85, 83, 62, 83, 82,
207
+ 83, 83, 83, 60, 86, 61, 35, 88, 89, 87, 62, 87,
208
+ 86, 87, 87, 87, 60, 90, 61, 35, 92, 91, 62, 91,
209
+ 90, 91, 91, 91, 91, 60, 93, 61, 35, 94, 62, 93,
210
+ 60, 94, 95, 96, 62, 94, 60, 97, 80, 58, 99, 100,
211
+ 98, 59, 98, 97, 98, 98, 98, 56, 61, 35, 101, 62,
212
+ 60, 97, 57, 58, 99, 100, 98, 59, 98, 97, 98, 98,
213
+ 98, 56, 103, 21, 105, 106, 104, 107, 104, 103, 104, 104,
214
+ 104, 102, 24, 108, 68, 63, 21, 107, 102, 109, 109, 109,
215
+ 109, 109, 109, 0, 111, 110, 110, 110, 110, 110, 110, 0,
216
+ 112, 112, 112, 112, 112, 112, 0, 113, 115, 114, 114, 113,
217
+ 114, 114, 114, 114, 0, 116, 117, 116, 0, 118, 120, 119,
218
+ 123, 122, 122, 122, 122, 122, 121, 124, 125, 24, 25, 23,
219
+ 24, 25, 23, 61, 35, 62, 60, 61, 35, 62, 60, 24,
220
+ 68, 63, 24, 68, 63, 126, 0
221
+ };
222
+ }
223
+
224
+ private static final byte _parser_indicies[] = init__parser_indicies_0();
225
+
226
+
227
+ private static byte[] init__parser_trans_targs_0()
228
+ {
229
+ return new byte [] {
230
+ 49, 1, 2, 3, 4, 3, 12, 52, 4, 5, 12, 52,
231
+ 49, 6, 5, 7, 6, 7, 8, 42, 9, 10, 13, 9,
232
+ 10, 13, 11, 5, 12, 52, 11, 5, 12, 52, 51, 14,
233
+ 15, 16, 20, 54, 15, 16, 20, 54, 17, 16, 18, 17,
234
+ 18, 19, 21, 15, 16, 20, 54, 53, 22, 23, 14, 31,
235
+ 22, 23, 31, 24, 26, 27, 41, 58, 25, 26, 27, 41,
236
+ 58, 28, 27, 29, 28, 29, 30, 40, 23, 32, 33, 34,
237
+ 38, 56, 33, 34, 38, 56, 35, 34, 36, 35, 36, 37,
238
+ 39, 33, 34, 38, 56, 55, 24, 26, 27, 41, 58, 25,
239
+ 57, 44, 44, 45, 46, 47, 46, 59, 47, 59, 0, 49,
240
+ 50, 49, 1, 43, 49, 49, 49
241
+ };
242
+ }
243
+
244
+ private static final byte _parser_trans_targs[] = init__parser_trans_targs_0();
245
+
246
+
247
+ private static byte[] init__parser_trans_actions_0()
248
+ {
249
+ return new byte [] {
250
+ 27, 0, 31, 3, 5, 0, 5, 5, 0, 11, 0, 0,
251
+ 29, 13, 0, 13, 0, 0, 0, 0, 15, 43, 15, 0,
252
+ 17, 0, 7, 64, 34, 34, 0, 37, 9, 9, 0, 17,
253
+ 7, 64, 34, 81, 0, 37, 9, 72, 13, 0, 13, 0,
254
+ 0, 17, 0, 40, 76, 68, 86, 58, 15, 46, 43, 15,
255
+ 0, 17, 0, 0, 7, 64, 34, 81, 0, 0, 37, 9,
256
+ 72, 13, 0, 13, 0, 0, 0, 17, 43, 17, 7, 64,
257
+ 34, 81, 0, 37, 9, 72, 13, 0, 13, 0, 0, 17,
258
+ 17, 40, 76, 68, 86, 58, 15, 40, 76, 68, 86, 15,
259
+ 58, 1, 0, 31, 3, 5, 0, 5, 0, 0, 0, 23,
260
+ 61, 25, 1, 0, 52, 49, 55
261
+ };
262
+ }
263
+
264
+ private static final byte _parser_trans_actions[] = init__parser_trans_actions_0();
265
+
266
+
267
+ private static byte[] init__parser_to_state_actions_0()
268
+ {
269
+ return new byte [] {
270
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
272
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
273
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
274
+ 19, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
275
+ };
276
+ }
277
+
278
+ private static final byte _parser_to_state_actions[] = init__parser_to_state_actions_0();
279
+
280
+
281
+ private static byte[] init__parser_from_state_actions_0()
282
+ {
283
+ return new byte [] {
284
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
285
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
286
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
287
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
288
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
289
+ };
290
+ }
291
+
292
+ private static final byte _parser_from_state_actions[] = init__parser_from_state_actions_0();
293
+
294
+
295
+ private static short[] init__parser_eof_trans_0()
296
+ {
297
+ return new short [] {
298
+ 0, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13,
299
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
300
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
301
+ 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, 1, 1,
302
+ 0, 0, 122, 125, 126, 125, 126, 125, 126, 125, 126, 127
303
+ };
304
+ }
305
+
306
+ private static final short _parser_eof_trans[] = init__parser_eof_trans_0();
307
+
308
+
309
+ static final int parser_start = 49;
310
+ static final int parser_first_final = 49;
311
+ static final int parser_error = 0;
312
+
313
+ static final int parser_en_Closeout = 48;
314
+ static final int parser_en_main = 49;
315
+
316
+
317
+ // line 143 "JavaScanner.rl"
318
+
319
+ public RubyArray operate(String tag_prefix, String input) {
320
+ char[] data = input.toCharArray();
321
+ String disposable_string;
322
+
323
+ String name = "";
324
+ String prefix = "";
325
+ RubySymbol flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
326
+ RubyHash attributes = RubyHash.newHash(runtime);
327
+
328
+ int tagstart = 0;
329
+ int mark_pfx = 0;
330
+ int mark_stg = 0;
331
+ int mark_attr = 0;
332
+ int mark_nat = 0;
333
+ int mark_vat = 0;
334
+
335
+ String nat = "";
336
+ String vat = "";
337
+
338
+ int cs;
339
+ int p = 0;
340
+ int pe = data.length;
341
+ int eof = pe;
342
+ int act;
343
+ int ts;
344
+ int te;
345
+
346
+ rv = RubyArray.newArray(runtime);
347
+ char[] remainder = data;
348
+
349
+
350
+ // line 351 "JavaScanner.java"
351
+ {
352
+ cs = parser_start;
353
+ ts = -1;
354
+ te = -1;
355
+ act = 0;
356
+ }
357
+
358
+ // line 175 "JavaScanner.rl"
359
+
360
+ // line 361 "JavaScanner.java"
361
+ {
362
+ int _klen;
363
+ int _trans = 0;
364
+ int _acts;
365
+ int _nacts;
366
+ int _keys;
367
+ int _goto_targ = 0;
368
+
369
+ _goto: while (true) {
370
+ switch ( _goto_targ ) {
371
+ case 0:
372
+ if ( p == pe ) {
373
+ _goto_targ = 4;
374
+ continue _goto;
375
+ }
376
+ if ( cs == 0 ) {
377
+ _goto_targ = 5;
378
+ continue _goto;
379
+ }
380
+ case 1:
381
+ _acts = _parser_from_state_actions[cs];
382
+ _nacts = (int) _parser_actions[_acts++];
383
+ while ( _nacts-- > 0 ) {
384
+ switch ( _parser_actions[_acts++] ) {
385
+ case 15:
386
+ // line 1 "NONE"
387
+ {ts = p;}
388
+ break;
389
+ // line 390 "JavaScanner.java"
390
+ }
391
+ }
392
+
393
+ _match: do {
394
+ _keys = _parser_key_offsets[cs];
395
+ _trans = _parser_index_offsets[cs];
396
+ _klen = _parser_single_lengths[cs];
397
+ if ( _klen > 0 ) {
398
+ int _lower = _keys;
399
+ int _mid;
400
+ int _upper = _keys + _klen - 1;
401
+ while (true) {
402
+ if ( _upper < _lower )
403
+ break;
404
+
405
+ _mid = _lower + ((_upper-_lower) >> 1);
406
+ if ( data[p] < _parser_trans_keys[_mid] )
407
+ _upper = _mid - 1;
408
+ else if ( data[p] > _parser_trans_keys[_mid] )
409
+ _lower = _mid + 1;
410
+ else {
411
+ _trans += (_mid - _keys);
412
+ break _match;
413
+ }
414
+ }
415
+ _keys += _klen;
416
+ _trans += _klen;
417
+ }
418
+
419
+ _klen = _parser_range_lengths[cs];
420
+ if ( _klen > 0 ) {
421
+ int _lower = _keys;
422
+ int _mid;
423
+ int _upper = _keys + (_klen<<1) - 2;
424
+ while (true) {
425
+ if ( _upper < _lower )
426
+ break;
427
+
428
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
429
+ if ( data[p] < _parser_trans_keys[_mid] )
430
+ _upper = _mid - 2;
431
+ else if ( data[p] > _parser_trans_keys[_mid+1] )
432
+ _lower = _mid + 2;
433
+ else {
434
+ _trans += ((_mid - _keys)>>1);
435
+ break _match;
436
+ }
437
+ }
438
+ _trans += _klen;
439
+ }
440
+ } while (false);
441
+
442
+ _trans = _parser_indicies[_trans];
443
+ case 3:
444
+ cs = _parser_trans_targs[_trans];
445
+
446
+ if ( _parser_trans_actions[_trans] != 0 ) {
447
+ _acts = _parser_trans_actions[_trans];
448
+ _nacts = (int) _parser_actions[_acts++];
449
+ while ( _nacts-- > 0 )
450
+ {
451
+ switch ( _parser_actions[_acts++] )
452
+ {
453
+ case 0:
454
+ // line 4 "JavaScanner.rl"
455
+ { mark_pfx = p; }
456
+ break;
457
+ case 1:
458
+ // line 5 "JavaScanner.rl"
459
+ {
460
+ prefix = input.substring(mark_pfx, p);
461
+ }
462
+ break;
463
+ case 2:
464
+ // line 8 "JavaScanner.rl"
465
+ {
466
+ if ( !prefix.equals(tag_prefix) ) {
467
+ // have to manually add ':' / Sep
468
+ // pass the text through & reset state
469
+ pass_through(input.substring(tagstart, p) + ":");
470
+ prefix = "";
471
+ {cs = 49; _goto_targ = 2; if (true) continue _goto;}
472
+ }
473
+ }
474
+ break;
475
+ case 3:
476
+ // line 18 "JavaScanner.rl"
477
+ { mark_stg = p; }
478
+ break;
479
+ case 4:
480
+ // line 19 "JavaScanner.rl"
481
+ { name = input.substring(mark_stg, p); }
482
+ break;
483
+ case 5:
484
+ // line 20 "JavaScanner.rl"
485
+ { mark_attr = p; }
486
+ break;
487
+ case 6:
488
+ // line 21 "JavaScanner.rl"
489
+ {
490
+ attributes.op_aset(
491
+ runtime.getCurrentContext(),
492
+ RubyString.newString(runtime, nat),
493
+ RubyString.newString(runtime, vat)
494
+ );
495
+ }
496
+ break;
497
+ case 7:
498
+ // line 29 "JavaScanner.rl"
499
+ { mark_nat = p; }
500
+ break;
501
+ case 8:
502
+ // line 30 "JavaScanner.rl"
503
+ { nat = input.substring(mark_nat, p); }
504
+ break;
505
+ case 9:
506
+ // line 31 "JavaScanner.rl"
507
+ { mark_vat = p; }
508
+ break;
509
+ case 10:
510
+ // line 32 "JavaScanner.rl"
511
+ { vat = input.substring(mark_vat, p); }
512
+ break;
513
+ case 11:
514
+ // line 34 "JavaScanner.rl"
515
+ { flavor = RubySymbol.newSymbol(runtime, "open".intern()); }
516
+ break;
517
+ case 12:
518
+ // line 35 "JavaScanner.rl"
519
+ { flavor = RubySymbol.newSymbol(runtime, "self".intern()); }
520
+ break;
521
+ case 13:
522
+ // line 36 "JavaScanner.rl"
523
+ { flavor = RubySymbol.newSymbol(runtime, "close".intern()); }
524
+ break;
525
+ case 16:
526
+ // line 1 "NONE"
527
+ {te = p+1;}
528
+ break;
529
+ case 17:
530
+ // line 72 "JavaScanner.rl"
531
+ {act = 1;}
532
+ break;
533
+ case 18:
534
+ // line 79 "JavaScanner.rl"
535
+ {act = 2;}
536
+ break;
537
+ case 19:
538
+ // line 79 "JavaScanner.rl"
539
+ {te = p+1;{
540
+ pass_through(input.substring(p, p + 1));
541
+ tagstart = p + 1;
542
+ }}
543
+ break;
544
+ case 20:
545
+ // line 72 "JavaScanner.rl"
546
+ {te = p;p--;{
547
+ tag(prefix, name, attributes, flavor);
548
+ prefix = "";
549
+ name = "";
550
+ attributes = RubyHash.newHash(runtime);
551
+ flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
552
+ }}
553
+ break;
554
+ case 21:
555
+ // line 79 "JavaScanner.rl"
556
+ {te = p;p--;{
557
+ pass_through(input.substring(p, p + 1));
558
+ tagstart = p + 1;
559
+ }}
560
+ break;
561
+ case 22:
562
+ // line 79 "JavaScanner.rl"
563
+ {{p = ((te))-1;}{
564
+ pass_through(input.substring(p, p + 1));
565
+ tagstart = p + 1;
566
+ }}
567
+ break;
568
+ case 23:
569
+ // line 1 "NONE"
570
+ { switch( act ) {
571
+ case 1:
572
+ {{p = ((te))-1;}
573
+ tag(prefix, name, attributes, flavor);
574
+ prefix = "";
575
+ name = "";
576
+ attributes = RubyHash.newHash(runtime);
577
+ flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
578
+ }
579
+ break;
580
+ case 2:
581
+ {{p = ((te))-1;}
582
+ pass_through(input.substring(p, p + 1));
583
+ tagstart = p + 1;
584
+ }
585
+ break;
586
+ }
587
+ }
588
+ break;
589
+ // line 590 "JavaScanner.java"
590
+ }
591
+ }
592
+ }
593
+
594
+ case 2:
595
+ _acts = _parser_to_state_actions[cs];
596
+ _nacts = (int) _parser_actions[_acts++];
597
+ while ( _nacts-- > 0 ) {
598
+ switch ( _parser_actions[_acts++] ) {
599
+ case 14:
600
+ // line 1 "NONE"
601
+ {ts = -1;}
602
+ break;
603
+ // line 604 "JavaScanner.java"
604
+ }
605
+ }
606
+
607
+ if ( cs == 0 ) {
608
+ _goto_targ = 5;
609
+ continue _goto;
610
+ }
611
+ if ( ++p != pe ) {
612
+ _goto_targ = 1;
613
+ continue _goto;
614
+ }
615
+ case 4:
616
+ if ( p == eof )
617
+ {
618
+ if ( _parser_eof_trans[cs] > 0 ) {
619
+ _trans = _parser_eof_trans[cs] - 1;
620
+ _goto_targ = 3;
621
+ continue _goto;
622
+ }
623
+ }
624
+
625
+ case 5:
626
+ }
627
+ break; }
628
+ }
629
+
630
+ // line 176 "JavaScanner.rl"
631
+
632
+ return rv;
633
+ }
634
+ }