loxxy 0.4.03 → 0.4.04
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 +4 -4
- data/CHANGELOG.md +24 -17
- data/lib/loxxy/ast/ast_builder.rb +1 -1
- data/lib/loxxy/front_end/grammar.rb +2 -8
- data/lib/loxxy/version.rb +1 -1
- data/spec/front_end/raw_parser_spec.rb +1 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e321e9f44f39776e2684a1a2c2f2d032460847ff46cdea45791cf8724696d038
|
|
4
|
+
data.tar.gz: 1c455133b79cd26939998ebd791c5b39872de1ccf59fa6b8c8d4c7d819114021
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
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' => '
|
|
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
|
|
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
|
@@ -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
|
-
|
|
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]
|