loxxy 0.2.03 → 0.2.04
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/loxxy/back_end/engine.rb +12 -3
- data/lib/loxxy/back_end/resolver.rb +1 -1
- data/lib/loxxy/front_end/parser.rb +1 -1
- data/lib/loxxy/version.rb +1 -1
- data/spec/interpreter_spec.rb +11 -0
- 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: d628b0737a29bab0869827af50a363846200bfab7baddc63279e0e3fb904fa75
|
4
|
+
data.tar.gz: d617939297fe24cf267fb66c198cbc172e05a7df4472eac546bd9b5e27eef0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde10867e0a0243a5c0e2349a37df2ec76178aa2a7da625abd42363175301bf773d8d56aa249dde380361b13af5181c33a8ed65a4cf1bd2bbdaf2c946b534f99
|
7
|
+
data.tar.gz: 204243d4d781f54820a66d483d791676d144b3a4af7febbb2a1a27041c651d2ea4a0015e2bf3408754c9ea31dc0f66b4c6b0d8ad6175edc5912391331f95e9e1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
## [0.2.04] - 2021-04-25
|
2
|
+
- `Loxxy` passes the test suite for `for` statements
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
- Method `BackEnd::Engine#after_for_stmt` now a for(;;) executes the body once; a for without test will execute forever
|
6
|
+
- Method `BackEnd::Resolver#after_for_stmt now accepts nil test expression
|
7
|
+
|
8
|
+
## [0.2.03] - 2021-04-24
|
9
|
+
- Fixes for the set (field) expressions, `accept` methods for AST nodes are meta-programmed
|
10
|
+
|
11
|
+
### New
|
12
|
+
- Module `Ast::Visitee` provides the `define_accept` method that generate `accept` method with meta-programming
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Method `BackEnd::Engine#before_set_expr` methos method that ensure that the receiver is evaluated first, then the assigned value
|
16
|
+
- Method `BackEnd::Engine#after_set_expr` now pushes the value assigned to the field also onto the stack
|
17
|
+
- Class `BackEnd::Engine` a number of StnadardError exceptions are replaced by Loxxy::RuntimeError
|
18
|
+
|
19
|
+
|
1
20
|
## [0.2.02] - 2021-04-21
|
2
21
|
- Improvements in the scanner class (escape sequence for quotes and newlines), error messages closer to jlox.
|
3
22
|
|
@@ -117,10 +117,19 @@ module Loxxy
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def after_for_stmt(aForStmt, aVisitor)
|
120
|
+
iterating = false
|
121
|
+
|
120
122
|
loop do
|
121
|
-
aForStmt.test_expr
|
122
|
-
|
123
|
-
|
123
|
+
if aForStmt.test_expr
|
124
|
+
aForStmt.test_expr.accept(aVisitor)
|
125
|
+
condition = stack.pop
|
126
|
+
break unless condition.truthy?
|
127
|
+
elsif iterating
|
128
|
+
# when both test and update expressions are nil => execute body once
|
129
|
+
break unless aForStmt.update_expr
|
130
|
+
else
|
131
|
+
iterating = true
|
132
|
+
end
|
124
133
|
|
125
134
|
aForStmt.body_stmt.accept(aVisitor)
|
126
135
|
aForStmt.update_expr&.accept(aVisitor)
|
@@ -46,7 +46,7 @@ module Loxxy
|
|
46
46
|
# Stop if the parse failed...
|
47
47
|
line1 = "Parsing failed\n"
|
48
48
|
line2 = "Reason: #{result.failure_reason.message}"
|
49
|
-
raise
|
49
|
+
raise SyntaxError, line1 + line2
|
50
50
|
end
|
51
51
|
|
52
52
|
return engine.convert(result) # engine.to_ptree(result)
|
data/lib/loxxy/version.rb
CHANGED
data/spec/interpreter_spec.rb
CHANGED
@@ -431,6 +431,17 @@ LOX_END
|
|
431
431
|
expect(result).to eq(3)
|
432
432
|
end
|
433
433
|
|
434
|
+
it 'should support return within statements inside a function' do
|
435
|
+
program = <<-LOX_END
|
436
|
+
fun foo() {
|
437
|
+
for (;;) return "done";
|
438
|
+
}
|
439
|
+
print foo(); // output: done
|
440
|
+
LOX_END
|
441
|
+
expect { subject.evaluate(program) }.not_to raise_error
|
442
|
+
expect(sample_cfg[:ostream].string).to eq('done')
|
443
|
+
end
|
444
|
+
|
434
445
|
# rubocop: disable Style/StringConcatenation
|
435
446
|
it 'should support local functions and closures' do
|
436
447
|
program = <<-LOX_END
|
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.2.
|
4
|
+
version: 0.2.04
|
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-04-
|
11
|
+
date: 2021-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|