liquidscript 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liquidscript/compiler/icr/expressions.rb +28 -45
- data/lib/liquidscript/compiler/icr/groups.rb +1 -2
- data/lib/liquidscript/compiler/icr/helpers.rb +9 -0
- data/lib/liquidscript/compiler/icr/literals.rb +3 -6
- data/lib/liquidscript/generator/javascript/literals.rb +2 -3
- data/lib/liquidscript/generator/javascript/objects.rb +1 -1
- data/lib/liquidscript/scanner/liquidscript/main.rb +4 -4
- data/lib/liquidscript/version.rb +1 -1
- data/spec/fixtures/expression.generate.yml +4 -1
- data/spec/fixtures/literals.generate.yml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b457cb6e151caa8e4c94e6c6f6155a6d4fab540d
|
4
|
+
data.tar.gz: 2593be00faad038c0c2d17d5457ccadd1c9b2bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1147b9665936ae2f33b883d189a5ba9aee3c758e084fcb4a929cad9bfe5e3cfa0ad3c880f20ca21176751b9646e8622c7fb34e9800e89e4ec533567b41a4a51e
|
7
|
+
data.tar.gz: bf1684054f962f5d6ef81b553ec83d5d3995f6ef814ede497d54d53b61fe091f4b5cf33844ab1eed930f57704ecdf9c4a807559f2c59628f3cea32344a490fdf
|
@@ -90,61 +90,44 @@ module Liquidscript
|
|
90
90
|
# @return [ICR::Code]
|
91
91
|
def compile_lparen
|
92
92
|
shift :lparen
|
93
|
-
maybe_func = 1
|
94
|
-
components = []
|
95
93
|
|
96
|
-
|
97
|
-
|
94
|
+
if peek?(:identifier)
|
95
|
+
_compile_lparen_method
|
96
|
+
elsif peek?(:rparen)
|
97
|
+
_compile_lparen_method_final
|
98
|
+
else
|
99
|
+
_compile_lparen_expression
|
98
100
|
end
|
101
|
+
end
|
99
102
|
|
100
|
-
|
101
|
-
|
102
|
-
components << compile_vexpression
|
103
|
-
end
|
103
|
+
def _compile_lparen_method
|
104
|
+
ident = shift :identifier
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
elsif peek?(:rparen)
|
110
|
-
components << i
|
111
|
-
else
|
112
|
-
components << value_expect(compile_identifier(i))
|
113
|
-
end
|
106
|
+
if peek?(:comma, :rparen)
|
107
|
+
_compile_lparen_method_final(ident)
|
108
|
+
else
|
109
|
+
value_expect(ident)
|
114
110
|
end
|
111
|
+
end
|
115
112
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
expect :rparen => action.end_loop,
|
123
|
-
:comma => action { maybe_func = 2 },
|
124
|
-
:identifier => ident,
|
125
|
-
:_ => expression
|
126
|
-
when 2
|
127
|
-
expect :rparen => action.end_loop,
|
128
|
-
:comma => action.shift,
|
129
|
-
:identifier => action { |i| components << i }
|
130
|
-
end
|
113
|
+
def _compile_lparen_method_final(ident = nil)
|
114
|
+
components = [ident].compact
|
115
|
+
|
116
|
+
while peek?(:comma) do
|
117
|
+
shift(:comma)
|
118
|
+
components << shift(:identifier)
|
131
119
|
end
|
132
120
|
|
133
|
-
|
134
|
-
|
121
|
+
shift :rparen
|
122
|
+
compile_function_with_parameters(components)
|
123
|
+
end
|
135
124
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
if c.is_a?(Scanner::Token)
|
141
|
-
compile_identifier(c)
|
142
|
-
else
|
143
|
-
c
|
144
|
-
end
|
145
|
-
end)
|
146
|
-
end
|
125
|
+
def _compile_lparen_expression
|
126
|
+
out = compile_vexpression
|
127
|
+
shift :rparen
|
128
|
+
code :expression, out
|
147
129
|
end
|
130
|
+
|
148
131
|
end
|
149
132
|
end
|
150
133
|
end
|
@@ -15,6 +15,15 @@ module Liquidscript
|
|
15
15
|
Liquidscript::ICR::Code.new type, *args
|
16
16
|
end
|
17
17
|
|
18
|
+
def _compile_block
|
19
|
+
if peek?(:lbrace)
|
20
|
+
shift :lbrace
|
21
|
+
collect_compiles(:expression, :rbrace)
|
22
|
+
else
|
23
|
+
compile_expression
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
18
27
|
def value_expect(v, &default)
|
19
28
|
out = expect \
|
20
29
|
:lparen => action { compile_call(v) },
|
@@ -16,8 +16,7 @@ module Liquidscript
|
|
16
16
|
shift :lparen
|
17
17
|
conditional = compile_vexpression
|
18
18
|
shift :rparen
|
19
|
-
|
20
|
-
body = collect_compiles(:expression, :rbrace)
|
19
|
+
body = _compile_block
|
21
20
|
code :while, conditional, body
|
22
21
|
end
|
23
22
|
|
@@ -44,10 +43,9 @@ module Liquidscript
|
|
44
43
|
|
45
44
|
obj = shift :identifier
|
46
45
|
shift :rparen
|
47
|
-
shift :lbrace
|
48
46
|
|
49
47
|
set ident
|
50
|
-
body =
|
48
|
+
body = _compile_block
|
51
49
|
code :for_in, ident, ref(obj), body
|
52
50
|
end
|
53
51
|
|
@@ -58,9 +56,8 @@ module Liquidscript
|
|
58
56
|
shift :comma
|
59
57
|
third = compile_vexpression
|
60
58
|
shift :rparen
|
61
|
-
shift :lbrace
|
62
59
|
|
63
|
-
body =
|
60
|
+
body = _compile_block
|
64
61
|
code :for_seg, first, second, third, body
|
65
62
|
end
|
66
63
|
|
@@ -136,11 +136,10 @@ module Liquidscript
|
|
136
136
|
def generate_object(code)
|
137
137
|
|
138
138
|
object = buffer
|
139
|
-
object.set_join!
|
140
|
-
indent!
|
139
|
+
object.set_join! ",\n#{indent!}"
|
141
140
|
|
142
141
|
code[1].inject(object) do |buf, part|
|
143
|
-
buf << "
|
142
|
+
buf << "\"#{part[0].value}\": #{replace(part[1])}"
|
144
143
|
end
|
145
144
|
|
146
145
|
unindent!
|
@@ -107,14 +107,14 @@ module Liquidscript
|
|
107
107
|
on(:string) { |m| emit :sstring, m }
|
108
108
|
on(:keywords) { |m| emit :keyword, m }
|
109
109
|
on(:actions) { |m| emit :action, m }
|
110
|
+
on(:binops) { |m| emit :binop, m }
|
111
|
+
on(:preunops) { |m| emit :preunop, m }
|
112
|
+
on(:unops) { |m| emit :unop, m }
|
110
113
|
on(%r{<<([A-Z]+)}, :heredoc)
|
111
114
|
on(%r{<<-([A-Z]+)}, :iheredoc)
|
112
|
-
on(%r{/(.*?)/([
|
115
|
+
on(%r{r/(.*?)/([gimy]*)}, :regex)
|
113
116
|
on(%r{"} => :istring)
|
114
117
|
on("///" => :block_regex)
|
115
|
-
on(:binops) { |m| emit :binop, m }
|
116
|
-
on(:preunops) { |m| emit :preunop, m }
|
117
|
-
on(:unops) { |m| emit :unop, m }
|
118
118
|
on("->") { emit :arrow }
|
119
119
|
on("=") { emit :equal }
|
120
120
|
on("{") { emit :lbrace }
|
data/lib/liquidscript/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquidscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|