liquor 0.1.1 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -9
  5. data/Gemfile +7 -0
  6. data/Guardfile +11 -0
  7. data/MIT-LICENSE +6 -2
  8. data/README.md +4 -122
  9. data/Rakefile +20 -23
  10. data/doc/language-spec.html +768 -0
  11. data/doc/language-spec.md +698 -0
  12. data/lib/liquor.rb +39 -68
  13. data/lib/liquor/ast_tools.rb +28 -0
  14. data/lib/liquor/compiler.rb +110 -0
  15. data/lib/liquor/context.rb +76 -254
  16. data/lib/liquor/diagnostics.rb +151 -0
  17. data/lib/liquor/drop/drop.rb +168 -0
  18. data/lib/liquor/drop/drop_delegation.rb +24 -0
  19. data/lib/liquor/drop/drop_scope.rb +118 -0
  20. data/lib/liquor/drop/dropable.rb +17 -0
  21. data/lib/liquor/emitter.rb +313 -0
  22. data/lib/liquor/extensions/kaminari.rb +14 -0
  23. data/lib/liquor/extensions/pagination.rb +235 -0
  24. data/lib/liquor/extensions/rails.rb +97 -0
  25. data/lib/liquor/extensions/thinking_sphinx.rb +14 -0
  26. data/lib/liquor/extensions/tire.rb +30 -0
  27. data/lib/liquor/external.rb +79 -0
  28. data/lib/liquor/function.rb +94 -0
  29. data/lib/liquor/grammar/lexer.rb +1223 -0
  30. data/lib/liquor/grammar/lexer.rl +297 -0
  31. data/lib/liquor/grammar/parser.racc +288 -0
  32. data/lib/liquor/grammar/parser.rb +885 -0
  33. data/lib/liquor/library.rb +41 -0
  34. data/lib/liquor/manager.rb +146 -0
  35. data/lib/liquor/runtime.rb +167 -0
  36. data/lib/liquor/stdlib/builtin_functions.rb +315 -0
  37. data/lib/liquor/stdlib/builtin_tags.rb +228 -0
  38. data/lib/liquor/stdlib/html_truncater.rb +162 -0
  39. data/lib/liquor/stdlib/partial_tags.rb +76 -0
  40. data/lib/liquor/tag.rb +83 -14
  41. data/lib/liquor/version.rb +1 -1
  42. data/liquor.gemspec +29 -6
  43. data/spec/builtins_spec.rb +264 -0
  44. data/spec/compiler_spec.rb +136 -0
  45. data/spec/context_spec.rb +49 -0
  46. data/spec/drop_delegation_spec.rb +21 -0
  47. data/spec/drop_spec.rb +222 -0
  48. data/spec/errors_spec.rb +40 -0
  49. data/spec/external_spec.rb +207 -0
  50. data/spec/function_spec.rb +80 -0
  51. data/spec/lexer_spec.rb +173 -0
  52. data/spec/library_spec.rb +18 -0
  53. data/spec/manager_spec.rb +84 -0
  54. data/spec/parser_spec.rb +381 -0
  55. data/spec/partials_spec.rb +74 -0
  56. data/spec/runtime_spec.rb +97 -0
  57. data/spec/spec_helper.rb +94 -0
  58. data/spec/tag_spec.rb +7 -0
  59. metadata +216 -173
  60. data/AUTHORS +0 -2
  61. data/CHANGELOG +0 -48
  62. data/Gemfile.lock +0 -91
  63. data/History.txt +0 -44
  64. data/LICENSE +0 -23
  65. data/example/server/example_servlet.rb +0 -37
  66. data/example/server/liquid_servlet.rb +0 -28
  67. data/example/server/liquor_servlet.rb +0 -28
  68. data/example/server/server.rb +0 -12
  69. data/example/server/templates/index.liquid +0 -6
  70. data/example/server/templates/index.liquor +0 -6
  71. data/example/server/templates/products.liquid +0 -45
  72. data/example/server/templates/products.liquor +0 -45
  73. data/init.rb +0 -8
  74. data/lib/extras/liquid_view.rb +0 -51
  75. data/lib/extras/liquor_view.rb +0 -51
  76. data/lib/liquor/block.rb +0 -101
  77. data/lib/liquor/condition.rb +0 -120
  78. data/lib/liquor/document.rb +0 -17
  79. data/lib/liquor/drop.rb +0 -256
  80. data/lib/liquor/errors.rb +0 -11
  81. data/lib/liquor/extensions.rb +0 -72
  82. data/lib/liquor/file_system.rb +0 -62
  83. data/lib/liquor/htmltags.rb +0 -74
  84. data/lib/liquor/module_ex.rb +0 -60
  85. data/lib/liquor/standardfilters.rb +0 -315
  86. data/lib/liquor/strainer.rb +0 -58
  87. data/lib/liquor/tags/assign.rb +0 -33
  88. data/lib/liquor/tags/capture.rb +0 -35
  89. data/lib/liquor/tags/case.rb +0 -83
  90. data/lib/liquor/tags/comment.rb +0 -9
  91. data/lib/liquor/tags/content_for.rb +0 -54
  92. data/lib/liquor/tags/cycle.rb +0 -59
  93. data/lib/liquor/tags/for.rb +0 -136
  94. data/lib/liquor/tags/if.rb +0 -80
  95. data/lib/liquor/tags/ifchanged.rb +0 -20
  96. data/lib/liquor/tags/include.rb +0 -56
  97. data/lib/liquor/tags/unless.rb +0 -33
  98. data/lib/liquor/tags/yield.rb +0 -49
  99. data/lib/liquor/template.rb +0 -181
  100. data/lib/liquor/variable.rb +0 -52
  101. data/performance/shopify.rb +0 -92
  102. data/performance/shopify/comment_form.rb +0 -33
  103. data/performance/shopify/database.rb +0 -45
  104. data/performance/shopify/json_filter.rb +0 -7
  105. data/performance/shopify/liquid.rb +0 -18
  106. data/performance/shopify/liquor.rb +0 -18
  107. data/performance/shopify/money_filter.rb +0 -18
  108. data/performance/shopify/paginate.rb +0 -93
  109. data/performance/shopify/shop_filter.rb +0 -98
  110. data/performance/shopify/tag_filter.rb +0 -25
  111. data/performance/shopify/vision.database.yml +0 -945
  112. data/performance/shopify/weight_filter.rb +0 -11
  113. data/performance/tests/dropify/article.liquid +0 -74
  114. data/performance/tests/dropify/blog.liquid +0 -33
  115. data/performance/tests/dropify/cart.liquid +0 -66
  116. data/performance/tests/dropify/collection.liquid +0 -22
  117. data/performance/tests/dropify/index.liquid +0 -47
  118. data/performance/tests/dropify/page.liquid +0 -8
  119. data/performance/tests/dropify/product.liquid +0 -68
  120. data/performance/tests/dropify/theme.liquid +0 -105
  121. data/performance/tests/ripen/article.liquid +0 -74
  122. data/performance/tests/ripen/blog.liquid +0 -13
  123. data/performance/tests/ripen/cart.liquid +0 -54
  124. data/performance/tests/ripen/collection.liquid +0 -29
  125. data/performance/tests/ripen/index.liquid +0 -32
  126. data/performance/tests/ripen/page.liquid +0 -4
  127. data/performance/tests/ripen/product.liquid +0 -75
  128. data/performance/tests/ripen/theme.liquid +0 -85
  129. data/performance/tests/tribble/404.liquid +0 -56
  130. data/performance/tests/tribble/article.liquid +0 -98
  131. data/performance/tests/tribble/blog.liquid +0 -41
  132. data/performance/tests/tribble/cart.liquid +0 -134
  133. data/performance/tests/tribble/collection.liquid +0 -70
  134. data/performance/tests/tribble/index.liquid +0 -94
  135. data/performance/tests/tribble/page.liquid +0 -56
  136. data/performance/tests/tribble/product.liquid +0 -116
  137. data/performance/tests/tribble/search.liquid +0 -51
  138. data/performance/tests/tribble/theme.liquid +0 -90
  139. data/performance/tests/vogue/article.liquid +0 -66
  140. data/performance/tests/vogue/blog.liquid +0 -32
  141. data/performance/tests/vogue/cart.liquid +0 -58
  142. data/performance/tests/vogue/collection.liquid +0 -19
  143. data/performance/tests/vogue/index.liquid +0 -22
  144. data/performance/tests/vogue/page.liquid +0 -3
  145. data/performance/tests/vogue/product.liquid +0 -62
  146. data/performance/tests/vogue/theme.liquid +0 -122
  147. data/test/assign_test.rb +0 -11
  148. data/test/block_test.rb +0 -58
  149. data/test/capture_test.rb +0 -41
  150. data/test/condition_test.rb +0 -115
  151. data/test/content_for_test.rb +0 -15
  152. data/test/context_test.rb +0 -479
  153. data/test/drop_test.rb +0 -162
  154. data/test/error_handling_test.rb +0 -89
  155. data/test/extra/breakpoint.rb +0 -547
  156. data/test/extra/caller.rb +0 -80
  157. data/test/file_system_test.rb +0 -30
  158. data/test/filter_test.rb +0 -147
  159. data/test/helper.rb +0 -24
  160. data/test/html_tag_test.rb +0 -31
  161. data/test/if_else_test.rb +0 -139
  162. data/test/include_tag_test.rb +0 -129
  163. data/test/module_ex_test.rb +0 -89
  164. data/test/output_test.rb +0 -121
  165. data/test/parsing_quirks_test.rb +0 -54
  166. data/test/regexp_test.rb +0 -45
  167. data/test/security_test.rb +0 -41
  168. data/test/standard_filter_test.rb +0 -170
  169. data/test/standard_tag_test.rb +0 -405
  170. data/test/statements_test.rb +0 -137
  171. data/test/strainer_test.rb +0 -27
  172. data/test/template_test.rb +0 -82
  173. data/test/test_helper.rb +0 -28
  174. data/test/unless_else_test.rb +0 -27
  175. data/test/variable_test.rb +0 -173
  176. data/test/yield_test.rb +0 -24
@@ -0,0 +1,97 @@
1
+ require 'rails'
2
+
3
+ ActionController::Renderers.add :liquor do |options, *|
4
+ output = nil
5
+ manager, name, layout_name, environment, storage = \
6
+ options.values_at(:manager, :template, :layout, :environment, :storage)
7
+
8
+ storage ||= {}
9
+
10
+ ActiveSupport::Notifications.instrument("render_template.action_view",
11
+ identifier: name, layout: layout_name) do
12
+ if layout_name
13
+ output = manager.render_with_layout(layout_name, environment,
14
+ name, environment, storage)
15
+ else
16
+ output = manager.render(name, environment, storage)
17
+ end
18
+ end
19
+
20
+ render :text => output
21
+ end
22
+
23
+ module Liquor::Rails
24
+ class Request
25
+ include Liquor::External
26
+
27
+ def initialize(request, controller)
28
+ @request = request
29
+ @controller = controller
30
+ end
31
+
32
+ delegate :url, to: :@request
33
+ delegate :path, to: :@request
34
+ delegate :referer, to: :@request
35
+
36
+ export :url, :path, :referer
37
+
38
+ def param(arg, kw={})
39
+ @request.params[arg.to_s]
40
+ end
41
+
42
+ export :param
43
+
44
+ def controller
45
+ @controller.controller_name
46
+ end
47
+
48
+ def action
49
+ @controller.action_name
50
+ end
51
+
52
+ export :controller, :action
53
+
54
+ def form_authenticity_token
55
+ # Sorry for sends
56
+ if @controller.send(:protect_against_forgery?)
57
+ @controller.send(:form_authenticity_token)
58
+ end
59
+ end
60
+
61
+ export :form_authenticity_token
62
+ end
63
+
64
+ class TemplateLoader
65
+ # TODO
66
+ end
67
+
68
+ class LogSubscriber < ActiveSupport::LogSubscriber
69
+ def load_template(event)
70
+ line(event, " Template Load", color: WHITE, info: "#{event.payload[:name]}")
71
+ end
72
+
73
+ def load(event)
74
+ line(event, "Template Load All", color: CYAN)
75
+ end
76
+
77
+ def compile(event)
78
+ line(event, "Template Compile", color: CYAN)
79
+ end
80
+
81
+ def logger
82
+ ActionController::Base.logger
83
+ end
84
+
85
+ protected
86
+
87
+ def line(event, what, options={})
88
+ if options[:color]
89
+ what = color(what, options[:color], true)
90
+ end
91
+
92
+ debug(" %s (%.1fms) %s" % [what, event.duration, options[:info]])
93
+ end
94
+ end
95
+
96
+ LogSubscriber.attach_to :liquor
97
+ end
@@ -0,0 +1,14 @@
1
+ require 'thinking_sphinx'
2
+ require 'liquor/extensions/pagination'
3
+
4
+ module ThinkingSphinx
5
+ class Search
6
+ def to_drop
7
+ Liquor::Pagination::Scope.new(self)
8
+ end
9
+
10
+ def to_page_path(url_generator, page)
11
+ url_generator.search_path(query: @query, page: page)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'tire'
2
+ require 'liquor/extensions/pagination'
3
+
4
+ module Tire
5
+ module Results
6
+ class Collection
7
+ def to_drop
8
+ Liquor::Pagination::Scope.new(self)
9
+ end
10
+
11
+ def to_page_path(url_generator, page)
12
+ url_generator.search_path(query: @query, page: page)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ module Tire
19
+ module Search
20
+ class Search
21
+ def to_drop
22
+ Liquor::Pagination::Scope.new(self.results)
23
+ end
24
+
25
+ def to_page_path(url_generator, page)
26
+ url_generator.search_path(query: @query, page: page)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,79 @@
1
+ require 'date'
2
+
3
+ module Liquor
4
+ module External
5
+ module ClassMethods
6
+ def export(*methods)
7
+ unless @liquor_exports
8
+ @liquor_exports = superclass.liquor_exports.dup
9
+ @liquor_deprecations = superclass.liquor_deprecations.dup
10
+ end
11
+
12
+ @liquor_exports.merge methods
13
+ end
14
+
15
+ def deprecate(*args)
16
+ options = {}
17
+ options = args.delete_at(-1) if args[-1].is_a? Hash
18
+
19
+ if (missing = [:date, :message] - options.keys).any?
20
+ raise ::ArgumentError, "A call to Liquor::External#deprecate misses " <<
21
+ "mandatory arguments: #{missing.join(", ")}"
22
+ elsif (extra = options.keys - [:date, :message]).any?
23
+ raise ::ArgumentError, "A call to Liquor::External#deprecate has " <<
24
+ "extraneous arguments: #{missing.join(", ")}"
25
+ end
26
+
27
+ options = {
28
+ date: Date.parse(options[:date]),
29
+ message: options[:message].to_s
30
+ }.freeze
31
+
32
+ args.each do |export|
33
+ @liquor_deprecations[export] = options
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.included(klass)
39
+ klass.instance_exec do
40
+ class << self
41
+ attr_reader :liquor_exports
42
+ attr_reader :liquor_deprecations
43
+ end
44
+
45
+ @liquor_exports = Set[]
46
+ @liquor_deprecations = {}
47
+
48
+ extend ClassMethods
49
+ end
50
+ end
51
+
52
+ def liquor_send(method, args, loc=nil)
53
+ method = method.to_sym
54
+
55
+ if self.class.liquor_exports.include?(method)
56
+ if (deprecation = self.class.liquor_deprecations[method])
57
+ Liquor::Runtime.deprecation(
58
+ "`#{method}' is deprecated and will be removed after " <<
59
+ "#{deprecation[:date]}: #{deprecation[:message]}", loc)
60
+ end
61
+
62
+ begin
63
+ send method, *args
64
+ rescue ::Liquor::Diagnostic => e
65
+ raise e
66
+ rescue ::Exception => e
67
+ # First, remove the caller backtrace at the following line.
68
+ # This will not include the line in liquor_send which will
69
+ # be in the host exception backtrace. Second, remove that one.
70
+ host_backtrace = (e.backtrace - caller)[0..-2]
71
+
72
+ raise HostError.new(nil, e, host_backtrace, loc)
73
+ end
74
+ else
75
+ raise ArgumentError.new("undefined external method #{method} for #{self.class}", loc)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,94 @@
1
+ module Liquor
2
+ class Function
3
+ attr_reader :name
4
+ attr_reader :unnamed_arg
5
+ attr_reader :mandatory_named_args, :optional_named_args
6
+ attr_reader :call
7
+
8
+ def initialize(name, options={}, &block)
9
+ @name = name.to_s
10
+
11
+ options = options.dup
12
+ @unnamed_arg = options.delete(:unnamed_arg)
13
+ @mandatory_named_args = (options.delete(:mandatory_named_args) || {}).to_hash
14
+ @optional_named_args = (options.delete(:optional_named_args) || {}).to_hash
15
+ @body = block
16
+
17
+ if @body.nil?
18
+ raise "Cannot define a function without body"
19
+ elsif options.any?
20
+ raise "Unknown function options: #{options.keys.join ", "}"
21
+ end
22
+ end
23
+
24
+ def alias(new_name)
25
+ self.class.new(new_name, {
26
+ unnamed_arg: @unnamed_arg,
27
+ mandatory_named_args: @mandatory_named_args,
28
+ optional_named_args: @optional_named_args,
29
+ }, &@body)
30
+ end
31
+
32
+ def check_type(name, arg, expected_type, loc)
33
+ actual_type = Runtime.type arg
34
+ check_failed = false
35
+
36
+ case expected_type
37
+ when :any
38
+ check_failed = (actual_type == :invalid)
39
+ when :null, :boolean, :string, :integer, :tuple, :external
40
+ check_failed = (actual_type != expected_type)
41
+ when Array
42
+ check_failed = !expected_type.include?(actual_type)
43
+ else
44
+ raise "Invalid type specifier: #{expected_type.inspect}"
45
+ end
46
+
47
+ if check_failed &&
48
+ Array(expected_type).include?(:tuple) &&
49
+ Runtime.indexable?(arg)
50
+ check_failed = false
51
+ end
52
+
53
+ if check_failed
54
+ expected = Array(expected_type).map(&:capitalize).join(", ")
55
+
56
+ Runtime.soft_error(ArgumentTypeError,
57
+ "#{expected} value expected, #{Runtime.pretty_type arg} found",
58
+ Array(expected_type).first,
59
+ { function: @name, argument: name }.merge(loc))
60
+ else
61
+ arg
62
+ end
63
+ end
64
+
65
+ def call(arg=nil, kw={}, loc={})
66
+ arg = check_type nil, arg, @unnamed_arg, loc if @unnamed_arg
67
+
68
+ @mandatory_named_args.each do |name, type|
69
+ kw[name] = check_type name, kw[name], type, loc
70
+ end
71
+
72
+ @optional_named_args.each do |name, type|
73
+ kw[name] = check_type name, kw[name], type, loc if kw.has_key?(name)
74
+ end
75
+
76
+ begin
77
+ if @body.arity == 3
78
+ @body.call(arg, kw, loc)
79
+ else
80
+ @body.call(arg, kw)
81
+ end
82
+ rescue ::Liquor::Diagnostic => e
83
+ raise e
84
+ rescue ::Exception => e
85
+ # First, remove the caller backtrace at the following line.
86
+ # This will not include the line in liquor_send which will
87
+ # be in the host exception backtrace. Second, remove that one.
88
+ host_backtrace = (e.backtrace - caller)[0..-2]
89
+
90
+ raise HostError.new(nil, e, host_backtrace, loc)
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,1223 @@
1
+
2
+ # line 1 "lib/liquor/grammar/lexer.rl"
3
+
4
+ # line 212 "lib/liquor/grammar/lexer.rl"
5
+
6
+
7
+ module Liquor
8
+ module Lexer
9
+
10
+ # line 11 "lib/liquor/grammar/lexer.rb"
11
+ class << self
12
+ attr_accessor :_liquor_actions
13
+ private :_liquor_actions, :_liquor_actions=
14
+ end
15
+ self._liquor_actions = [
16
+ 0, 1, 1, 1, 3, 1, 4, 1,
17
+ 5, 1, 6, 1, 7, 1, 8, 1,
18
+ 9, 1, 10, 1, 11, 1, 12, 1,
19
+ 13, 1, 14, 1, 15, 1, 16, 1,
20
+ 17, 1, 18, 1, 19, 1, 20, 1,
21
+ 21, 1, 22, 1, 23, 1, 24, 1,
22
+ 25, 1, 26, 1, 27, 1, 28, 1,
23
+ 29, 1, 30, 1, 31, 1, 32, 1,
24
+ 33, 1, 34, 1, 35, 1, 36, 1,
25
+ 37, 1, 38, 1, 39, 1, 40, 1,
26
+ 41, 1, 42, 1, 43, 1, 44, 1,
27
+ 45, 1, 46, 1, 47, 1, 48, 1,
28
+ 49, 1, 50, 1, 51, 1, 52, 1,
29
+ 53, 1, 54, 1, 55, 1, 56, 1,
30
+ 57, 1, 58, 1, 59, 1, 60, 1,
31
+ 61, 1, 62, 1, 63, 1, 64, 1,
32
+ 65, 1, 66, 1, 67, 1, 68, 1,
33
+ 69, 1, 70, 1, 71, 1, 72, 2,
34
+ 0, 8, 2, 5, 0, 2, 5, 2
35
+ ]
36
+
37
+ class << self
38
+ attr_accessor :_liquor_key_offsets
39
+ private :_liquor_key_offsets, :_liquor_key_offsets=
40
+ end
41
+ self._liquor_key_offsets = [
42
+ 0, 4, 9, 12, 13, 16, 17, 20,
43
+ 23, 26, 28, 32, 35, 36, 37, 40,
44
+ 42, 45, 47, 54, 56, 64, 66, 74,
45
+ 83, 92, 101, 108, 137, 139, 140, 141,
46
+ 142, 143, 147, 148, 156, 159, 160
47
+ ]
48
+
49
+ class << self
50
+ attr_accessor :_liquor_trans_keys
51
+ private :_liquor_trans_keys, :_liquor_trans_keys=
52
+ end
53
+ self._liquor_trans_keys = [
54
+ 10, 33, 37, 123, 95, 65, 90, 97,
55
+ 122, 9, 32, 37, 125, 9, 32, 37,
56
+ 125, 10, 92, 123, 10, 92, 123, 10,
57
+ 92, 123, 10, 92, 10, 33, 37, 123,
58
+ 10, 33, 123, 125, 33, 10, 34, 92,
59
+ 34, 92, 10, 39, 92, 39, 92, 95,
60
+ 48, 57, 65, 90, 97, 122, 48, 57,
61
+ 9, 32, 95, 101, 65, 90, 97, 122,
62
+ 9, 32, 58, 95, 48, 57, 65, 90,
63
+ 97, 122, 58, 95, 110, 48, 57, 65,
64
+ 90, 97, 122, 58, 95, 100, 48, 57,
65
+ 65, 90, 97, 122, 32, 58, 95, 48,
66
+ 57, 65, 90, 97, 122, 95, 48, 57,
67
+ 65, 90, 97, 122, 9, 32, 33, 34,
68
+ 37, 38, 39, 40, 41, 42, 43, 44,
69
+ 45, 46, 47, 60, 61, 62, 91, 93,
70
+ 95, 124, 125, 48, 57, 65, 90, 97,
71
+ 122, 9, 32, 61, 125, 38, 61, 9,
72
+ 32, 37, 61, 61, 58, 95, 48, 57,
73
+ 65, 90, 97, 122, 9, 32, 37, 124,
74
+ 125, 0
75
+ ]
76
+
77
+ class << self
78
+ attr_accessor :_liquor_single_lengths
79
+ private :_liquor_single_lengths, :_liquor_single_lengths=
80
+ end
81
+ self._liquor_single_lengths = [
82
+ 4, 1, 3, 1, 3, 1, 3, 3,
83
+ 3, 2, 4, 3, 1, 1, 3, 2,
84
+ 3, 2, 1, 0, 4, 2, 2, 3,
85
+ 3, 3, 1, 23, 2, 1, 1, 1,
86
+ 1, 4, 1, 2, 3, 1, 1
87
+ ]
88
+
89
+ class << self
90
+ attr_accessor :_liquor_range_lengths
91
+ private :_liquor_range_lengths, :_liquor_range_lengths=
92
+ end
93
+ self._liquor_range_lengths = [
94
+ 0, 2, 0, 0, 0, 0, 0, 0,
95
+ 0, 0, 0, 0, 0, 0, 0, 0,
96
+ 0, 0, 3, 1, 2, 0, 3, 3,
97
+ 3, 3, 3, 3, 0, 0, 0, 0,
98
+ 0, 0, 0, 3, 0, 0, 0
99
+ ]
100
+
101
+ class << self
102
+ attr_accessor :_liquor_index_offsets
103
+ private :_liquor_index_offsets, :_liquor_index_offsets=
104
+ end
105
+ self._liquor_index_offsets = [
106
+ 0, 5, 9, 13, 15, 19, 21, 25,
107
+ 29, 33, 36, 41, 45, 47, 49, 53,
108
+ 56, 60, 63, 68, 70, 77, 80, 86,
109
+ 93, 100, 107, 112, 139, 142, 144, 146,
110
+ 148, 150, 155, 157, 163, 167, 169
111
+ ]
112
+
113
+ class << self
114
+ attr_accessor :_liquor_indicies
115
+ private :_liquor_indicies, :_liquor_indicies=
116
+ end
117
+ self._liquor_indicies = [
118
+ 2, 0, 0, 0, 1, 4, 4, 4,
119
+ 3, 6, 6, 7, 5, 8, 5, 10,
120
+ 10, 11, 9, 12, 9, 2, 13, 14,
121
+ 1, 2, 13, 16, 1, 2, 13, 17,
122
+ 1, 2, 13, 1, 2, 19, 20, 21,
123
+ 1, 23, 24, 25, 22, 27, 26, 28,
124
+ 26, 30, 31, 32, 29, 34, 35, 33,
125
+ 37, 38, 39, 36, 41, 42, 40, 45,
126
+ 44, 45, 45, 43, 44, 46, 48, 48,
127
+ 49, 50, 49, 49, 47, 48, 48, 51,
128
+ 53, 49, 49, 49, 49, 52, 53, 49,
129
+ 54, 49, 49, 49, 52, 53, 49, 55,
130
+ 49, 49, 49, 52, 56, 53, 49, 49,
131
+ 49, 49, 52, 4, 4, 4, 4, 57,
132
+ 59, 59, 60, 61, 62, 63, 64, 65,
133
+ 66, 67, 68, 69, 70, 71, 72, 74,
134
+ 75, 76, 78, 79, 77, 80, 81, 73,
135
+ 77, 77, 58, 59, 59, 82, 84, 83,
136
+ 86, 85, 88, 87, 90, 89, 6, 6,
137
+ 7, 92, 91, 94, 93, 96, 77, 77,
138
+ 77, 77, 95, 10, 10, 11, 97, 99,
139
+ 98, 100, 87, 0
140
+ ]
141
+
142
+ class << self
143
+ attr_accessor :_liquor_trans_targs
144
+ private :_liquor_trans_targs, :_liquor_trans_targs=
145
+ end
146
+ self._liquor_trans_targs = [
147
+ 6, 7, 7, 20, 26, 27, 2, 3,
148
+ 27, 27, 4, 5, 27, 8, 10, 6,
149
+ 0, 9, 6, 6, 6, 6, 11, 11,
150
+ 12, 13, 11, 11, 11, 14, 14, 14,
151
+ 15, 14, 14, 14, 16, 16, 16, 17,
152
+ 16, 16, 16, 18, 19, 18, 18, 20,
153
+ 21, 22, 23, 20, 20, 20, 24, 25,
154
+ 1, 20, 27, 28, 29, 27, 30, 31,
155
+ 27, 27, 27, 27, 27, 27, 27, 27,
156
+ 27, 27, 32, 33, 34, 35, 27, 27,
157
+ 37, 38, 27, 27, 27, 27, 27, 27,
158
+ 27, 27, 27, 27, 27, 27, 27, 27,
159
+ 36, 27, 27, 27, 27
160
+ ]
161
+
162
+ class << self
163
+ attr_accessor :_liquor_trans_actions
164
+ private :_liquor_trans_actions, :_liquor_trans_actions=
165
+ end
166
+ self._liquor_trans_actions = [
167
+ 141, 7, 146, 57, 0, 129, 0, 0,
168
+ 63, 127, 0, 0, 61, 0, 0, 137,
169
+ 0, 0, 139, 135, 133, 131, 13, 143,
170
+ 0, 0, 15, 11, 9, 23, 25, 21,
171
+ 0, 27, 17, 19, 35, 37, 33, 0,
172
+ 39, 29, 31, 43, 0, 41, 45, 49,
173
+ 0, 0, 0, 51, 55, 47, 0, 7,
174
+ 0, 53, 105, 0, 0, 97, 0, 0,
175
+ 99, 73, 75, 81, 77, 65, 79, 67,
176
+ 83, 59, 0, 7, 0, 0, 69, 71,
177
+ 0, 0, 107, 123, 87, 117, 103, 125,
178
+ 93, 121, 91, 113, 85, 119, 89, 109,
179
+ 149, 111, 115, 95, 101
180
+ ]
181
+
182
+ class << self
183
+ attr_accessor :_liquor_to_state_actions
184
+ private :_liquor_to_state_actions, :_liquor_to_state_actions=
185
+ end
186
+ self._liquor_to_state_actions = [
187
+ 0, 0, 0, 0, 0, 0, 3, 0,
188
+ 0, 0, 0, 3, 0, 0, 3, 0,
189
+ 3, 0, 3, 0, 3, 0, 0, 0,
190
+ 0, 0, 0, 3, 0, 0, 0, 0,
191
+ 0, 0, 0, 0, 0, 0, 0
192
+ ]
193
+
194
+ class << self
195
+ attr_accessor :_liquor_from_state_actions
196
+ private :_liquor_from_state_actions, :_liquor_from_state_actions=
197
+ end
198
+ self._liquor_from_state_actions = [
199
+ 0, 0, 0, 0, 0, 0, 5, 0,
200
+ 0, 0, 0, 5, 0, 0, 5, 0,
201
+ 5, 0, 5, 0, 5, 0, 0, 0,
202
+ 0, 0, 0, 5, 0, 0, 0, 0,
203
+ 0, 0, 0, 0, 0, 0, 0
204
+ ]
205
+
206
+ class << self
207
+ attr_accessor :_liquor_eof_actions
208
+ private :_liquor_eof_actions, :_liquor_eof_actions=
209
+ end
210
+ self._liquor_eof_actions = [
211
+ 0, 0, 0, 0, 0, 0, 0, 0,
212
+ 0, 0, 0, 0, 0, 0, 1, 0,
213
+ 1, 0, 0, 0, 0, 0, 0, 0,
214
+ 0, 0, 0, 0, 0, 0, 0, 0,
215
+ 0, 0, 0, 0, 0, 0, 0
216
+ ]
217
+
218
+ class << self
219
+ attr_accessor :_liquor_eof_trans
220
+ private :_liquor_eof_trans, :_liquor_eof_trans=
221
+ end
222
+ self._liquor_eof_trans = [
223
+ 1, 4, 6, 6, 10, 10, 0, 16,
224
+ 16, 16, 19, 0, 27, 27, 0, 34,
225
+ 0, 41, 0, 47, 0, 52, 53, 53,
226
+ 53, 53, 58, 0, 83, 84, 86, 88,
227
+ 90, 92, 94, 96, 98, 99, 88
228
+ ]
229
+
230
+ class << self
231
+ attr_accessor :liquor_start
232
+ end
233
+ self.liquor_start = 6;
234
+ class << self
235
+ attr_accessor :liquor_first_final
236
+ end
237
+ self.liquor_first_final = 6;
238
+ class << self
239
+ attr_accessor :liquor_error
240
+ end
241
+ self.liquor_error = -1;
242
+
243
+ class << self
244
+ attr_accessor :liquor_en_comment
245
+ end
246
+ self.liquor_en_comment = 11;
247
+ class << self
248
+ attr_accessor :liquor_en_dqstring
249
+ end
250
+ self.liquor_en_dqstring = 14;
251
+ class << self
252
+ attr_accessor :liquor_en_sqstring
253
+ end
254
+ self.liquor_en_sqstring = 16;
255
+ class << self
256
+ attr_accessor :liquor_en_integer
257
+ end
258
+ self.liquor_en_integer = 18;
259
+ class << self
260
+ attr_accessor :liquor_en_tag_start
261
+ end
262
+ self.liquor_en_tag_start = 20;
263
+ class << self
264
+ attr_accessor :liquor_en_code
265
+ end
266
+ self.liquor_en_code = 27;
267
+ class << self
268
+ attr_accessor :liquor_en_plaintext
269
+ end
270
+ self.liquor_en_plaintext = 6;
271
+
272
+
273
+ # line 217 "lib/liquor/grammar/lexer.rl"
274
+
275
+ def self.lex(data, name='(code)', registered_tags={})
276
+ eof = data.length
277
+ ts = nil # token start
278
+ te = nil # token end
279
+ stack = []
280
+
281
+ # Strings
282
+ string = ""
283
+ str_start = nil
284
+ runaway = false
285
+
286
+ # Tags
287
+ kw_stop = nil
288
+
289
+ line_starts = [0]
290
+
291
+ find_line_start = ->(index) {
292
+ line_starts.
293
+ each_index.find { |i|
294
+ line_starts[i + 1].nil? || line_starts[i + 1] > index
295
+ }
296
+ }
297
+ loc = ->(index) {
298
+ line_start_index = find_line_start.(index)
299
+ [ line_start_index, index - line_starts[line_start_index] ]
300
+ }
301
+
302
+ # Tag stack
303
+ tag_stack = []
304
+ tag_conts = []
305
+ last_tag = nil
306
+
307
+ update_tag_cont = ->() {
308
+ tag = tag_stack.last
309
+ if registered_tags.include?(tag)
310
+ tag_conts = registered_tags[tag].continuations
311
+ end
312
+ }
313
+ push_last_tag = ->() {
314
+ if last_tag
315
+ tag_stack.push last_tag
316
+ last_tag = nil
317
+ update_tag_cont.()
318
+ end
319
+ }
320
+ pop_tag = ->() {
321
+ tag_stack.pop
322
+ update_tag_cont.()
323
+ }
324
+
325
+ tokens = []
326
+
327
+ fixtok = ->(new_type) {
328
+ tokens.last[0] = new_type
329
+ }
330
+ tok = ->(type, data=nil, options={}) {
331
+ sl, sc, el, ec = *loc.(options[:ts] || ts),
332
+ *loc.(options[:te] || te - 1)
333
+ tokens << [type, { file: name, line: sl, start: sc, end: ec }, *data]
334
+ }
335
+
336
+
337
+ # line 338 "lib/liquor/grammar/lexer.rb"
338
+ begin
339
+ p ||= 0
340
+ pe ||= data.length
341
+ cs = liquor_start
342
+ top = 0
343
+ ts = nil
344
+ te = nil
345
+ act = 0
346
+ end
347
+
348
+ # line 280 "lib/liquor/grammar/lexer.rl"
349
+
350
+ # line 351 "lib/liquor/grammar/lexer.rb"
351
+ begin
352
+ _klen, _trans, _keys, _acts, _nacts = nil
353
+ _goto_level = 0
354
+ _resume = 10
355
+ _eof_trans = 15
356
+ _again = 20
357
+ _test_eof = 30
358
+ _out = 40
359
+ while true
360
+ _trigger_goto = false
361
+ if _goto_level <= 0
362
+ if p == pe
363
+ _goto_level = _test_eof
364
+ next
365
+ end
366
+ end
367
+ if _goto_level <= _resume
368
+ _acts = _liquor_from_state_actions[cs]
369
+ _nacts = _liquor_actions[_acts]
370
+ _acts += 1
371
+ while _nacts > 0
372
+ _nacts -= 1
373
+ _acts += 1
374
+ case _liquor_actions[_acts - 1]
375
+ when 4 then
376
+ # line 1 "NONE"
377
+ begin
378
+ ts = p
379
+ end
380
+ # line 381 "lib/liquor/grammar/lexer.rb"
381
+ end # from state action switch
382
+ end
383
+ if _trigger_goto
384
+ next
385
+ end
386
+ _keys = _liquor_key_offsets[cs]
387
+ _trans = _liquor_index_offsets[cs]
388
+ _klen = _liquor_single_lengths[cs]
389
+ _break_match = false
390
+
391
+ begin
392
+ if _klen > 0
393
+ _lower = _keys
394
+ _upper = _keys + _klen - 1
395
+
396
+ loop do
397
+ break if _upper < _lower
398
+ _mid = _lower + ( (_upper - _lower) >> 1 )
399
+
400
+ if data[p].ord < _liquor_trans_keys[_mid]
401
+ _upper = _mid - 1
402
+ elsif data[p].ord > _liquor_trans_keys[_mid]
403
+ _lower = _mid + 1
404
+ else
405
+ _trans += (_mid - _keys)
406
+ _break_match = true
407
+ break
408
+ end
409
+ end # loop
410
+ break if _break_match
411
+ _keys += _klen
412
+ _trans += _klen
413
+ end
414
+ _klen = _liquor_range_lengths[cs]
415
+ if _klen > 0
416
+ _lower = _keys
417
+ _upper = _keys + (_klen << 1) - 2
418
+ loop do
419
+ break if _upper < _lower
420
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
421
+ if data[p].ord < _liquor_trans_keys[_mid]
422
+ _upper = _mid - 2
423
+ elsif data[p].ord > _liquor_trans_keys[_mid+1]
424
+ _lower = _mid + 2
425
+ else
426
+ _trans += ((_mid - _keys) >> 1)
427
+ _break_match = true
428
+ break
429
+ end
430
+ end # loop
431
+ break if _break_match
432
+ _trans += _klen
433
+ end
434
+ end while false
435
+ _trans = _liquor_indicies[_trans]
436
+ end
437
+ if _goto_level <= _eof_trans
438
+ cs = _liquor_trans_targs[_trans]
439
+ if _liquor_trans_actions[_trans] != 0
440
+ _acts = _liquor_trans_actions[_trans]
441
+ _nacts = _liquor_actions[_acts]
442
+ _acts += 1
443
+ while _nacts > 0
444
+ _nacts -= 1
445
+ _acts += 1
446
+ case _liquor_actions[_acts - 1]
447
+ when 0 then
448
+ # line 5 "lib/liquor/grammar/lexer.rl"
449
+ begin
450
+
451
+ line_starts.push(p + 1)
452
+ end
453
+ when 2 then
454
+ # line 136 "lib/liquor/grammar/lexer.rl"
455
+ begin
456
+ kw_stop = p end
457
+ when 5 then
458
+ # line 1 "NONE"
459
+ begin
460
+ te = p+1
461
+ end
462
+ when 6 then
463
+ # line 54 "lib/liquor/grammar/lexer.rl"
464
+ begin
465
+ te = p+1
466
+ begin begin
467
+ stack[top] = cs
468
+ top+= 1
469
+ cs = 11
470
+ _trigger_goto = true
471
+ _goto_level = _again
472
+ break
473
+ end
474
+ end
475
+ end
476
+ when 7 then
477
+ # line 55 "lib/liquor/grammar/lexer.rl"
478
+ begin
479
+ te = p+1
480
+ begin begin
481
+ top -= 1
482
+ cs = stack[top]
483
+ _trigger_goto = true
484
+ _goto_level = _again
485
+ break
486
+ end
487
+ end
488
+ end
489
+ when 8 then
490
+ # line 56 "lib/liquor/grammar/lexer.rl"
491
+ begin
492
+ te = p+1
493
+ end
494
+ when 9 then
495
+ # line 56 "lib/liquor/grammar/lexer.rl"
496
+ begin
497
+ te = p
498
+ p = p - 1; end
499
+ when 10 then
500
+ # line 60 "lib/liquor/grammar/lexer.rl"
501
+ begin
502
+ te = p+1
503
+ begin string << '"' end
504
+ end
505
+ when 11 then
506
+ # line 61 "lib/liquor/grammar/lexer.rl"
507
+ begin
508
+ te = p+1
509
+ begin string << '\\' end
510
+ end
511
+ when 12 then
512
+ # line 27 "lib/liquor/grammar/lexer.rl"
513
+ begin
514
+ te = p+1
515
+ begin
516
+ tok.(:string, string.dup, ts: str_start)
517
+ string.clear
518
+ begin
519
+ cs = 27
520
+ _trigger_goto = true
521
+ _goto_level = _again
522
+ break
523
+ end
524
+
525
+ end
526
+ end
527
+ when 13 then
528
+ # line 23 "lib/liquor/grammar/lexer.rl"
529
+ begin
530
+ te = p+1
531
+ begin
532
+ string << data[p]
533
+ end
534
+ end
535
+ when 14 then
536
+ # line 37 "lib/liquor/grammar/lexer.rl"
537
+ begin
538
+ te = p+1
539
+ begin
540
+ symbol = data[p]
541
+ if symbol == "\n"
542
+ symbol = "end of line"
543
+ else
544
+ symbol = "`#{symbol.inspect[1..-2]}'"
545
+ end
546
+
547
+ error = SyntaxError.new("unexpected #{symbol}",
548
+ file: name,
549
+ line: line_starts.count - 1,
550
+ start: p - line_starts.last,
551
+ end: p - line_starts.last)
552
+ raise error
553
+ end
554
+ end
555
+ when 15 then
556
+ # line 23 "lib/liquor/grammar/lexer.rl"
557
+ begin
558
+ te = p
559
+ p = p - 1; begin
560
+ string << data[p]
561
+ end
562
+ end
563
+ when 16 then
564
+ # line 69 "lib/liquor/grammar/lexer.rl"
565
+ begin
566
+ te = p+1
567
+ begin string << "'" end
568
+ end
569
+ when 17 then
570
+ # line 70 "lib/liquor/grammar/lexer.rl"
571
+ begin
572
+ te = p+1
573
+ begin string << '\\' end
574
+ end
575
+ when 18 then
576
+ # line 27 "lib/liquor/grammar/lexer.rl"
577
+ begin
578
+ te = p+1
579
+ begin
580
+ tok.(:string, string.dup, ts: str_start)
581
+ string.clear
582
+ begin
583
+ cs = 27
584
+ _trigger_goto = true
585
+ _goto_level = _again
586
+ break
587
+ end
588
+
589
+ end
590
+ end
591
+ when 19 then
592
+ # line 23 "lib/liquor/grammar/lexer.rl"
593
+ begin
594
+ te = p+1
595
+ begin
596
+ string << data[p]
597
+ end
598
+ end
599
+ when 20 then
600
+ # line 37 "lib/liquor/grammar/lexer.rl"
601
+ begin
602
+ te = p+1
603
+ begin
604
+ symbol = data[p]
605
+ if symbol == "\n"
606
+ symbol = "end of line"
607
+ else
608
+ symbol = "`#{symbol.inspect[1..-2]}'"
609
+ end
610
+
611
+ error = SyntaxError.new("unexpected #{symbol}",
612
+ file: name,
613
+ line: line_starts.count - 1,
614
+ start: p - line_starts.last,
615
+ end: p - line_starts.last)
616
+ raise error
617
+ end
618
+ end
619
+ when 21 then
620
+ # line 23 "lib/liquor/grammar/lexer.rl"
621
+ begin
622
+ te = p
623
+ p = p - 1; begin
624
+ string << data[p]
625
+ end
626
+ end
627
+ when 22 then
628
+ # line 37 "lib/liquor/grammar/lexer.rl"
629
+ begin
630
+ te = p+1
631
+ begin
632
+ symbol = data[p]
633
+ if symbol == "\n"
634
+ symbol = "end of line"
635
+ else
636
+ symbol = "`#{symbol.inspect[1..-2]}'"
637
+ end
638
+
639
+ error = SyntaxError.new("unexpected #{symbol}",
640
+ file: name,
641
+ line: line_starts.count - 1,
642
+ start: p - line_starts.last,
643
+ end: p - line_starts.last)
644
+ raise error
645
+ end
646
+ end
647
+ when 23 then
648
+ # line 80 "lib/liquor/grammar/lexer.rl"
649
+ begin
650
+ te = p+1
651
+ begin p = p - 1; begin
652
+ cs = 27
653
+ _trigger_goto = true
654
+ _goto_level = _again
655
+ break
656
+ end
657
+ end
658
+ end
659
+ when 24 then
660
+ # line 78 "lib/liquor/grammar/lexer.rl"
661
+ begin
662
+ te = p
663
+ p = p - 1; begin tok.(:integer, data[ts...te].to_i) end
664
+ end
665
+ when 25 then
666
+ # line 105 "lib/liquor/grammar/lexer.rl"
667
+ begin
668
+ te = p+1
669
+ begin fixtok.(:lblock2)
670
+ tok.(:keyword, data[ts...te - 1])
671
+ begin
672
+ cs = 27
673
+ _trigger_goto = true
674
+ _goto_level = _again
675
+ break
676
+ end
677
+
678
+ end
679
+ end
680
+ when 26 then
681
+ # line 126 "lib/liquor/grammar/lexer.rl"
682
+ begin
683
+ te = p+1
684
+ begin p = p - 1; begin
685
+ cs = 27
686
+ _trigger_goto = true
687
+ _goto_level = _again
688
+ break
689
+ end
690
+ end
691
+ end
692
+ when 27 then
693
+ # line 84 "lib/liquor/grammar/lexer.rl"
694
+ begin
695
+ te = p
696
+ p = p - 1; end
697
+ when 28 then
698
+ # line 87 "lib/liquor/grammar/lexer.rl"
699
+ begin
700
+ te = p
701
+ p = p - 1; begin tag = data[ts + 4...te]
702
+ if tag_stack.last == tag
703
+ fixtok.(:lblock2)
704
+ tok.(:endtag)
705
+ pop_tag.()
706
+ else
707
+ (sl, sc), (el, ec) = loc.(ts), loc.(te - 1)
708
+ info = { file: name, line: sl, start: sc, end: ec }
709
+ if tag_stack.any?
710
+ raise SyntaxError.new("unmatched `end #{tag}', expected `end #{tag_stack.last}'", info)
711
+ else
712
+ raise SyntaxError.new("unexpected `end #{tag}'", info)
713
+ end
714
+ end
715
+ begin
716
+ cs = 27
717
+ _trigger_goto = true
718
+ _goto_level = _again
719
+ break
720
+ end
721
+
722
+ end
723
+ end
724
+ when 29 then
725
+ # line 111 "lib/liquor/grammar/lexer.rl"
726
+ begin
727
+ te = p
728
+ p = p - 1; begin tag = data[ts...te]
729
+
730
+ if tag_conts.include? tag
731
+ fixtok.(:lblock2)
732
+ tok.(:keyword, tag)
733
+ begin
734
+ cs = 27
735
+ _trigger_goto = true
736
+ _goto_level = _again
737
+ break
738
+ end
739
+
740
+ end
741
+
742
+ tok.(:ident, tag)
743
+ last_tag = tag
744
+
745
+ begin
746
+ cs = 27
747
+ _trigger_goto = true
748
+ _goto_level = _again
749
+ break
750
+ end
751
+
752
+ end
753
+ end
754
+ when 30 then
755
+ # line 111 "lib/liquor/grammar/lexer.rl"
756
+ begin
757
+ begin p = ((te))-1; end
758
+ begin tag = data[ts...te]
759
+
760
+ if tag_conts.include? tag
761
+ fixtok.(:lblock2)
762
+ tok.(:keyword, tag)
763
+ begin
764
+ cs = 27
765
+ _trigger_goto = true
766
+ _goto_level = _again
767
+ break
768
+ end
769
+
770
+ end
771
+
772
+ tok.(:ident, tag)
773
+ last_tag = tag
774
+
775
+ begin
776
+ cs = 27
777
+ _trigger_goto = true
778
+ _goto_level = _again
779
+ break
780
+ end
781
+
782
+ end
783
+ end
784
+ when 31 then
785
+ # line 134 "lib/liquor/grammar/lexer.rl"
786
+ begin
787
+ te = p+1
788
+ begin p = p - 1; begin
789
+ cs = 18
790
+ _trigger_goto = true
791
+ _goto_level = _again
792
+ break
793
+ end
794
+ end
795
+ end
796
+ when 32 then
797
+ # line 137 "lib/liquor/grammar/lexer.rl"
798
+ begin
799
+ te = p+1
800
+ begin tok.(:keyword, data[ts...kw_stop], te: kw_stop)
801
+ tok.(:rblock, nil, ts: te - 2)
802
+ push_last_tag.()
803
+ begin
804
+ cs = 6
805
+ _trigger_goto = true
806
+ _goto_level = _again
807
+ break
808
+ end
809
+
810
+ end
811
+ end
812
+ when 33 then
813
+ # line 147 "lib/liquor/grammar/lexer.rl"
814
+ begin
815
+ te = p+1
816
+ begin
817
+ tok.(:keyword, '=', te: ts + 1)
818
+ tok.(:rblock, nil, ts: te - 2)
819
+ push_last_tag.()
820
+ begin
821
+ cs = 6
822
+ _trigger_goto = true
823
+ _goto_level = _again
824
+ break
825
+ end
826
+
827
+ end
828
+ end
829
+ when 34 then
830
+ # line 157 "lib/liquor/grammar/lexer.rl"
831
+ begin
832
+ te = p+1
833
+ begin tok.(:comma) end
834
+ end
835
+ when 35 then
836
+ # line 158 "lib/liquor/grammar/lexer.rl"
837
+ begin
838
+ te = p+1
839
+ begin tok.(:dot) end
840
+ end
841
+ when 36 then
842
+ # line 160 "lib/liquor/grammar/lexer.rl"
843
+ begin
844
+ te = p+1
845
+ begin tok.(:lbracket) end
846
+ end
847
+ when 37 then
848
+ # line 161 "lib/liquor/grammar/lexer.rl"
849
+ begin
850
+ te = p+1
851
+ begin tok.(:rbracket) end
852
+ end
853
+ when 38 then
854
+ # line 163 "lib/liquor/grammar/lexer.rl"
855
+ begin
856
+ te = p+1
857
+ begin tok.(:lparen) end
858
+ end
859
+ when 39 then
860
+ # line 164 "lib/liquor/grammar/lexer.rl"
861
+ begin
862
+ te = p+1
863
+ begin tok.(:rparen) end
864
+ end
865
+ when 40 then
866
+ # line 168 "lib/liquor/grammar/lexer.rl"
867
+ begin
868
+ te = p+1
869
+ begin tok.(:op_plus) end
870
+ end
871
+ when 41 then
872
+ # line 169 "lib/liquor/grammar/lexer.rl"
873
+ begin
874
+ te = p+1
875
+ begin tok.(:op_minus) end
876
+ end
877
+ when 42 then
878
+ # line 170 "lib/liquor/grammar/lexer.rl"
879
+ begin
880
+ te = p+1
881
+ begin tok.(:op_mul) end
882
+ end
883
+ when 43 then
884
+ # line 171 "lib/liquor/grammar/lexer.rl"
885
+ begin
886
+ te = p+1
887
+ begin tok.(:op_div) end
888
+ end
889
+ when 44 then
890
+ # line 174 "lib/liquor/grammar/lexer.rl"
891
+ begin
892
+ te = p+1
893
+ begin tok.(:op_eq) end
894
+ end
895
+ when 45 then
896
+ # line 175 "lib/liquor/grammar/lexer.rl"
897
+ begin
898
+ te = p+1
899
+ begin tok.(:op_neq) end
900
+ end
901
+ when 46 then
902
+ # line 177 "lib/liquor/grammar/lexer.rl"
903
+ begin
904
+ te = p+1
905
+ begin tok.(:op_geq) end
906
+ end
907
+ when 47 then
908
+ # line 179 "lib/liquor/grammar/lexer.rl"
909
+ begin
910
+ te = p+1
911
+ begin tok.(:op_leq) end
912
+ end
913
+ when 48 then
914
+ # line 183 "lib/liquor/grammar/lexer.rl"
915
+ begin
916
+ te = p+1
917
+ begin tok.(:op_and) end
918
+ end
919
+ when 49 then
920
+ # line 184 "lib/liquor/grammar/lexer.rl"
921
+ begin
922
+ te = p+1
923
+ begin tok.(:op_or) end
924
+ end
925
+ when 50 then
926
+ # line 186 "lib/liquor/grammar/lexer.rl"
927
+ begin
928
+ te = p+1
929
+ begin str_start = p; begin
930
+ cs = 14
931
+ _trigger_goto = true
932
+ _goto_level = _again
933
+ break
934
+ end
935
+ end
936
+ end
937
+ when 51 then
938
+ # line 187 "lib/liquor/grammar/lexer.rl"
939
+ begin
940
+ te = p+1
941
+ begin str_start = p; begin
942
+ cs = 16
943
+ _trigger_goto = true
944
+ _goto_level = _again
945
+ break
946
+ end
947
+ end
948
+ end
949
+ when 52 then
950
+ # line 189 "lib/liquor/grammar/lexer.rl"
951
+ begin
952
+ te = p+1
953
+ begin tok.(:rinterp); begin
954
+ cs = 6
955
+ _trigger_goto = true
956
+ _goto_level = _again
957
+ break
958
+ end
959
+ end
960
+ end
961
+ when 53 then
962
+ # line 190 "lib/liquor/grammar/lexer.rl"
963
+ begin
964
+ te = p+1
965
+ begin tok.(:rblock); last_tag = nil; begin
966
+ cs = 6
967
+ _trigger_goto = true
968
+ _goto_level = _again
969
+ break
970
+ end
971
+ end
972
+ end
973
+ when 54 then
974
+ # line 37 "lib/liquor/grammar/lexer.rl"
975
+ begin
976
+ te = p+1
977
+ begin
978
+ symbol = data[p]
979
+ if symbol == "\n"
980
+ symbol = "end of line"
981
+ else
982
+ symbol = "`#{symbol.inspect[1..-2]}'"
983
+ end
984
+
985
+ error = SyntaxError.new("unexpected #{symbol}",
986
+ file: name,
987
+ line: line_starts.count - 1,
988
+ start: p - line_starts.last,
989
+ end: p - line_starts.last)
990
+ raise error
991
+ end
992
+ end
993
+ when 55 then
994
+ # line 130 "lib/liquor/grammar/lexer.rl"
995
+ begin
996
+ te = p
997
+ p = p - 1; end
998
+ when 56 then
999
+ # line 132 "lib/liquor/grammar/lexer.rl"
1000
+ begin
1001
+ te = p
1002
+ p = p - 1; begin tok.(:ident, data[ts...te]) end
1003
+ end
1004
+ when 57 then
1005
+ # line 144 "lib/liquor/grammar/lexer.rl"
1006
+ begin
1007
+ te = p
1008
+ p = p - 1; begin tok.(:keyword, data[ts...te-1]) end
1009
+ end
1010
+ when 58 then
1011
+ # line 155 "lib/liquor/grammar/lexer.rl"
1012
+ begin
1013
+ te = p
1014
+ p = p - 1; begin tok.(:keyword, '=') end
1015
+ end
1016
+ when 59 then
1017
+ # line 166 "lib/liquor/grammar/lexer.rl"
1018
+ begin
1019
+ te = p
1020
+ p = p - 1; begin tok.(:pipe) end
1021
+ end
1022
+ when 60 then
1023
+ # line 172 "lib/liquor/grammar/lexer.rl"
1024
+ begin
1025
+ te = p
1026
+ p = p - 1; begin tok.(:op_mod) end
1027
+ end
1028
+ when 61 then
1029
+ # line 176 "lib/liquor/grammar/lexer.rl"
1030
+ begin
1031
+ te = p
1032
+ p = p - 1; begin tok.(:op_gt) end
1033
+ end
1034
+ when 62 then
1035
+ # line 178 "lib/liquor/grammar/lexer.rl"
1036
+ begin
1037
+ te = p
1038
+ p = p - 1; begin tok.(:op_lt) end
1039
+ end
1040
+ when 63 then
1041
+ # line 181 "lib/liquor/grammar/lexer.rl"
1042
+ begin
1043
+ te = p
1044
+ p = p - 1; begin tok.(:op_not) end
1045
+ end
1046
+ when 64 then
1047
+ # line 37 "lib/liquor/grammar/lexer.rl"
1048
+ begin
1049
+ te = p
1050
+ p = p - 1; begin
1051
+ symbol = data[p]
1052
+ if symbol == "\n"
1053
+ symbol = "end of line"
1054
+ else
1055
+ symbol = "`#{symbol.inspect[1..-2]}'"
1056
+ end
1057
+
1058
+ error = SyntaxError.new("unexpected #{symbol}",
1059
+ file: name,
1060
+ line: line_starts.count - 1,
1061
+ start: p - line_starts.last,
1062
+ end: p - line_starts.last)
1063
+ raise error
1064
+ end
1065
+ end
1066
+ when 65 then
1067
+ # line 144 "lib/liquor/grammar/lexer.rl"
1068
+ begin
1069
+ begin p = ((te))-1; end
1070
+ begin tok.(:keyword, data[ts...te-1]) end
1071
+ end
1072
+ when 66 then
1073
+ # line 155 "lib/liquor/grammar/lexer.rl"
1074
+ begin
1075
+ begin p = ((te))-1; end
1076
+ begin tok.(:keyword, '=') end
1077
+ end
1078
+ when 67 then
1079
+ # line 200 "lib/liquor/grammar/lexer.rl"
1080
+ begin
1081
+ te = p+1
1082
+ begin tok.(:linterp); begin
1083
+ cs = 27
1084
+ _trigger_goto = true
1085
+ _goto_level = _again
1086
+ break
1087
+ end
1088
+ end
1089
+ end
1090
+ when 68 then
1091
+ # line 203 "lib/liquor/grammar/lexer.rl"
1092
+ begin
1093
+ te = p+1
1094
+ begin tok.(:lblock); begin
1095
+ cs = 20
1096
+ _trigger_goto = true
1097
+ _goto_level = _again
1098
+ break
1099
+ end
1100
+ end
1101
+ end
1102
+ when 69 then
1103
+ # line 206 "lib/liquor/grammar/lexer.rl"
1104
+ begin
1105
+ te = p+1
1106
+ begin begin
1107
+ stack[top] = cs
1108
+ top+= 1
1109
+ cs = 11
1110
+ _trigger_goto = true
1111
+ _goto_level = _again
1112
+ break
1113
+ end
1114
+ end
1115
+ end
1116
+ when 70 then
1117
+ # line 197 "lib/liquor/grammar/lexer.rl"
1118
+ begin
1119
+ te = p
1120
+ p = p - 1; begin tok.(:plaintext, data[ts...te]); end
1121
+ end
1122
+ when 71 then
1123
+ # line 209 "lib/liquor/grammar/lexer.rl"
1124
+ begin
1125
+ te = p
1126
+ p = p - 1; begin p = p - 1; begin
1127
+ cs = 27
1128
+ _trigger_goto = true
1129
+ _goto_level = _again
1130
+ break
1131
+ end
1132
+ end
1133
+ end
1134
+ when 72 then
1135
+ # line 197 "lib/liquor/grammar/lexer.rl"
1136
+ begin
1137
+ begin p = ((te))-1; end
1138
+ begin tok.(:plaintext, data[ts...te]); end
1139
+ end
1140
+ # line 1141 "lib/liquor/grammar/lexer.rb"
1141
+ end # action switch
1142
+ end
1143
+ end
1144
+ if _trigger_goto
1145
+ next
1146
+ end
1147
+ end
1148
+ if _goto_level <= _again
1149
+ _acts = _liquor_to_state_actions[cs]
1150
+ _nacts = _liquor_actions[_acts]
1151
+ _acts += 1
1152
+ while _nacts > 0
1153
+ _nacts -= 1
1154
+ _acts += 1
1155
+ case _liquor_actions[_acts - 1]
1156
+ when 3 then
1157
+ # line 1 "NONE"
1158
+ begin
1159
+ ts = nil; end
1160
+ # line 1161 "lib/liquor/grammar/lexer.rb"
1161
+ end # to state action switch
1162
+ end
1163
+ if _trigger_goto
1164
+ next
1165
+ end
1166
+ p += 1
1167
+ if p != pe
1168
+ _goto_level = _resume
1169
+ next
1170
+ end
1171
+ end
1172
+ if _goto_level <= _test_eof
1173
+ if p == eof
1174
+ if _liquor_eof_trans[cs] > 0
1175
+ _trans = _liquor_eof_trans[cs] - 1;
1176
+ _goto_level = _eof_trans
1177
+ next;
1178
+ end
1179
+ __acts = _liquor_eof_actions[cs]
1180
+ __nacts = _liquor_actions[__acts]
1181
+ __acts += 1
1182
+ while __nacts > 0
1183
+ __nacts -= 1
1184
+ __acts += 1
1185
+ case _liquor_actions[__acts - 1]
1186
+ when 1 then
1187
+ # line 33 "lib/liquor/grammar/lexer.rl"
1188
+ begin
1189
+
1190
+ runaway = true
1191
+ end
1192
+ # line 1193 "lib/liquor/grammar/lexer.rb"
1193
+ end # eof action switch
1194
+ end
1195
+ if _trigger_goto
1196
+ next
1197
+ end
1198
+ end
1199
+ end
1200
+ if _goto_level <= _out
1201
+ break
1202
+ end
1203
+ end
1204
+ end
1205
+
1206
+ # line 281 "lib/liquor/grammar/lexer.rl"
1207
+
1208
+ if runaway
1209
+ line_start_index = find_line_start.(str_start)
1210
+ line_start = line_starts[line_start_index]
1211
+
1212
+ error = SyntaxError.new("literal not terminated",
1213
+ file: name,
1214
+ line: line_start_index,
1215
+ start: str_start - line_start,
1216
+ end: str_start - line_start)
1217
+ raise error
1218
+ end
1219
+
1220
+ tokens
1221
+ end
1222
+ end
1223
+ end