liquidscript 0.7.0 → 0.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee4e04ff0fb7e70cc829b24f939b5dc3818876de
4
- data.tar.gz: df98980cc63c5f2913684363eb897972d53dc59a
3
+ metadata.gz: 32708208fcf1f212c031c3d7e843219653887748
4
+ data.tar.gz: 8bf0b59774f62cdcaf18fc130cbbc8723311627e
5
5
  SHA512:
6
- metadata.gz: e9a16921b5902920a3f5bab535fb597f7076d9d441daf504ae19c5536fa76d4aaa866876440711abccf355f3225df1e2a5e80ad7fe787f04cdf94032e4196ec2
7
- data.tar.gz: 1eae537900f300cdeb2a58db4a9aa6dc000dc75d1d555a78e0f8c69f5a5291954df851f1b5c623199fb135677735539a12aef07d1073f0c10fa3d138169f7b63
6
+ metadata.gz: 48960e3bcdea3d27a3c4bf0b5e3e182b4e2f4d0731c4cffeba7eba89a1e8cd3202663d4a45b49f825edd467db704080f38e0e544b062f03c1b816f0cbad863c8
7
+ data.tar.gz: 9c60166e3f63e8b96f3d7c055b86e037b17d955b7182da3be656f10d8be5405df98c83b0f83af10c7cf49e74710cd34d54b9718a5b6f1e21c9905e4df52fea3a
@@ -19,7 +19,7 @@ module Liquidscript
19
19
  out = expect :number, :identifier,
20
20
  :istring, :lparen,
21
21
  :sstring, :operator,
22
- :keyword, :unop,
22
+ :keyword,
23
23
  :regex,
24
24
  :newline,
25
25
  :istring_begin,
@@ -28,6 +28,9 @@ module Liquidscript
28
28
  :lbrace => :object,
29
29
  :lbrack => :array,
30
30
  :arrow => :function,
31
+ [
32
+ :preunop, :unop
33
+ ] => :unop,
31
34
  [
32
35
  :heredoc_ref, :iheredoc_ref
33
36
  ] => :href,
@@ -56,7 +59,7 @@ module Liquidscript
56
59
  end
57
60
 
58
61
  def compile_unop
59
- code :unop, shift(:unop), compile_vexpression
62
+ code :unop, shift(:unop, :preunop), compile_vexpression
60
63
  end
61
64
 
62
65
  # Handles an assignment of the form `identifier = expression`,
@@ -23,9 +23,12 @@ module Liquidscript
23
23
  }x
24
24
 
25
25
  set :unops, %w(
26
- !
27
26
  ++
28
27
  --
28
+ )
29
+
30
+ set :preunops, %w(
31
+ !
29
32
  ~
30
33
  new
31
34
  return
@@ -74,7 +77,7 @@ module Liquidscript
74
77
  on(:number) { |m| emit :number, m }
75
78
  on(:string) { |m| emit :sstring, m }
76
79
  on(:keywords) { |m| emit :keyword, m }
77
- on(:actions) { |m| emit :action, m }
80
+ on(:actions) { |m| emit :action, m }
78
81
  on("->") { emit :arrow }
79
82
  on("=") { emit :equal }
80
83
  on("{") { emit :lbrace }
@@ -102,9 +105,11 @@ module Liquidscript
102
105
  emit :regex, [m, b]
103
106
  }
104
107
  on("///" => :block_regex)
105
- on(:binops) { |m| emit :binop, m }
106
- on(:unops) { |m| emit :unop, m }
107
- on(:identifier) { |m| emit :identifier, m.gsub(/\-[a-z]/) { |m| m[1].upcase } }
108
+ on(:binops) { |m| emit :binop, m }
109
+ on(:preunops) { |m| emit :preunop, m }
110
+ on(:unops) { |m| emit :unop, m }
111
+
112
+ on(:identifier) { |m| emit :identifier, m.gsub(/\-[a-z]/) { |p| p[1].upcase } }
108
113
 
109
114
  on(%r{#! ([A-Za-z]+) ?(.*?)\n}) do |_, c, a|
110
115
  metadata[:directives] ||= []
@@ -1,5 +1,5 @@
1
1
  module Liquidscript
2
2
 
3
3
  # The current version of liquidscript.
4
- VERSION = "0.7.0".freeze
4
+ VERSION = "0.7.1".freeze
5
5
  end
@@ -0,0 +1,40 @@
1
+ data: |
2
+ class Greeter {
3
+ initialize: (name)-> {
4
+ this.name = name
5
+ }
6
+
7
+ greet: -> {
8
+ console.log("Hello #{this.name}!")
9
+ }
10
+
11
+ this.meet: (first, second)-> {
12
+ new Greeter(first).greet()
13
+ new Greeter(second).greet()
14
+ }
15
+ }
16
+
17
+ Greeter.meet("Alice", "Bob")
18
+
19
+ compiled: |
20
+ var Greeter;
21
+ Greeter = Greeter || function Greeter() {
22
+ if(this.initialize) {
23
+ this.initialize.apply(this, arguments);
24
+ }
25
+ }
26
+
27
+ Greeter.prototype.initialize = function(name) {
28
+ this.name = name;
29
+ };
30
+
31
+ Greeter.prototype.greet = function() {
32
+ console.log("Hello " + (this.name) + "!");
33
+ };
34
+
35
+ Greeter.meet = function(first, second) {
36
+ new Greeter(first).greet();
37
+ new Greeter(second).greet();
38
+ };;
39
+
40
+ Greeter.meet("Alice", "Bob");
@@ -45,10 +45,10 @@ describe Liquidscript::Scanner::Liquidscript, :lexer_helper do
45
45
 
46
46
  it "scans keywords" do
47
47
  scan("return test = new foo").should eq [
48
- [:unop, "return"],
48
+ [:preunop, "return"],
49
49
  [:identifier, "test"],
50
50
  [:equal, nil],
51
- [:unop, "new"],
51
+ [:preunop, "new"],
52
52
  [:identifier, "foo"]
53
53
  ]
54
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquidscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Rodi
@@ -160,6 +160,7 @@ files:
160
160
  - spec/fixtures/class.generate.yml
161
161
  - spec/fixtures/combination.generate.yml
162
162
  - spec/fixtures/complex.generate.yml
163
+ - spec/fixtures/example.generate.yml
163
164
  - spec/fixtures/expression.generate.yml
164
165
  - spec/fixtures/function.generate.yml
165
166
  - spec/fixtures/get.generate.yml
@@ -219,6 +220,7 @@ test_files:
219
220
  - spec/fixtures/class.generate.yml
220
221
  - spec/fixtures/combination.generate.yml
221
222
  - spec/fixtures/complex.generate.yml
223
+ - spec/fixtures/example.generate.yml
222
224
  - spec/fixtures/expression.generate.yml
223
225
  - spec/fixtures/function.generate.yml
224
226
  - spec/fixtures/get.generate.yml