loxxy 0.4.08 → 0.4.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/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -1
- data/README.md +6 -4
- data/lib/loxxy/ast/ast_builder.rb +2 -2
- data/lib/loxxy/back_end/resolver.rb +0 -2
- data/lib/loxxy/datatype/number.rb +0 -2
- data/lib/loxxy/front_end/scanner.rb +1 -1
- data/lib/loxxy/version.rb +1 -1
- data/loxxy.gemspec +6 -7
- data/spec/back_end/engine_spec.rb +1 -1
- metadata +26 -16
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ece684c97fd1a382d69d7fb821bd33ca29b662c07230e1f305a9fb50e4abef1
|
4
|
+
data.tar.gz: 0400c4fe48329686f63d34693658c6a8960759ba10173958e0ef0c6b2b75880b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 373db901360190ef0cd84fa3142ec7705922a41d77ec36e3a2f6b8a0b74fbc27c6f0e6de00fc8c38122813a4333758a497b9a88fc372c977a558c8722c19dccb
|
7
|
+
data.tar.gz: a52c9d016e7761ce6b0415cf7c5a409a90106e96c8c18dd8d7e264f87bf43a293d7314bf3854164e809cc1c9cb8354e4c9b97d5d1f2f57d6730e0ecf229e4502
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [0.4.09] - 2025-01-16
|
2
|
+
- Tested with MRI Ruby 3.4.1.
|
3
|
+
- Minor changes
|
4
|
+
- [NEW] Added `demo` folder
|
5
|
+
- [FIX] Some Rubocop 1.72.0 offences fixed.
|
6
|
+
|
1
7
|
## [0.4.08] - 2022-04-09
|
2
8
|
- Refactoring of the `Scanner` class.
|
3
9
|
|
@@ -14,7 +20,6 @@
|
|
14
20
|
- File `duplicate_local.lox` Fixed typo in error message.
|
15
21
|
- File `duplicate_parameter.lox` Fixed typo in error message.
|
16
22
|
|
17
|
-
|
18
23
|
## [0.4.06] - 2021-11-01
|
19
24
|
- Code update to cope with `Rley` v.0.8.08 changes
|
20
25
|
|
data/README.md
CHANGED
@@ -19,8 +19,8 @@ Although __Lox__ is fairly simple, it is far from being a toy language:
|
|
19
19
|
### Loxxy gem features
|
20
20
|
- Complete tree-walking interpreter including lexer, parser and resolver
|
21
21
|
- 100% pure Ruby with clean design (not a port from some other language)
|
22
|
-
- Passes the `
|
23
|
-
- Can run a Lox
|
22
|
+
- Passes the `jlox` (THE reference `Lox` implementation) test suite
|
23
|
+
- Can run a Lox interpreter implemented in ... `Lox` [LoxLox](https://github.com/benhoyt/loxlox),
|
24
24
|
- Minimal runtime dependency (Rley gem). Won't drag a bunch of gems...
|
25
25
|
- Ruby API for integrating a Lox interpreter with your code.
|
26
26
|
- A command-line interpreter `loxxy`
|
@@ -55,7 +55,7 @@ And then execute:
|
|
55
55
|
Create a text file and enter the following lines:
|
56
56
|
```javascript
|
57
57
|
// hello.lox
|
58
|
-
// Your
|
58
|
+
// Your first Lox program
|
59
59
|
print "Hello, world.";
|
60
60
|
```
|
61
61
|
|
@@ -326,7 +326,9 @@ lox_input = <<-LOX_END
|
|
326
326
|
print "Hello, world!";
|
327
327
|
LOX_END
|
328
328
|
|
329
|
-
|
329
|
+
lox = Loxxy::Interpreter.new
|
330
|
+
lox.evaluate(lox_program) # => Hello, world!
|
331
|
+
```
|
330
332
|
|
331
333
|
## Suppported Lox language features
|
332
334
|
|
@@ -188,7 +188,7 @@ module Loxxy
|
|
188
188
|
# rule('varDecl' => 'VAR IDENTIFIER (EQUAL expression)? SEMICOLON')
|
189
189
|
def reduce_var_declaration(_production, _range, tokens, theChildren)
|
190
190
|
var_name = theChildren[1].token.lexeme.dup
|
191
|
-
init_val = theChildren[2]
|
191
|
+
init_val = theChildren[2]&.last
|
192
192
|
Ast::LoxVarStmt.new(tokens[1].position, var_name, init_val)
|
193
193
|
end
|
194
194
|
|
@@ -260,7 +260,7 @@ module Loxxy
|
|
260
260
|
|
261
261
|
# rule('returnStmt' => 'RETURN expression? SEMICOLON')
|
262
262
|
def reduce_return_stmt(_production, _range, tokens, theChildren)
|
263
|
-
ret_expr = theChildren[1]
|
263
|
+
ret_expr = theChildren[1]&.first
|
264
264
|
Ast::LoxReturnStmt.new(tokens[1].position, ret_expr)
|
265
265
|
end
|
266
266
|
|
@@ -178,7 +178,6 @@ module Loxxy
|
|
178
178
|
resolve_local(aThisExpr, aVisitor)
|
179
179
|
end
|
180
180
|
|
181
|
-
# rubocop: disable Style/CaseLikeIf
|
182
181
|
# rubocop: disable Style/StringConcatenation
|
183
182
|
def after_super_expr(aSuperExpr, aVisitor)
|
184
183
|
msg_prefix = "Error at 'super': Can't use 'super' "
|
@@ -195,7 +194,6 @@ module Loxxy
|
|
195
194
|
resolve_local(aSuperExpr, aVisitor)
|
196
195
|
end
|
197
196
|
# rubocop: enable Style/StringConcatenation
|
198
|
-
# rubocop: enable Style/CaseLikeIf
|
199
197
|
|
200
198
|
# function declaration creates a new scope for its body & binds its parameters for that scope
|
201
199
|
def before_fun_stmt(aFunStmt, aVisitor)
|
@@ -63,7 +63,6 @@ module Loxxy
|
|
63
63
|
# one Lox number and a Ruby Numeric
|
64
64
|
# @param other [Loxxy::Datatype::Number, Numeric]
|
65
65
|
# @return [Loxxy::Datatype::Number]
|
66
|
-
# rubocop: disable Lint/BinaryOperatorWithIdenticalOperands
|
67
66
|
def /(other)
|
68
67
|
case other
|
69
68
|
when Number, Numeric
|
@@ -84,7 +83,6 @@ module Loxxy
|
|
84
83
|
raise TypeError, err_msg
|
85
84
|
end
|
86
85
|
end
|
87
|
-
# rubocop: enable Lint/BinaryOperatorWithIdenticalOperands
|
88
86
|
|
89
87
|
# Unary minus (return value with changed sign)
|
90
88
|
# @return [Loxxy::Datatype::Number]
|
@@ -67,7 +67,7 @@ module Loxxy
|
|
67
67
|
@@keywords = %w[
|
68
68
|
and class else false fun for if nil or
|
69
69
|
print return super this true var while
|
70
|
-
].
|
70
|
+
].to_h { |x| [x, x] }
|
71
71
|
|
72
72
|
# Single character that have a special meaning when escaped
|
73
73
|
# @return [{Char => String}]
|
data/lib/loxxy/version.rb
CHANGED
data/loxxy.gemspec
CHANGED
@@ -10,12 +10,10 @@ module PkgExtending
|
|
10
10
|
file_list = Dir[
|
11
11
|
'.rubocop.yml',
|
12
12
|
'.rspec',
|
13
|
-
'.travis.yml',
|
14
13
|
'.yardopts',
|
15
14
|
'Gemfile',
|
16
15
|
'Rakefile',
|
17
16
|
'CHANGELOG.md',
|
18
|
-
'CODE_OF_CONDUCT.md',
|
19
17
|
'LICENSE.txt',
|
20
18
|
'README.md',
|
21
19
|
'loxxy.gemspec',
|
@@ -48,7 +46,7 @@ Gem::Specification.new do |spec|
|
|
48
46
|
DESCR_END
|
49
47
|
spec.homepage = 'https://github.com/famished-tiger/loxxy'
|
50
48
|
spec.license = 'MIT'
|
51
|
-
spec.required_ruby_version = '>= 2.
|
49
|
+
spec.required_ruby_version = '>= 2.6'
|
52
50
|
|
53
51
|
spec.bindir = 'bin'
|
54
52
|
spec.executables = ['loxxy']
|
@@ -58,10 +56,11 @@ Gem::Specification.new do |spec|
|
|
58
56
|
PkgExtending.pkg_documentation(spec)
|
59
57
|
|
60
58
|
# Runtime dependencies
|
61
|
-
spec.add_dependency 'rley', '~> 0.8.
|
59
|
+
spec.add_dependency 'rley', '~> 0.8.10'
|
62
60
|
|
63
61
|
# Development dependencies
|
64
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
65
|
-
spec.add_development_dependency 'rake', '~>
|
66
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
62
|
+
spec.add_development_dependency 'bundler', '~> 2.5.0'
|
63
|
+
spec.add_development_dependency 'rake', '~> 13.1.0'
|
64
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
65
|
+
spec.add_development_dependency 'yard', '~> 0.9.34'
|
67
66
|
end
|
@@ -15,7 +15,7 @@ module Loxxy
|
|
15
15
|
subject { Engine.new(sample_options) }
|
16
16
|
|
17
17
|
context 'Initialization:' do
|
18
|
-
it 'should accept
|
18
|
+
it 'should accept an option Hash at initialization' do
|
19
19
|
expect { Engine.new(sample_options) }.not_to raise_error
|
20
20
|
end
|
21
21
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loxxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.09
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-16 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rley
|
@@ -16,56 +15,70 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.8.
|
18
|
+
version: 0.8.10
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.8.
|
25
|
+
version: 0.8.10
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: bundler
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
32
|
+
version: 2.5.0
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
39
|
+
version: 2.5.0
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: rake
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
46
|
+
version: 13.1.0
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
53
|
+
version: 13.1.0
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: rspec
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
60
|
+
version: '3.12'
|
62
61
|
type: :development
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
67
|
+
version: '3.12'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: yard
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.9.34
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.9.34
|
69
82
|
description: |2
|
70
83
|
A Ruby implementation of the Lox programming language. Lox is a dynamically typed,
|
71
84
|
object-oriented programming language that features first-class functions, closures,
|
@@ -80,7 +93,6 @@ extra_rdoc_files:
|
|
80
93
|
files:
|
81
94
|
- ".rspec"
|
82
95
|
- ".rubocop.yml"
|
83
|
-
- ".travis.yml"
|
84
96
|
- ".yardopts"
|
85
97
|
- CHANGELOG.md
|
86
98
|
- Gemfile
|
@@ -163,7 +175,6 @@ homepage: https://github.com/famished-tiger/loxxy
|
|
163
175
|
licenses:
|
164
176
|
- MIT
|
165
177
|
metadata: {}
|
166
|
-
post_install_message:
|
167
178
|
rdoc_options:
|
168
179
|
- --charset=UTF-8 --exclude="examples|spec"
|
169
180
|
require_paths:
|
@@ -172,15 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
183
|
requirements:
|
173
184
|
- - ">="
|
174
185
|
- !ruby/object:Gem::Version
|
175
|
-
version: '2.
|
186
|
+
version: '2.6'
|
176
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
188
|
requirements:
|
178
189
|
- - ">="
|
179
190
|
- !ruby/object:Gem::Version
|
180
191
|
version: '0'
|
181
192
|
requirements: []
|
182
|
-
rubygems_version: 3.
|
183
|
-
signing_key:
|
193
|
+
rubygems_version: 3.6.2
|
184
194
|
specification_version: 4
|
185
195
|
summary: An implementation of the Lox programming language.
|
186
196
|
test_files:
|