loxxy 0.1.0 → 0.1.01
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 +5 -0
- data/lib/loxxy/ast/ast_builder.rb +2 -2
- data/lib/loxxy/ast/lox_fun_stmt.rb +2 -0
- data/lib/loxxy/back_end/engine.rb +1 -1
- data/lib/loxxy/back_end/function.rb +2 -3
- data/lib/loxxy/version.rb +1 -1
- data/spec/interpreter_spec.rb +2 -0
- 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: c477fc7db959df775fc4656e21d577dbb3fce65724b07c8a7ec020496c196100
|
4
|
+
data.tar.gz: f941317a01b0dbcdca250697a4e84b88f85b572fa7f4f67be3de7c162bc8e2cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b379767ee5cdf986a1b5e704c0254bb8901123811504ba58c59d3996897c29413e84298f6d3c65db849ad289183261d30657e1605d076c4ab9a8e9b0c38318da
|
7
|
+
data.tar.gz: 258f5a4d501bedbbec5f235ca7d858a4195c9088dcef8d63a6a16b9c25306167eecf93ff3b51aafc8ecf17fd6ed40f9dfe220797a033021f377eb62200de99c3
|
data/CHANGELOG.md
CHANGED
@@ -233,7 +233,7 @@ module Loxxy
|
|
233
233
|
end
|
234
234
|
|
235
235
|
# rule('block' => 'LEFT_BRACE RIGHT_BRACE').as 'block_empty'
|
236
|
-
def reduce_block_empty(_production, _range, tokens,
|
236
|
+
def reduce_block_empty(_production, _range, tokens, _children)
|
237
237
|
Ast::LoxBlockStmt.new(tokens[0].position, nil)
|
238
238
|
end
|
239
239
|
|
@@ -298,7 +298,7 @@ module Loxxy
|
|
298
298
|
def reduce_function(_production, _range, _tokens, theChildren)
|
299
299
|
first_child = theChildren.first
|
300
300
|
pos = first_child.token.position
|
301
|
-
|
301
|
+
LoxFunStmt.new(pos, first_child.token.lexeme, theChildren[2], theChildren[4])
|
302
302
|
end
|
303
303
|
|
304
304
|
# rule('parameters' => 'parameters COMMA IDENTIFIER')
|
@@ -4,6 +4,7 @@ require_relative 'lox_compound_expr'
|
|
4
4
|
|
5
5
|
module Loxxy
|
6
6
|
module Ast
|
7
|
+
# rubocop: disable Style/AccessorGrouping
|
7
8
|
class LoxFunStmt < LoxCompoundExpr
|
8
9
|
attr_reader :name
|
9
10
|
attr_reader :params
|
@@ -28,5 +29,6 @@ module Loxxy
|
|
28
29
|
|
29
30
|
alias operands subnodes
|
30
31
|
end # class
|
32
|
+
# rubocop: enable Style/AccessorGrouping
|
31
33
|
end # module
|
32
34
|
end # module
|
@@ -213,7 +213,7 @@ module Loxxy
|
|
213
213
|
stack.push(aValue)
|
214
214
|
end
|
215
215
|
|
216
|
-
def after_fun_stmt(aFunStmt,
|
216
|
+
def after_fun_stmt(aFunStmt, _visitor)
|
217
217
|
function = Function.new(aFunStmt.name, aFunStmt.params, aFunStmt.body, stack)
|
218
218
|
new_var = Variable.new(aFunStmt.name, function)
|
219
219
|
symbol_table.insert(new_var)
|
@@ -4,18 +4,16 @@ require_relative '../datatype/all_datatypes'
|
|
4
4
|
|
5
5
|
module Loxxy
|
6
6
|
module BackEnd
|
7
|
+
# rubocop: disable Style/AccessorGrouping
|
7
8
|
# Representation of a Lox function.
|
8
9
|
# It is a named slot that can be associated with a value at the time.
|
9
10
|
class Function
|
10
|
-
|
11
11
|
# @return [String]
|
12
12
|
attr_reader :name
|
13
13
|
|
14
14
|
# @return [Array<>] the parameters
|
15
15
|
attr_reader :parameters
|
16
|
-
|
17
16
|
attr_reader :body
|
18
|
-
|
19
17
|
attr_reader :stack
|
20
18
|
|
21
19
|
# Create a variable with given name and initial value
|
@@ -41,5 +39,6 @@ module Loxxy
|
|
41
39
|
"<fn #{name}>"
|
42
40
|
end
|
43
41
|
end # class
|
42
|
+
# rubocop: enable Style/AccessorGrouping
|
44
43
|
end # module
|
45
44
|
end # module
|
data/lib/loxxy/version.rb
CHANGED
data/spec/interpreter_spec.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative '../lib/loxxy/interpreter'
|
|
9
9
|
module Loxxy
|
10
10
|
# This spec contains the bare bones test for the Interpreter class.
|
11
11
|
# The execution of Lox code is tested elsewhere.
|
12
|
+
# rubocop: disable Metrics/BlockLength
|
12
13
|
describe Interpreter do
|
13
14
|
let(:sample_cfg) do
|
14
15
|
{ ostream: StringIO.new }
|
@@ -429,4 +430,5 @@ LOX_END
|
|
429
430
|
end
|
430
431
|
end # context
|
431
432
|
end # describe
|
433
|
+
# rubocop: enable Metrics/BlockLength
|
432
434
|
end # module
|