loxxy 0.1.08 → 0.1.09
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 +9 -0
- data/README.md +2 -3
- data/lib/loxxy/ast/lox_return_stmt.rb +2 -1
- data/lib/loxxy/back_end/resolver.rb +11 -0
- data/lib/loxxy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d027baa99cb59b7a102b55d1dec07e75f7cb17a71c42708881507ae8bc83b75
|
4
|
+
data.tar.gz: 6f27ba42c296a5845185fb8d746fd8cf24d9b8b71c2c98d590fa8a9c22cac33f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b71f56915f53a4ece5bcfde6b74ee7d407517b54038b3a00a945813acd3137c5da8800f8ac2fea71220b35557d18eb63fef25ac0b90297b1067a9ed65e70a55
|
7
|
+
data.tar.gz: b6faed818eff75c6beb32137cd97777b332b9a79994ab74ddb70cc4a257778e8a2571ab59d8c612fc89e5bf5f3c7a4e9f3868748ae737b3fe0cce1e404681460
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## [0.1.09] - 2021-03-28
|
2
|
+
- Fix and test suite for return statements
|
3
|
+
|
4
|
+
### Changed
|
5
|
+
- `Loxxy` reports an error when a return statement occurs in top-level scope
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
- A return without explicit value genrated an exception in some cases.
|
9
|
+
|
1
10
|
## [0.1.08] - 2021-03-27
|
2
11
|
- `Loxxy` implements variable resolving and binding as described in Chapter 11 of "Crafting Interpreters" book.
|
3
12
|
|
data/README.md
CHANGED
@@ -13,10 +13,9 @@ a simple language defined in Bob Nystrom's online book [Crafting Interpreters](h
|
|
13
13
|
a Lox interpreter written in Lox.
|
14
14
|
|
15
15
|
### Current status
|
16
|
-
The interpreter currently
|
16
|
+
The interpreter currently can execute all allowed __Lox__ expressions and statements except
|
17
17
|
object-oriented feaures (classes and objects).
|
18
|
-
|
19
|
-
Our intent is implement to these missing features in Q2 2021.
|
18
|
+
The goal is to implement these missing features in Q2 2021.
|
20
19
|
|
21
20
|
|
22
21
|
## What's the fuss about Lox?
|
@@ -8,7 +8,8 @@ module Loxxy
|
|
8
8
|
# @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
|
9
9
|
# @param anExpression [Ast::LoxNode] expression to return
|
10
10
|
def initialize(aPosition, anExpression)
|
11
|
-
|
11
|
+
expr = anExpression || Datatype::Nil.instance
|
12
|
+
super(aPosition, [expr])
|
12
13
|
end
|
13
14
|
|
14
15
|
# Part of the 'visitee' role in Visitor design pattern.
|
@@ -64,6 +64,13 @@ module Loxxy
|
|
64
64
|
anIfStmt.else_stmt&.accept(aVisitor)
|
65
65
|
end
|
66
66
|
|
67
|
+
def before_return_stmt(_returnStmt)
|
68
|
+
if scopes.size < 2
|
69
|
+
msg = "Error at 'return': Can't return from top-level code."
|
70
|
+
raise StandardError, msg
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
67
74
|
def after_while_stmt(aWhileStmt, aVisitor)
|
68
75
|
aWhileStmt.body.accept(aVisitor)
|
69
76
|
aWhileStmt.condition.accept(aVisitor)
|
@@ -122,6 +129,10 @@ module Loxxy
|
|
122
129
|
return if scopes.empty?
|
123
130
|
|
124
131
|
curr_scope = scopes.last
|
132
|
+
if curr_scope.include?(aVarName)
|
133
|
+
msg = "Error at '#{aVarName}': Already variable with this name in this scope."
|
134
|
+
raise StandardError, msg
|
135
|
+
end
|
125
136
|
|
126
137
|
# The initializer is not yet processed.
|
127
138
|
# Mark the variable as 'not yet ready' = exists but may not be referenced yet
|
data/lib/loxxy/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.09
|
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-03-
|
11
|
+
date: 2021-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|