miniruby 0.1.0 → 0.2.0
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 +35 -26
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +7 -7
- data/lib/miniruby/ast.rb +692 -73
- data/lib/miniruby/bytecode_function.rb +251 -0
- data/lib/miniruby/call_info.rb +29 -0
- data/lib/miniruby/compiler.rb +438 -0
- data/lib/miniruby/io.rb +32 -0
- data/lib/miniruby/lexer.rb +33 -30
- data/lib/miniruby/native_function.rb +40 -0
- data/lib/miniruby/opcode.rb +136 -0
- data/lib/miniruby/parser/result.rb +5 -5
- data/lib/miniruby/parser.rb +422 -53
- data/lib/miniruby/position.rb +4 -4
- data/lib/miniruby/span.rb +6 -6
- data/lib/miniruby/token.rb +40 -29
- data/lib/miniruby/version.rb +1 -1
- data/lib/miniruby/vm.rb +245 -0
- data/lib/miniruby.rb +26 -26
- metadata +11 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4b95c75a52ab5a51fdb41c2721323256d4983ac109e223840c0527bdbca01d8
|
|
4
|
+
data.tar.gz: 72f0db09bcd1228eaae0c530382c3746d00db27ef489b169032a5431d45f79cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be29ee866331b6e375f7950185c0d1b7d078019a87b07057298f9e600a2c909128285033921a1b70556f291cf6448beed3081e2906541a88fe449d53bb401c7e
|
|
7
|
+
data.tar.gz: 07420f654d4cf62143bddd5bc2f3b2062ad43c367c52b596345e9ee579c93bd834310e1f80ada72c327ce766d44c7b65ee07861cdfedcb40cbafddf438115a9f
|
data/.rubocop.yml
CHANGED
|
@@ -1,77 +1,86 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 3.2
|
|
3
|
-
|
|
4
1
|
inherit_gem:
|
|
5
2
|
rubocop-espago: sorbet.yml
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.4
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
Metrics/PerceivedComplexity:
|
|
11
8
|
Enabled: false
|
|
12
9
|
|
|
13
|
-
Style/
|
|
10
|
+
Style/RaiseArgs:
|
|
14
11
|
Enabled: false
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
Style/MultipleComparison:
|
|
17
14
|
Enabled: false
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
Style/YodaExpression:
|
|
20
17
|
Enabled: false
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
Sorbet/ForbidTTypeAlias:
|
|
23
20
|
Enabled: false
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
Sorbet/CallbackConditionalsBinding:
|
|
26
23
|
Enabled: false
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
Style/InvertibleUnlessCondition:
|
|
29
26
|
Enabled: false
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
Style/GuardClause:
|
|
32
29
|
Enabled: false
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
Sorbet/ForbidMixesInClassMethods:
|
|
35
32
|
Enabled: false
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
Lint/SafeNavigationConsistency:
|
|
38
35
|
Enabled: false
|
|
39
36
|
|
|
40
|
-
|
|
37
|
+
Metrics/ClassLength:
|
|
41
38
|
Enabled: false
|
|
42
39
|
|
|
43
|
-
Metrics/
|
|
40
|
+
Metrics/MethodLength:
|
|
44
41
|
Enabled: false
|
|
45
42
|
|
|
46
|
-
Style/
|
|
43
|
+
Style/SafeNavigationChainLength:
|
|
47
44
|
Enabled: false
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
Lint/SelfAssignment:
|
|
50
47
|
Enabled: false
|
|
51
48
|
|
|
52
|
-
|
|
49
|
+
Sorbet/RedundantExtendTSig:
|
|
53
50
|
Enabled: false
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
Style/HashLookupMethod:
|
|
56
53
|
Enabled: false
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
Style/MethodCallWithoutArgsParentheses:
|
|
59
56
|
Enabled: false
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
Style/InfiniteLoop:
|
|
62
59
|
Enabled: false
|
|
63
60
|
|
|
64
61
|
Sorbet/ForbidTUnsafe:
|
|
65
62
|
Enabled: false
|
|
66
63
|
|
|
64
|
+
Sorbet/ForbidTSig:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
Lint/BooleanSymbol:
|
|
68
|
+
Enabled: false
|
|
69
|
+
|
|
67
70
|
Sorbet/ForbidTypeAliasedShapes:
|
|
68
71
|
Enabled: false
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
Metrics/CyclomaticComplexity:
|
|
71
74
|
Enabled: false
|
|
72
75
|
|
|
73
|
-
Style/
|
|
76
|
+
Style/OneClassPerFile:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
Sorbet/ForbidTHelpers:
|
|
80
|
+
Enabled: false
|
|
81
|
+
|
|
82
|
+
Style/FormatStringToken:
|
|
74
83
|
Enabled: false
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
Style/ItBlockParameter:
|
|
77
86
|
Enabled: false
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.4.
|
|
1
|
+
3.4.9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -31,7 +31,7 @@ You can call the `next` method to receive the next token.
|
|
|
31
31
|
Once the lexing is complete a token of type `:end_of_file` gets returned.
|
|
32
32
|
|
|
33
33
|
```rb
|
|
34
|
-
require '
|
|
34
|
+
require 'miniruby'
|
|
35
35
|
|
|
36
36
|
lexer = MiniRuby::Lexer.new(<<~RUBY)
|
|
37
37
|
foo = 5
|
|
@@ -51,7 +51,7 @@ lexer.next #=> Token(:end_of_file)
|
|
|
51
51
|
There is a simplified API that lets you generate an array of all tokens.
|
|
52
52
|
|
|
53
53
|
```rb
|
|
54
|
-
require '
|
|
54
|
+
require 'miniruby'
|
|
55
55
|
|
|
56
56
|
MiniRuby.lex(<<~RUBY)
|
|
57
57
|
foo = 5
|
|
@@ -69,7 +69,7 @@ with source code.
|
|
|
69
69
|
It returns `MiniRuby::Parser::Result` which contains the produced AST (Abstract Syntax Tree) and the list of encountered errors.
|
|
70
70
|
|
|
71
71
|
```rb
|
|
72
|
-
require '
|
|
72
|
+
require 'miniruby'
|
|
73
73
|
|
|
74
74
|
MiniRuby.parse(<<~RUBY)
|
|
75
75
|
a = 0
|
|
@@ -185,7 +185,7 @@ It returns `MiniRuby::BytecodeFunction`, an executable chunk of bytecode.
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
```rb
|
|
188
|
-
require '
|
|
188
|
+
require 'miniruby'
|
|
189
189
|
|
|
190
190
|
func = MiniRuby.compile(<<~RUBY)
|
|
191
191
|
a = 0
|
|
@@ -226,7 +226,7 @@ func.class #=> MiniRuby::BytecodeFunction
|
|
|
226
226
|
You can also use the compiler directly to compile an already produced AST.
|
|
227
227
|
|
|
228
228
|
```rb
|
|
229
|
-
require '
|
|
229
|
+
require 'miniruby'
|
|
230
230
|
|
|
231
231
|
parse_result = MiniRuby.parse(<<~RUBY)
|
|
232
232
|
a = 0
|
|
@@ -276,7 +276,7 @@ It returns the last computed value in the bytecode.
|
|
|
276
276
|
|
|
277
277
|
|
|
278
278
|
```rb
|
|
279
|
-
require '
|
|
279
|
+
require 'miniruby'
|
|
280
280
|
|
|
281
281
|
result = MiniRuby.interpret(<<~RUBY)
|
|
282
282
|
a = 0
|
|
@@ -297,7 +297,7 @@ result == 6 #=> true
|
|
|
297
297
|
You can also use the VM directly to interpret an already produced piece of bytecode.
|
|
298
298
|
|
|
299
299
|
```rb
|
|
300
|
-
require '
|
|
300
|
+
require 'miniruby'
|
|
301
301
|
|
|
302
302
|
func = MiniRuby::Compiler.compile_source(<<~RUBY)
|
|
303
303
|
a = 0
|