loxxy 0.4.05 → 0.4.06

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: 36f3b49ca1158cd6922cb5ece2340f53efec793e5877a96f94aebc0eee34235d
4
- data.tar.gz: ade953da452fbf9ad6552e8dbfb035161c79c2bffcd0d531c4e79cf6d785c51c
3
+ metadata.gz: c0b12b86ba7c949cf712d97fed6691b087f97284e3580124680b773df3be5347
4
+ data.tar.gz: f19231c3e1372525e418fd155f23f71ef84c5fbcb9283eeef11709d4a321408f
5
5
  SHA512:
6
- metadata.gz: bc0ff7ac6da9846a5a70ead053ceeee2eb390f778a70932392fcbe10ce70c7e147f11983baee96dc5aed924de492d744c3b6b61c8d03f389a74432a56b3916a5
7
- data.tar.gz: 40e36a53abc6ce121299952ff98f71175198271659f3a7dabf1cbd0f8e79bdc4c76242f47a4707c513f9ca63459bd4495d56de2287136cedb5cadac14ed4fca3
6
+ metadata.gz: d0f0829b465d2ffb3cd7f287efb9a069ae0c94ddc95f89790f6e1f1d6519aed4dfccb5359d95130afff4cd69d70953983ef25f02f89529789f9bd2ca1bd18c9a
7
+ data.tar.gz: 908ca8e78dbf30ff582a545d542b58b4080a98feab8a035582ea3dd09a5e2533f255cbc7bc531b143d21bd2b0a23d8ea3b0eed0b6007cc35eea005cfc564de61
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [0.4.06] - 2021-11-01
2
+ - Code update to cope with `Rley` v.0.8.08 changes
3
+
4
+ ### Changed
5
+ - File `AST::AstBuilder` some `reduce_` to cope implementation change of ? quantifier
6
+ - Method `AST::LoxCallExpr#initialize` call to `Array#flatten` with argList argument
7
+ - File `loxxy.gemspec` dependency towards `rely` minimal version number is now `0.8.08`
8
+ - Some spec files updated after `rley` changes of ?, *, + quantifiers
9
+
10
+ ### Removed
11
+ - File `front_end/literal.rb`: obsolete
12
+
13
+
1
14
  ## [0.4.05] - 2021-10-10
2
15
  - Removal of `Literal` class, code restyling to please Rubocop 1.22
3
16
 
@@ -16,7 +29,7 @@
16
29
  - File `grammar.rb` use `match_closest` constraint from Rley to cope with dangling else statement
17
30
 
18
31
  ## [0.4.02] - 2021-09-10
19
- - Fixes in`AST::AstBuilder` class to cope with changes in Rley 0.8.03
32
+ - Fixes in`AST::AstBuilder` class to cope with changes in Rley 0.8.03
20
33
 
21
34
  ### Changed
22
35
  - File `loxxy.gemspec` forced dependency to Rley 0.8.03
@@ -222,10 +222,8 @@ module Loxxy
222
222
  if test.nil? && update
223
223
  # when test expr is nil but update expr is not, then force test to be true
224
224
  test = LoxLiteralExpr.new(tokens[0].position, Datatype::True.instance)
225
- [init, test, update]
226
- else
227
- theChildren
228
225
  end
226
+ [init, test, update&.first]
229
227
  end
230
228
 
231
229
  # rule('forInitialization' => 'SEMICOLON')
@@ -234,8 +232,8 @@ module Loxxy
234
232
  end
235
233
 
236
234
  # rule('forTest' => 'expression? SEMICOLON')
237
- def reduce_for_test(_production, range, tokens, theChildren)
238
- return_first_child(range, tokens, theChildren)
235
+ def reduce_for_test(_production, _range, _tokens, theChildren)
236
+ theChildren[0]&.first
239
237
  end
240
238
 
241
239
  # rule('ifStmt' => 'IF ifCondition statement ELSE statement')
@@ -262,7 +260,8 @@ module Loxxy
262
260
 
263
261
  # rule('returnStmt' => 'RETURN expression? SEMICOLON')
264
262
  def reduce_return_stmt(_production, _range, tokens, theChildren)
265
- Ast::LoxReturnStmt.new(tokens[1].position, theChildren[1])
263
+ ret_expr = theChildren[1].nil? ? nil : theChildren[1].first
264
+ Ast::LoxReturnStmt.new(tokens[1].position, ret_expr)
266
265
  end
267
266
 
268
267
  # rule('whileStmt' => 'WHILE LEFT_PAREN expression RIGHT_PAREN statement').as ''
@@ -275,7 +274,7 @@ module Loxxy
275
274
  decls = nil
276
275
  if theChildren[1]
277
276
  pos = tokens[1].position
278
- decls = LoxSeqDecl.new(tokens[1].position, theChildren[1])
277
+ decls = LoxSeqDecl.new(pos, theChildren[1].flatten)
279
278
  else
280
279
  pos = tokens[0].position
281
280
  end
@@ -377,15 +376,16 @@ module Loxxy
377
376
  LoxSuperExpr.new(theChildren[0].token.position, theChildren[2].token.lexeme)
378
377
  end
379
378
 
380
- # rule('function' => 'IDENTIFIER LEFT_PAREN params_opt RIGHT_PAREN block').as 'function'
379
+ # rule('function' => 'IDENTIFIER LEFT_PAREN parameters? RIGHT_PAREN block').as 'function'
381
380
  def reduce_function(_production, _range, _tokens, theChildren)
382
381
  first_child = theChildren.first
383
382
  pos = first_child.token.position
384
- if theChildren[2] && theChildren[2].size > 255
383
+ params = theChildren[2] ? theChildren[2].flatten : []
384
+ if params.size > 255
385
385
  msg = "Can't have more than 255 parameters."
386
386
  raise Loxxy::SyntaxError, msg
387
387
  end
388
- LoxFunStmt.new(pos, first_child.token.lexeme, theChildren[2], theChildren[4])
388
+ LoxFunStmt.new(pos, first_child.token.lexeme, params, theChildren[4])
389
389
  end
390
390
 
391
391
  # rule('parameters' => 'IDENTIFIER (COMMA IDENTIFIER)*').as 'parameters'
@@ -399,7 +399,7 @@ module Loxxy
399
399
 
400
400
  # rule('arguments' => 'expression (COMMA expression)*')
401
401
  def reduce_arguments(_production, _range, _tokens, theChildren)
402
- return [theChildren[0]] unless theChildren[1]
402
+ return [theChildren[0]] if theChildren[1].empty?
403
403
 
404
404
  successors = theChildren[1].map(&:last)
405
405
  successors.unshift(theChildren[0])
@@ -244,7 +244,6 @@ module Loxxy
244
244
 
245
245
  # Let's proceed with the visit of subnodes
246
246
  subnodes.each { |a_node| a_node.accept(self) }
247
-
248
247
  broadcast(:after_subnodes, aParentNode, subnodes)
249
248
  end
250
249
 
@@ -12,7 +12,7 @@ module Loxxy
12
12
  # @param argList [Array<Loxxy::Ast::LoxNode>]
13
13
  def initialize(aPosition, argList)
14
14
  super(aPosition, [])
15
- @arguments = argList
15
+ @arguments = argList.flatten
16
16
  end
17
17
 
18
18
  define_accept # Add `accept` method as found in Visitor design pattern
@@ -6,7 +6,7 @@ module Loxxy
6
6
  module Ast
7
7
  class LoxReturnStmt < LoxCompoundExpr
8
8
  # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
9
- # @param anExpression [Ast::LoxNode] expression to return
9
+ # @param anExpression [Ast::LoxNode, NilClass] expression to return
10
10
  def initialize(aPosition, anExpression)
11
11
  expr = anExpression || Datatype::Nil.instance
12
12
  super(aPosition, [expr])
data/lib/loxxy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loxxy
4
- VERSION = '0.4.05'
4
+ VERSION = '0.4.06'
5
5
  end
data/loxxy.gemspec CHANGED
@@ -58,7 +58,7 @@ Gem::Specification.new do |spec|
58
58
  PkgExtending.pkg_documentation(spec)
59
59
 
60
60
  # Runtime dependencies
61
- spec.add_dependency 'rley', '~> 0.8.06'
61
+ spec.add_dependency 'rley', '~> 0.8.08'
62
62
 
63
63
  # Development dependencies
64
64
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -28,7 +28,7 @@ module Loxxy
28
28
  expect(aParseTree.root.symbol.name).to eq('program')
29
29
  (decls, eof) = aParseTree.root.subnodes
30
30
  expect(decls).to be_kind_of(Rley::PTree::NonTerminalNode)
31
- expect(decls.symbol.name).to eq('declaration_star')
31
+ expect(decls.symbol.name).to eq('rep_declaration_star')
32
32
  expect(decls.subnodes).to be_empty
33
33
  expect(eof).to be_kind_of(Rley::PTree::TerminalNode)
34
34
  expect(eof.symbol.name).to eq('EOF')
@@ -76,9 +76,9 @@ LOX_END
76
76
  expect(root.symbol.name).to eq('program')
77
77
  (decls, eof) = root.subnodes
78
78
  expect(decls).to be_kind_of(Rley::PTree::NonTerminalNode)
79
- expect(decls.symbol.name).to eq('declaration_star')
79
+ expect(decls.symbol.name).to eq('rep_declaration_star')
80
80
  expect(decls.subnodes[0]).to be_kind_of(Rley::PTree::NonTerminalNode)
81
- expect(decls.subnodes[0].symbol.name).to eq('declaration_star')
81
+ expect(decls.subnodes[0].symbol.name).to eq('rep_declaration_star')
82
82
  expect(decls.subnodes[1]).to be_kind_of(Rley::PTree::NonTerminalNode)
83
83
  expect(decls.subnodes[1].symbol.name).to eq('declaration')
84
84
  statement = decls.subnodes[1].subnodes[0]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loxxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.05
4
+ version: 0.4.06
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-10 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.06
19
+ version: 0.8.08
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.06
26
+ version: 0.8.08
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement