sardonyx 0.1.85 → 0.1.841

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
  SHA256:
3
- metadata.gz: 8c24e6115400ff31393984b7220c4226ea6f6a4fc8f9ba146f8d9f3ce51f749b
4
- data.tar.gz: e1b92b4d17872047f11fe869d988370898dbebc74f5fe2ba4cb5e8d0ede648ec
3
+ metadata.gz: 54495fa9b457fb450d812a6a09b57a3284b948e8e93e44ab97521a241bef0a3b
4
+ data.tar.gz: '06619369fdff53a992b948401115f98ba11319ff0d06bd0a29d73030e39e892e'
5
5
  SHA512:
6
- metadata.gz: c87037ad33284bec4da7576040d214a45978ab5e018c5ef62152a2ae31858484df6f5f2e7899d6b29f9618a875d145f45960aa8c1efa22b97e60ff661b579eea
7
- data.tar.gz: 2ed22a60d030ac9236075a3f97d992956753dc9c3cda125783f3e05f5c74c9d20ce3fe84a848b96b7933b2063efc9d1dd9a899f95d26957050dd7979de75d957
6
+ metadata.gz: ceb7a82b5e59a72b23063caa984e26ce4f3d9d44d41e826d1702613bdad7634f06606dd622c6751aa6f477d042a58c2191cda025bebea6aeb84c356ca9fec984
7
+ data.tar.gz: 71514ddd0dfe83eb7542b5686b194c396878f8d9a6da7652b7ca1f2f38cb4f6c114b31e84293df9d37d73777df4fa248a69c37170524d9c009c1d7c8de76ceb6
@@ -103,12 +103,10 @@ module Compiler
103
103
  end
104
104
  i += "\x2a#{e.size}\x18"
105
105
  end
106
- bc += "\x2b#{i.size}\x18" + i
106
+ bc += "\x29#{i.size}\x18" + i
107
107
  if e
108
108
  bc += e
109
109
  end
110
- when :bool
111
- bc += "\x21\x12#{node.value}\x18"
112
110
  when :name
113
111
  bc += "\x20#{node.value}\x18"
114
112
  when :nil
@@ -10,13 +10,11 @@ module Parser
10
10
  /\Aobject/ => :object,
11
11
  /\Anew/ => :new,
12
12
  /\Arequire/ => :require,
13
- /\A(true|false)/ => :bool,
14
- /\A-?[0-9]+\.[0-9]+/ => :float,
15
- /\A-?[0-9]+/ => :number,
16
- /\A(\+|-)/ => :l1op,
17
- /\A(\/|\*|%)/ => :l2op,
18
- /\A(<|>|<=|>=|==|!=)/ => :l1op,
13
+ /\A(<|>|<=|>=|==|!=)/ => :op,
19
14
  /\A(\+|-|\*|\/|%)?=/ => :eq,
15
+ /\A(\+|-|\*|\/|%)/ => :op,
16
+ /\A-?[0-9]+/ => :number,
17
+ /\A-?[0-9]+\.[0-9]+/ => :float,
20
18
  /\A"([^"]|\\")*"/ => :string,
21
19
  /\Anil/ => :nil,
22
20
  /\A\(/ => :lpar,
@@ -99,14 +97,6 @@ module Parser
99
97
  end
100
98
  end
101
99
 
102
- def self.parse_bool(tokens)
103
- if self.expect tokens, :bool
104
- [ (Node.new :bool, tokens[0][0], []), 1 ]
105
- else
106
- nil
107
- end
108
- end
109
-
110
100
  def self.parse_float(tokens)
111
101
  if self.expect tokens, :float
112
102
  [ (Node.new :float, tokens[0][0], []), 1 ]
@@ -199,7 +189,7 @@ module Parser
199
189
  end
200
190
 
201
191
  def self.parse_literal(tokens)
202
- (self.parse_block tokens) || (self.parse_bool tokens) || (self.parse_float tokens) || (self.parse_name tokens) || (self.parse_number tokens) || (self.parse_list tokens) || (self.parse_string tokens) || (self.parse_nil tokens) || (self.parse_parens tokens)
192
+ (self.parse_block tokens) || (self.parse_float tokens) || (self.parse_name tokens) || (self.parse_number tokens) || (self.parse_list tokens) || (self.parse_string tokens) || (self.parse_nil tokens) || (self.parse_parens tokens)
203
193
  end
204
194
 
205
195
  def self.parse_call(tokens)
@@ -360,7 +350,7 @@ module Parser
360
350
  return [ (Node.new :for, e, [name, block]), total ]
361
351
  end
362
352
 
363
- def self.parse_term(tokens)
353
+ def self.parse_op(tokens)
364
354
  total = 0
365
355
  unless self.parse_literal tokens
366
356
  return nil
@@ -368,38 +358,16 @@ module Parser
368
358
  lhs, part = self.parse_literal tokens
369
359
  total += part
370
360
  tokens = tokens[part..tokens.size]
371
- unless self.expect tokens, :l2op
372
- return [lhs, part]
373
- end
374
- op = tokens[0][0]
375
- total += 1
376
- tokens = tokens[1..tokens.size]
377
- unless self.parse_literal tokens
378
- return nil
379
- end
380
- rhs, part = self.parse_literal tokens
381
- total += part
382
- return [ (Node.new :op, op, [lhs, rhs]), total]
383
- end
384
-
385
- def self.parse_op(tokens)
386
- total = 0
387
- unless self.parse_term tokens
361
+ unless self.expect tokens, :op
388
362
  return nil
389
363
  end
390
- lhs, part = self.parse_term tokens
391
- total += part
392
- tokens = tokens[part..tokens.size]
393
- unless self.expect tokens, :l1op
394
- return [lhs, part]
395
- end
396
364
  op = tokens[0][0]
397
365
  total += 1
398
366
  tokens = tokens[1..tokens.size]
399
- unless self.parse_term tokens
367
+ unless self.parse_expr tokens
400
368
  return nil
401
369
  end
402
- rhs, part = self.parse_term tokens
370
+ rhs, part = self.parse_expr tokens
403
371
  total += part
404
372
  return [ (Node.new :op, op, [lhs, rhs]), total]
405
373
  end
@@ -535,7 +503,7 @@ module Parser
535
503
  end
536
504
 
537
505
  def self.parse_expr(tokens)
538
- (self.parse_require tokens) || (self.parse_new tokens) || (self.parse_object tokens) || (self.parse_fn tokens) || (self.parse_assign tokens) || (self.parse_op tokens) || (self.parse_term tokens) || (self.parse_call tokens) || (self.parse_literal tokens) || (self.parse_if tokens) || (self.parse_while tokens) || (self.parse_for tokens)
506
+ (self.parse_require tokens) || (self.parse_new tokens) || (self.parse_object tokens) || (self.parse_fn tokens) || (self.parse_assign tokens) || (self.parse_op tokens) || (self.parse_call tokens) || (self.parse_literal tokens) || (self.parse_if tokens) || (self.parse_while tokens) || (self.parse_for tokens)
539
507
  end
540
508
 
541
509
  def self.parse(tokens, path)
@@ -341,9 +341,8 @@ class Nil < DataType
341
341
  end
342
342
 
343
343
  class List < DataType
344
- def initialize(val, scope=nil)
344
+ def initialize(val)
345
345
  @internal = val
346
- @scope = scope
347
346
  @pos = 0
348
347
  @fields = {
349
348
  "__as_string" => (NativeFnInternal.new (Proc.new do
@@ -412,7 +411,7 @@ class List < DataType
412
411
  end
413
412
 
414
413
  def add(other)
415
- return List.new [*@internal, (Variable.new other, (get_type other), @scope || @internal[0].scope)]
414
+ return List.new [*@internal, (Variable.new other, (get_type other), @internal[0].scope)]
416
415
  end
417
416
 
418
417
  def mul(other)
data/lib/sdx/vm/vm.rb CHANGED
@@ -18,14 +18,10 @@ class VM
18
18
  attr_accessor :bc_io
19
19
 
20
20
  def truthy(val)
21
- case val.value
22
- when Bool
23
- return val.value.internal
24
- end
25
21
  if val.value.fields["__as_bool"]
26
- return (val.value.fields["__as_bool"].call).internal
22
+ (val.value.fields["__as_bool"].call).internal
27
23
  else
28
- return true
24
+ true
29
25
  end
30
26
  end
31
27
 
@@ -59,7 +55,7 @@ class VM
59
55
  when String
60
56
  to_var (Str.new val)
61
57
  when Float
62
- to_var (Num.new val)
58
+ to_var (Float.new val)
63
59
  when Array
64
60
  to_var (List.new val.map { |v| from_rb v })
65
61
  when Nil
@@ -279,19 +275,12 @@ class VM
279
275
  vals << pop_from_stack
280
276
  end
281
277
  vals.reverse!
282
- push_to_stack Variable.new (List.new vals, @global), :list, @global
278
+ push_to_stack Variable.new (List.new vals), :list, @global
283
279
  when :block
284
280
  size = get_string.to_i
285
281
  body =
286
282
  ((load_bytes size, false).map { |e| e.chr }).join ""
287
283
  push_to_stack Variable.new (Block.new body), :block, @global
288
- when :bool
289
- val = get_string
290
- t = {
291
- "true" => true,
292
- "false" => false,
293
- }
294
- push_to_stack Variable.new (Bool.new t[val]), :bool, @global
295
284
  when :nil
296
285
  push_to_stack Variable.new (Nil.new), :nil, @global
297
286
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sardonyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.85
4
+ version: 0.1.841
5
5
  platform: ruby
6
6
  authors:
7
7
  - sugarfi