lib/liquidscript/scanner/liquidscript.rb in liquidscript-0.6.1 vs lib/liquidscript/scanner/liquidscript.rb in liquidscript-0.6.2
- old
+ new
@@ -9,13 +9,13 @@
define do
default_context :main
context :main do
set :number, %r{
- -? [1-9][0-9]* # the base of the number
- (\.[0-9]+)? # decmial portion, if needed
- ([eE][+-]?[0-9]+)? # scientific notation
+ -? ([1-9][0-9]* | 0) # the base of the number
+ (\.[0-9]+)? # decmial portion, if needed
+ ([eE][+-]?[0-9]+)? # scientific notation
}x
set :string, %r{
'
[A-Za-z0-9_$\-]+
@@ -37,16 +37,16 @@
break
continue
)
set :binops, %w(
- + - * / ^
+ * / ^
<< >> >>>
- == ===
- != !==
- > >=
- < <=
+ === ==
+ !== !=
+ >= >
+ <= <
&& ||
& |
instanceof
or and
)
@@ -84,10 +84,12 @@
on(")") { emit :rparen }
on("]") { emit :rbrack }
on(":") { emit :colon }
on(".") { emit :prop }
on(",") { emit :comma }
+ on("-") { emit :minus }
+ on("+") { emit :plus }
on("\n") { line! }
on(%r{"} => :istring)
on(%r{<<([A-Z]+)}) do |_, s|
emit :heredoc_ref, s
@lexes << [:heredoc, s]
@@ -101,9 +103,15 @@
}
on("///" => :block_regex)
on(:binops) { |m| emit :binop, m }
on(:unops) { |m| emit :unop, m }
on(:identifier) { |m| emit :identifier, m }
+
+ on(%r{#! ([A-Za-z]+) ?(.*?)\n}) do |_, c, a|
+ metadata[:directives] ||= []
+ metadata[:directives].push :command => c,
+ :args => a
+ end
on(%r{#.*?\n}) { }
on(%r{\s}) { }
on(:_) { |m| error }
end