loxxy 0.4.03 → 0.4.04

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a500598bd4afc6d330a6e661bc9686b86de41c921fc7fea04ea0293dd97c057
4
- data.tar.gz: 7e3f0335e8f9d7914d36db4e0e306ce053f9df18d5efce5cca1f43d22c866402
3
+ metadata.gz: e321e9f44f39776e2684a1a2c2f2d032460847ff46cdea45791cf8724696d038
4
+ data.tar.gz: 1c455133b79cd26939998ebd791c5b39872de1ccf59fa6b8c8d4c7d819114021
5
5
  SHA512:
6
- metadata.gz: 51affe131c074f29e887b83de9263cedf31394d9c9254877ddcf971d8e5d41f7035abb50b95af8f98c18a2d9cee06bfb3df7e6c9c97db24e31dbad7fb124c2f5
7
- data.tar.gz: 6e16c93754aa0bbe32815b78b2362ade39e7823dafc677cb1c2694f3bdec8c07e59820487464634bde7ab08221da4f83381b38149bd68bfd18987d19565a71ab
6
+ metadata.gz: '031899513309e2950fd9dcf9fc782a14299bed0337e6ca2383351b277c69e1e5afc865d82a9bfce030d4780b9c738de18f18db970d862b344ac98ad00f22a2a7'
7
+ data.tar.gz: 60938437329c31b76307ea181e5596191b5261d55aeca369365fd8076f08879e2adfb112ec8cbaf1fd9d365e9e13816b644e1b897dd4f7840e37d9d20cc89ac8
data/CHANGELOG.md CHANGED
@@ -1,15 +1,22 @@
1
+ ## [0.4.04] - 2021-09-11
2
+ - Grammar optimization (3 rules less, use of match_closest feature from `Rley`)
3
+
4
+ ### Changed
5
+ - Method `Ast::AstBuilder#reduce_arguments` code re-styling: use shorthand &:
6
+ - File `grammar.rb` use `match_closest` constraint from Rley to cope with dangling else statement
7
+
1
8
  ## [0.4.02] - 2021-09-10
2
- - Fixes in`AST::AstBuilder` class to cope with changes inRley 0.8.03
9
+ - Fixes in`AST::AstBuilder` class to cope with changes in Rley 0.8.03
3
10
 
4
11
  ### Changed
5
12
  - File `loxxy.gemspec` forced dependency to Rley 0.8.03
6
13
 
7
14
  ### Fixed
8
15
  - Method `Ast::AstBuilder#reduce_class_naming` fixed access to `IDENTIFER` in (LESS IDENTIFER)?
9
- - Method `Ast::AstBuilder#reduce_var_declaration` fixed access to `expression` in (EQUAL expression)?
10
- - Method `Ast::AstBuilder#reduce_assign_expr`fixed access to `call` in (call DOT)?
11
- - Method `Ast::AstBuilder#reduce_parameters`fixed access to `IDENTIFIER` in (COMMA IDENTIFIER)*
12
- - Method `Ast::AstBuilder#reduce_arguments`fixed access to `expression` in (COMMA expression)*
16
+ - Method `Ast::AstBuilder#reduce_var_declaration` fixed access to `expression` in (EQUAL expression)?
17
+ - Method `Ast::AstBuilder#reduce_assign_expr`fixed access to `call` in (call DOT)?
18
+ - Method `Ast::AstBuilder#reduce_parameters`fixed access to `IDENTIFIER` in (COMMA IDENTIFIER)*
19
+ - Method `Ast::AstBuilder#reduce_arguments`fixed access to `expression` in (COMMA expression)*
13
20
 
14
21
 
15
22
 
@@ -68,14 +75,14 @@
68
75
  - Milestone: `Loxxy` passes all reference test suite.
69
76
 
70
77
  ### Fixed
71
- - Method `BackEnd::Resolver#before_variable_expr`: Standard `Lox` allows re-declaration of a variable at top-level scope
78
+ - Method `BackEnd::Resolver#before_variable_expr`: Standard `Lox` allows re-declaration of a variable at top-level scope
79
+
72
80
 
73
-
74
81
  ## [0.2.06] - 2021-05-04
75
82
  - Nearly passing the 'official' test suite, fixing non-compliant behavior, specialized exceptions for errors
76
83
 
77
84
  ### New
78
- - Module `LoxFileTester` module that hosts methods that simplify the tests of `Lox` source file.
85
+ - Module `LoxFileTester` module that hosts methods that simplify the tests of `Lox` source file.
79
86
 
80
87
  ### Changed
81
88
  - Folder `test_suite` vastly reorganized. Sub-folder `baseline` contains spec files testing the `Lox` files from official implementation
@@ -85,7 +92,7 @@
85
92
 
86
93
  ### Fixed
87
94
  - `0/0` expression results in a ZeroDivisionError exception, in Lox this result to a NaN (Not a Number). Now, `Loxxy` is aligned to standard `Lox`
88
- - `FrontEnd::Scanner` now always treats expression like `-123` as the unary or binary minus operator applied to a positive number.
95
+ - `FrontEnd::Scanner` now always treats expression like `-123` as the unary or binary minus operator applied to a positive number.
89
96
 
90
97
  ## [0.2.05] - 2021-04-26
91
98
  - `Loxxy` now transforms for loops into while loops (desugaring), fix in Scanner class
@@ -112,7 +119,7 @@
112
119
  - Method `BackEnd::Resolver#after_for_stmt now accepts nil test expression
113
120
 
114
121
  ## [0.2.03] - 2021-04-24
115
- - Fixes for the set (field) expressions, `accept` methods for AST nodes are meta-programmed
122
+ - Fixes for the set (field) expressions, `accept` methods for AST nodes are meta-programmed
116
123
 
117
124
  ### New
118
125
  - Module `Ast::Visitee` provides the `define_accept` method that generate `accept` method with meta-programming
@@ -287,7 +294,7 @@
287
294
  - Fix and test suite for return statements
288
295
 
289
296
  ### CHANGED
290
- - `Loxxy` reports an error when a return statement occurs in top-level scope
297
+ - `Loxxy` reports an error when a return statement occurs in top-level scope
291
298
 
292
299
  ### Fixed
293
300
  - A return without explicit value genrated an exception in some cases.
@@ -311,7 +318,7 @@
311
318
  - Class `BackEnd::Environment`: added the attributes `predecessor` and `embedding` to support closures.
312
319
  - Class `BackeEnd::LoxFunction`: added the attribute `closure` that is equal to the environment where the function is declared.
313
320
  - Constructor `BackEnd::LoxFunction#new` now takes a `BackEnd::Engine`as its fourth parameter
314
- - Methods `BackEnd::SymbolTable#enter_environment`, `BackEnd::SymbolTable#leave_environment` take into account closures.
321
+ - Methods `BackEnd::SymbolTable#enter_environment`, `BackEnd::SymbolTable#leave_environment` take into account closures.
315
322
 
316
323
  ### Fixed
317
324
  - Method `Ast::AstBuilder#after_var_stmt` now takes into account the value from the top of stack
@@ -357,7 +364,7 @@
357
364
 
358
365
  ### Changed
359
366
  - File `console` renamed to `loxxy`. Very basic command-line interface.
360
- - Custom exception classes
367
+ - Custom exception classes
361
368
  - File `README.md` updated list of supported `Lox` keywords.
362
369
 
363
370
 
@@ -388,8 +395,8 @@
388
395
  - Method `Ast::ASTVisitor#visit_fun_stmt` for visiting an `Ast::LoxFunStmt` node
389
396
  - Method `Ast::LoxBlockStmt#empty?` returns true if the code block is empty
390
397
  - Method `BackEnd::Engine#after_fun_stmt`
391
- - Method `BackEnd::NativeFunction#call`
392
- - Method `BackEnd::NativeFunction#to_str`
398
+ - Method `BackEnd::NativeFunction#call`
399
+ - Method `BackEnd::NativeFunction#to_str`
393
400
  - Method `BackEnd::LoxFunction` runtime representation of a Lox function.
394
401
 
395
402
  ### Changed
@@ -458,7 +465,7 @@
458
465
  - Method `Ast::ASTBuilder#reduce_assign_expr` creates an `Ast::LoxAssignExpr` node
459
466
  - Method `Ast::ASTVisitor#visit_assign_expr` for visiting an `Ast::LoxAssignExpr` node
460
467
  - Method `BackEnd::Engine#after_assign_expr` implementation of the assignment
461
- - Method `BackEnd::Variable#assign` to assign a value to a variable
468
+ - Method `BackEnd::Variable#assign` to assign a value to a variable
462
469
 
463
470
  ## [0.0.23] - 2021-01-20
464
471
  - Fix for variables without explicit initialization.
@@ -728,4 +735,4 @@
728
735
 
729
736
  ## [0.0.1] - 2020-12-27
730
737
  ### Added
731
- - Initial Github commit
738
+ - Initial Github commit
@@ -401,7 +401,7 @@ module Loxxy
401
401
  def reduce_arguments(_production, _range, _tokens, theChildren)
402
402
  return [theChildren[0]] unless theChildren[1]
403
403
 
404
- successors = theChildren[1].map { |seq_node| seq_node.last }
404
+ successors = theChildren[1].map(&:last)
405
405
  successors.unshift(theChildren[0])
406
406
  end
407
407
  end # class
@@ -32,7 +32,7 @@ module Loxxy
32
32
  rule('declaration' => 'classDecl')
33
33
  rule('declaration' => 'funDecl')
34
34
  rule('declaration' => 'varDecl')
35
- rule('declaration' => 'stmt')
35
+ rule('declaration' => 'statement')
36
36
 
37
37
  rule('classDecl' => 'CLASS classNaming class_body').as 'class_decl'
38
38
  rule('classNaming' => 'IDENTIFIER (LESS IDENTIFIER)?').as 'class_naming'
@@ -43,8 +43,6 @@ module Loxxy
43
43
  rule('varDecl' => 'VAR IDENTIFIER (EQUAL expression)? SEMICOLON').as 'var_declaration'
44
44
 
45
45
  # Statements: produce side effects, but don't introduce bindings
46
- rule('stmt' => 'statement')
47
- # rule('stmt' => 'unbalancedStmt') # Tweak to cope with "dangling else" problem
48
46
  rule('statement' => 'exprStmt')
49
47
  rule('statement' => 'forStmt')
50
48
  rule('statement' => 'ifStmt')
@@ -63,11 +61,7 @@ module Loxxy
63
61
  rule('forTest' => 'expression? SEMICOLON').as 'for_test'
64
62
 
65
63
  rule('ifStmt' => 'IF ifCondition statement ELSE {match_closest: "IF"} statement').as 'if_else_stmt'
66
- rule('ifStmt' => 'IF ifCondition stmt').as 'if_stmt'
67
- # rule('unbalancedStmt' => 'IF ifCondition statement ELSE unbalancedStmt').as 'if_else_stmt'
68
- # rule('ifStmt' => 'IF ifCondition statement ELSE statement').as 'if_else_stmt'
69
- # rule('unbalancedStmt' => 'IF ifCondition stmt').as 'if_stmt'
70
- # rule('unbalancedStmt' => 'IF ifCondition statement ELSE unbalancedStmt').as 'if_else_stmt'
64
+ rule('ifStmt' => 'IF ifCondition statement').as 'if_stmt'
71
65
  rule('ifCondition' => 'LEFT_PAREN expression RIGHT_PAREN').as 'keep_symbol2'
72
66
 
73
67
  rule('printStmt' => 'PRINT expression SEMICOLON').as 'print_stmt'
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.03'
4
+ VERSION = '0.4.04'
5
5
  end
@@ -81,10 +81,7 @@ LOX_END
81
81
  expect(decls.subnodes[0].symbol.name).to eq('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
- stmt = decls.subnodes[1].subnodes[0]
85
- expect(stmt).to be_kind_of(Rley::PTree::NonTerminalNode)
86
- expect(stmt.symbol.name).to eq('stmt')
87
- statement = stmt.subnodes[0]
84
+ statement = decls.subnodes[1].subnodes[0]
88
85
  expect(statement).to be_kind_of(Rley::PTree::NonTerminalNode)
89
86
  expect(statement.symbol.name).to eq('statement')
90
87
  prnt_stmt = statement.subnodes[0]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loxxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.03
4
+ version: 0.4.04
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef