mvinl 0.1.3 → 0.1.4
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/README.md +3 -3
- data/Rakefile +9 -3
- data/lib/mvinl/info.rb +1 -1
- data/lib/mvinl/lexer.rb +6 -2
- data/lib/mvinl/parser.rb +1 -1
- data/mvinl.gemspec +1 -1
- data/rakelib/build.rake +25 -1
- data/spec/program_spec.rb +87 -0
- data/spec/spec_helper.rb +3 -0
- data/syntax/mvinl.tab.rb +172 -139
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e1464b5085d8cd24dc9b43f22063e675a8f6d249a2c3d716e29367726032e16
|
4
|
+
data.tar.gz: 0f8ee1fa140bf083afda23c1004e02bf3a8b3e0fcccd55f19d39135305b6b2dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449b3f884f41165b9892fa70e9a776dbd7208261ad1d237189d252fcec7f09fe6688873324b8045b9a85b1fdf7e707591057f4e1e7bf899fa48170f8e2cbf9a4
|
7
|
+
data.tar.gz: 0a09d81f07dcbc1c9253048526b3e60606b7a48c657f040c4a76e7d639d104b14148d5e2e640574429f4d1181eb85974543f74ec2b87077c29f3befe07aa2d76
|
data/README.md
CHANGED
@@ -15,8 +15,8 @@ gem install mvinl
|
|
15
15
|
or build and install it from this repo if you have it downloaded
|
16
16
|
|
17
17
|
```
|
18
|
-
|
19
|
-
|
18
|
+
rake build
|
19
|
+
rake install
|
20
20
|
```
|
21
21
|
|
22
22
|
## Usage
|
@@ -46,7 +46,7 @@ def (center x (/ x 2))
|
|
46
46
|
Buttom (center 1920)
|
47
47
|
(center 1080)
|
48
48
|
"Hello, MVinl!"
|
49
|
-
|
49
|
+
font_size: 21 # END_TAG is optional
|
50
50
|
```
|
51
51
|
|
52
52
|
## Contribute
|
data/Rakefile
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen-string-literal: true
|
2
2
|
|
3
|
-
|
4
|
-
rspec
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
|
6
|
+
t.rspec_opts = ENV['SPEC_OPTS'] || '--format documentation'
|
7
|
+
end
|
8
|
+
task default: :spec
|
9
|
+
rescue LoadError
|
10
|
+
warn 'Could not run rspec'
|
5
11
|
end
|
data/lib/mvinl/info.rb
CHANGED
data/lib/mvinl/lexer.rb
CHANGED
@@ -28,7 +28,9 @@ module MVinl
|
|
28
28
|
KEYWORD_ARG: /(#{ID_REGEX}):/,
|
29
29
|
ID: ID_REGEX,
|
30
30
|
GROUP: /@(#{ID_REGEX})/,
|
31
|
+
FLOAT: /[+-]?\d+\.\d+/,
|
31
32
|
NUMBER: /[+-]?\d+/,
|
33
|
+
MULTILINE_STRING: /"((?:\\.|[^"\\])*)"\s*\\\s*/,
|
32
34
|
STRING: /"((?:\\.|[^"\\])*)"/,
|
33
35
|
SYMBOL: /:(#{ID_REGEX})/,
|
34
36
|
COMMENT: /#/,
|
@@ -71,7 +73,7 @@ module MVinl
|
|
71
73
|
when :OPEN_PAREN then [:OPEN_PAREN, '(']
|
72
74
|
when :CLOSE_PAREN
|
73
75
|
unless Parser::STATE[:depth].positive?
|
74
|
-
raise UnexpectedTokenError, 'CLOSE_PARAM found
|
76
|
+
raise UnexpectedTokenError, 'CLOSE_PARAM found with no matching OPEN_PARAM'
|
75
77
|
end
|
76
78
|
|
77
79
|
[:CLOSE_PAREN, ')']
|
@@ -102,7 +104,9 @@ module MVinl
|
|
102
104
|
@in_group = true
|
103
105
|
[:GROUP, @ss[1]]
|
104
106
|
when :ID then [:ID, @ss.matched]
|
105
|
-
when :
|
107
|
+
when :MULTILINE_STRING
|
108
|
+
[:MULTILINE_STRING, @ss[1]]
|
109
|
+
when :NUMBER, :FLOAT, :STRING, :SYMBOL
|
106
110
|
# Values can't be used outside an property or a lambda
|
107
111
|
if !Parser::STATE[:in_prop] && !Parser::STATE[:depth].positive?
|
108
112
|
raise UnexpectedTokenError, "Looking for ID or OPEN_PAREN but found #{@last_type}"
|
data/lib/mvinl/parser.rb
CHANGED
data/mvinl.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
# Compile syntax file
|
27
27
|
s.files.delete(GRAMMAR_FILE)
|
28
28
|
s.files << COMPILED_FILE
|
29
|
-
s.require_paths = %w[lib
|
29
|
+
s.require_paths = %w[lib syntax]
|
30
30
|
s.executables << 'imvnl'
|
31
31
|
|
32
32
|
s.add_dependency 'pp', '~> 0.6.2'
|
data/rakelib/build.rake
CHANGED
@@ -1,8 +1,32 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
2
|
|
3
|
+
require 'rubygems/package'
|
4
|
+
require 'mvinl/info'
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
require 'shellwords'
|
8
|
+
|
3
9
|
GRAMMAR_FILE = 'syntax/mvinl.y'
|
4
10
|
COMPILED_FILE = 'syntax/mvinl.tab.rb'
|
5
11
|
|
6
|
-
|
12
|
+
gemspec = Gem::Specification.load 'mvinl.gemspec'
|
13
|
+
gemfile = "#{gemspec.name}-#{gemspec.version}.gem"
|
14
|
+
|
15
|
+
task push: [:build] do
|
16
|
+
#binding.pry
|
17
|
+
system('gem', 'push', '-v', Shellwords.escape(gemspec.version.to_s), Shellwords.escape(gemspec.name))
|
18
|
+
end
|
19
|
+
|
20
|
+
task install: [:build] do
|
21
|
+
Gem.install(gemfile)
|
22
|
+
puts "Installed #{gemfile}"
|
23
|
+
end
|
24
|
+
|
25
|
+
task build: [:compile] do
|
26
|
+
Gem::Package.build(gemspec)
|
27
|
+
puts "Build #{gemfile}"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :compile do
|
7
31
|
system('racc', GRAMMAR_FILE, '-o', COMPILED_FILE)
|
8
32
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
require 'mvinl'
|
5
|
+
|
6
|
+
describe MVinl, '#eval' do
|
7
|
+
context 'no input' do
|
8
|
+
it 'returns an empty hash' do
|
9
|
+
result = MVinl.eval('')
|
10
|
+
expect(result).to eq({})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'groups' do
|
14
|
+
it 'retruns a single group' do
|
15
|
+
result = MVinl.eval('@x')
|
16
|
+
expect(result).to eq({ x: {} })
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns two groups' do
|
20
|
+
result = MVinl.eval('@x @y')
|
21
|
+
expect(result).to eq({ x: {}, y: {} })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context 'properties' do
|
25
|
+
it 'return a single property' do
|
26
|
+
result = MVinl.eval('@x a')
|
27
|
+
expect(result).to eq({ x: { a: [[], {}] } })
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns two properties' do
|
31
|
+
result = MVinl.eval('@x a b')
|
32
|
+
expect(result).to eq({ x: { a: [[], {}], b: [[], {}] } })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'functions' do
|
37
|
+
it 'Stores function definition with \'+\' OPER and no arguments' do
|
38
|
+
MVinl.eval('def (f (+ 1))')
|
39
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: [], body: [:+, 1] } })
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'Stores function definition with \'-\' OPER and no arguments' do
|
43
|
+
MVinl.eval('def (f (- 1))')
|
44
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: [], body: [:-, 1] } })
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'Stores function definition with \'*\' OPER and no arguments' do
|
48
|
+
MVinl.eval('def (f (* 1))')
|
49
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: [], body: [:*, 1] } })
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'Stores function definition with \'/\' OPER and no arguments' do
|
53
|
+
MVinl.eval('def (f (/ 1))')
|
54
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: [], body: [:/, 1] } })
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'Stores function definition with \'%\' OPER and no arguments' do
|
58
|
+
MVinl.eval('def (f (% 1))')
|
59
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: [], body: [:%, 1] } })
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'Stores function definition with a single argument' do
|
63
|
+
MVinl.eval('def (f a (+ a a))')
|
64
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: %I[a], body: %I[+ a a] } })
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'Stores function definition with two arguments' do
|
68
|
+
MVinl.eval('def (f a b (+ a b))')
|
69
|
+
expect(MVinl::Parser::FUNCTIONS).to eq({ f: { args: %I[a b], body: %I[+ a b] } })
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'Evaluate anonimous function' do
|
73
|
+
result = MVinl.eval('@x x (+ 2 2)')
|
74
|
+
expect(result).to eq({ x: { x: [[4], {}] } })
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'Evaluate function' do
|
78
|
+
result = MVinl.eval('def (foo (+ 5)) @x x (foo)')
|
79
|
+
expect(result).to eq({ x: { x: [[5], {}] } })
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'Evaluate function calling another function' do
|
83
|
+
result = MVinl.eval('def (foo (+ 5)) def (bar (foo)) @x x (bar)')
|
84
|
+
expect(result).to eq({ x: { x: [[5], {}] } })
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/syntax/mvinl.tab.rb
CHANGED
@@ -8,7 +8,7 @@ require 'racc/parser.rb'
|
|
8
8
|
module MVinl
|
9
9
|
class Program < Racc::Parser
|
10
10
|
|
11
|
-
module_eval(<<'...end mvinl.y/module_eval...', 'mvinl.y',
|
11
|
+
module_eval(<<'...end mvinl.y/module_eval...', 'mvinl.y', 112)
|
12
12
|
|
13
13
|
FUNCTIONS = {}
|
14
14
|
STATE = {
|
@@ -47,8 +47,8 @@ module_eval(<<'...end mvinl.y/module_eval...', 'mvinl.y', 105)
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
if FUNCTIONS.key?(operator
|
51
|
-
function = FUNCTIONS[operator
|
50
|
+
if FUNCTIONS.key?(operator)
|
51
|
+
function = FUNCTIONS[operator]
|
52
52
|
raise MVinl::ParserError, "Argument mismatch for #{operator}" if operands.size != function[:args].size
|
53
53
|
|
54
54
|
# Map arguments to operands
|
@@ -59,7 +59,7 @@ module_eval(<<'...end mvinl.y/module_eval...', 'mvinl.y', 105)
|
|
59
59
|
evaluate_pn(function[0], function[1..], new_context)
|
60
60
|
else
|
61
61
|
begin
|
62
|
-
operands.reduce(operator
|
62
|
+
operands.reduce(operator)
|
63
63
|
rescue NoMethodError
|
64
64
|
raise MVinl::ParserError, "Unknown operator: #{operator}"
|
65
65
|
end
|
@@ -81,107 +81,116 @@ module_eval(<<'...end mvinl.y/module_eval...', 'mvinl.y', 105)
|
|
81
81
|
##### State transition tables begin ###
|
82
82
|
|
83
83
|
racc_action_table = [
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
-9, 8, -9, -9, -9, 11, 2, 15, 5, 6,
|
85
|
+
15, -9, 28, 29, 41, 15, -9, 7, 24, 25,
|
86
|
+
27, 28, 29, 17, 11, 41, 15, 37, 15, 24,
|
87
|
+
25, 27, 28, 29, 43, 11, 43, 54, nil, 15,
|
88
|
+
24, 25, 27, 28, 29, nil, 11, 43, 54, nil,
|
89
|
+
15, 24, 25, 27, 28, 29, nil, 11, 43, nil,
|
90
|
+
nil, 15, 24, 25, 27, 28, 29, nil, 11, 43,
|
91
|
+
nil, nil, 15, -15, 24, 25, 27, 28, 29, nil,
|
92
|
+
11, 24, 25, 27, 28, 29, nil, 11 ]
|
91
93
|
|
92
94
|
racc_action_check = [
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
13, 2, 13, 13, 13, 7, 1, 9, 1, 1,
|
96
|
+
10, 13, 29, 29, 30, 30, 13, 1, 19, 19,
|
97
|
+
19, 19, 19, 12, 19, 32, 32, 20, 19, 47,
|
98
|
+
47, 47, 47, 47, 31, 47, 47, 47, nil, 47,
|
99
|
+
48, 48, 48, 48, 48, nil, 48, 48, 48, nil,
|
100
|
+
48, 49, 49, 49, 49, 49, nil, 49, 49, nil,
|
101
|
+
nil, 49, 50, 50, 50, 50, 50, nil, 50, 50,
|
102
|
+
nil, nil, 50, 18, 18, 18, 18, 18, 18, nil,
|
103
|
+
18, 36, 36, 36, 36, 36, nil, 36 ]
|
100
104
|
|
101
105
|
racc_action_pointer = [
|
102
|
-
nil,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
nil, nil, nil, nil, nil, nil, nil,
|
107
|
-
|
106
|
+
nil, 6, 1, nil, nil, nil, nil, -7, nil, -9,
|
107
|
+
-6, nil, 19, 0, nil, nil, nil, nil, 68, 12,
|
108
|
+
22, nil, nil, nil, nil, nil, nil, nil, nil, 3,
|
109
|
+
-1, 21, 10, nil, nil, nil, 75, nil, nil, nil,
|
110
|
+
nil, nil, nil, nil, nil, nil, nil, 23, 34, 45,
|
111
|
+
56, nil, nil, nil, nil, nil, nil, nil, nil ]
|
108
112
|
|
109
113
|
racc_action_default = [
|
110
|
-
-1, -
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
114
|
+
-1, -44, -44, -2, -3, -4, -6, -44, 59, -5,
|
115
|
+
-44, -32, -7, -13, -12, -43, -34, -8, -10, -44,
|
116
|
+
-11, -14, -19, -20, -21, -22, -23, -24, -25, -44,
|
117
|
+
-44, -37, -44, -35, -36, -16, -44, -18, -26, -38,
|
118
|
+
-38, -42, -27, -33, -34, -34, -17, -44, -44, -44,
|
119
|
+
-44, -30, -39, -40, -41, -31, -28, -37, -29 ]
|
116
120
|
|
117
121
|
racc_goto_table = [
|
118
|
-
10, 14, 16, 34,
|
119
|
-
3, 4,
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
10, 14, 16, 34, 40, 21, 45, 19, 1, 42,
|
123
|
+
47, 48, 32, 3, 4, 9, 12, 13, 18, 20,
|
124
|
+
35, 36, 39, 46, 44, 51, 55, 56, 58, 38,
|
125
|
+
31, nil, nil, 34, 34, 49, 50, nil, nil, 53,
|
126
|
+
53, nil, 32, 32 ]
|
123
127
|
|
124
128
|
racc_goto_check = [
|
125
|
-
|
126
|
-
2, 3,
|
127
|
-
|
128
|
-
|
129
|
-
|
129
|
+
16, 9, 9, 13, 20, 10, 20, 17, 1, 19,
|
130
|
+
21, 21, 16, 2, 3, 4, 5, 6, 7, 8,
|
131
|
+
11, 12, 9, 10, 9, 19, 19, 19, 19, 15,
|
132
|
+
18, nil, nil, 13, 13, 17, 17, nil, nil, 9,
|
133
|
+
9, nil, 16, 16 ]
|
130
134
|
|
131
135
|
racc_goto_pointer = [
|
132
|
-
nil,
|
133
|
-
|
136
|
+
nil, 8, 12, 13, 9, 7, 8, 5, 1, -8,
|
137
|
+
-13, 0, 1, -16, nil, 0, -7, -9, 11, -22,
|
138
|
+
-26, -29 ]
|
134
139
|
|
135
140
|
racc_goto_default = [
|
136
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
137
|
-
|
141
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 33,
|
142
|
+
52, nil, nil, 22, 23, 26, 30, nil, 57, nil,
|
143
|
+
nil, nil ]
|
138
144
|
|
139
145
|
racc_reduce_table = [
|
140
146
|
0, 0, :racc_error,
|
141
|
-
0,
|
142
|
-
2,
|
143
|
-
2,
|
144
|
-
2,
|
145
|
-
2,
|
146
|
-
0,
|
147
|
-
2,
|
148
|
-
3,
|
149
|
-
1,
|
150
|
-
2,
|
151
|
-
3,
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
2,
|
158
|
-
|
159
|
-
1,
|
160
|
-
1,
|
161
|
-
1,
|
162
|
-
1,
|
163
|
-
1,
|
164
|
-
1,
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
4,
|
169
|
-
4,
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
2,
|
176
|
-
|
147
|
+
0, 18, :_reduce_1,
|
148
|
+
2, 18, :_reduce_2,
|
149
|
+
2, 18, :_reduce_3,
|
150
|
+
2, 18, :_reduce_4,
|
151
|
+
2, 19, :_reduce_5,
|
152
|
+
0, 21, :_reduce_6,
|
153
|
+
2, 21, :_reduce_7,
|
154
|
+
3, 21, :_reduce_8,
|
155
|
+
1, 22, :_reduce_9,
|
156
|
+
2, 22, :_reduce_10,
|
157
|
+
3, 22, :_reduce_11,
|
158
|
+
1, 23, :_reduce_12,
|
159
|
+
0, 24, :_reduce_13,
|
160
|
+
2, 24, :_reduce_14,
|
161
|
+
0, 25, :_reduce_15,
|
162
|
+
2, 25, :_reduce_16,
|
163
|
+
2, 28, :_reduce_17,
|
164
|
+
1, 29, :_reduce_18,
|
165
|
+
1, 27, :_reduce_19,
|
166
|
+
1, 27, :_reduce_20,
|
167
|
+
1, 30, :_reduce_21,
|
168
|
+
1, 30, :_reduce_22,
|
169
|
+
1, 30, :_reduce_23,
|
170
|
+
1, 30, :_reduce_24,
|
171
|
+
1, 32, :_reduce_25,
|
172
|
+
2, 32, :_reduce_26,
|
173
|
+
6, 20, :_reduce_27,
|
174
|
+
4, 35, :_reduce_28,
|
175
|
+
4, 35, :_reduce_29,
|
176
|
+
4, 31, :_reduce_30,
|
177
|
+
4, 31, :_reduce_31,
|
178
|
+
1, 33, :_reduce_32,
|
179
|
+
1, 36, :_reduce_33,
|
180
|
+
0, 34, :_reduce_34,
|
181
|
+
2, 34, :_reduce_35,
|
182
|
+
2, 34, :_reduce_36,
|
177
183
|
2, 34, :_reduce_37,
|
178
|
-
|
179
|
-
2,
|
180
|
-
|
184
|
+
0, 38, :_reduce_38,
|
185
|
+
2, 38, :_reduce_39,
|
186
|
+
2, 38, :_reduce_40,
|
187
|
+
2, 38, :_reduce_41,
|
188
|
+
1, 37, :_reduce_42,
|
189
|
+
1, 26, :_reduce_43 ]
|
181
190
|
|
182
|
-
racc_reduce_n =
|
191
|
+
racc_reduce_n = 44
|
183
192
|
|
184
|
-
racc_shift_n =
|
193
|
+
racc_shift_n = 59
|
185
194
|
|
186
195
|
racc_token_table = {
|
187
196
|
false => 0,
|
@@ -191,16 +200,18 @@ racc_token_table = {
|
|
191
200
|
:END_TAG => 4,
|
192
201
|
:KEYWORD_ARG => 5,
|
193
202
|
:NUMBER => 6,
|
194
|
-
:
|
203
|
+
:FLOAT => 7,
|
195
204
|
:SYMBOL => 8,
|
196
|
-
:
|
197
|
-
:
|
198
|
-
:
|
199
|
-
:
|
200
|
-
:
|
201
|
-
:
|
205
|
+
:STRING => 9,
|
206
|
+
:MULTILINE_STRING => 10,
|
207
|
+
:DEF => 11,
|
208
|
+
:OPEN_PAREN => 12,
|
209
|
+
:CLOSE_PAREN => 13,
|
210
|
+
:polish_notation => 14,
|
211
|
+
:OPER => 15,
|
212
|
+
:ID => 16 }
|
202
213
|
|
203
|
-
racc_nt_base =
|
214
|
+
racc_nt_base = 17
|
204
215
|
|
205
216
|
racc_use_result_var = false
|
206
217
|
|
@@ -229,13 +240,15 @@ Racc_token_to_s_table = [
|
|
229
240
|
"END_TAG",
|
230
241
|
"KEYWORD_ARG",
|
231
242
|
"NUMBER",
|
232
|
-
"
|
243
|
+
"FLOAT",
|
233
244
|
"SYMBOL",
|
245
|
+
"STRING",
|
246
|
+
"MULTILINE_STRING",
|
234
247
|
"DEF",
|
235
|
-
"OPER",
|
236
248
|
"OPEN_PAREN",
|
237
249
|
"CLOSE_PAREN",
|
238
250
|
"polish_notation",
|
251
|
+
"OPER",
|
239
252
|
"ID",
|
240
253
|
"$start",
|
241
254
|
"program",
|
@@ -246,16 +259,18 @@ Racc_token_to_s_table = [
|
|
246
259
|
"prop_id",
|
247
260
|
"positional_args",
|
248
261
|
"keyword_args",
|
249
|
-
"lambda",
|
250
262
|
"identifier",
|
251
263
|
"super_value",
|
252
264
|
"keyword_arg",
|
253
265
|
"keyword_arg_id",
|
254
266
|
"value",
|
267
|
+
"lambda",
|
268
|
+
"string",
|
255
269
|
"open_paren",
|
256
270
|
"args",
|
257
271
|
"polish_notation_def",
|
258
272
|
"close_paren",
|
273
|
+
"operator",
|
259
274
|
"params" ]
|
260
275
|
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
|
261
276
|
|
@@ -331,46 +346,40 @@ module_eval(<<'.,.,', 'mvinl.y', 28)
|
|
331
346
|
end
|
332
347
|
.,.,
|
333
348
|
|
334
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
349
|
+
module_eval(<<'.,.,', 'mvinl.y', 31)
|
335
350
|
def _reduce_12(val, _values)
|
336
|
-
|
351
|
+
STATE[:in_prop] = true; val[0]
|
337
352
|
end
|
338
353
|
.,.,
|
339
354
|
|
340
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
355
|
+
module_eval(<<'.,.,', 'mvinl.y', 34)
|
341
356
|
def _reduce_13(val, _values)
|
342
|
-
|
357
|
+
Array.new
|
343
358
|
end
|
344
359
|
.,.,
|
345
360
|
|
346
361
|
module_eval(<<'.,.,', 'mvinl.y', 35)
|
347
362
|
def _reduce_14(val, _values)
|
348
|
-
Array.new
|
349
|
-
end
|
350
|
-
.,.,
|
351
|
-
|
352
|
-
module_eval(<<'.,.,', 'mvinl.y', 36)
|
353
|
-
def _reduce_15(val, _values)
|
354
363
|
val[0] << val[1]
|
355
364
|
end
|
356
365
|
.,.,
|
357
366
|
|
358
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
359
|
-
def
|
367
|
+
module_eval(<<'.,.,', 'mvinl.y', 38)
|
368
|
+
def _reduce_15(val, _values)
|
360
369
|
Hash.new
|
361
370
|
end
|
362
371
|
.,.,
|
363
372
|
|
364
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
365
|
-
def
|
373
|
+
module_eval(<<'.,.,', 'mvinl.y', 41)
|
374
|
+
def _reduce_16(val, _values)
|
366
375
|
STATE[:keyword_arg_depth] = 0
|
367
376
|
val[0].merge(val[1])
|
368
377
|
|
369
378
|
end
|
370
379
|
.,.,
|
371
380
|
|
372
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
373
|
-
def
|
381
|
+
module_eval(<<'.,.,', 'mvinl.y', 48)
|
382
|
+
def _reduce_17(val, _values)
|
374
383
|
STATE[:in_keyword_arg] = false
|
375
384
|
STATE[:keyword_arg_depth] += 1
|
376
385
|
{val[0].to_sym => val[1]}
|
@@ -378,27 +387,33 @@ module_eval(<<'.,.,', 'mvinl.y', 49)
|
|
378
387
|
end
|
379
388
|
.,.,
|
380
389
|
|
381
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
382
|
-
def
|
390
|
+
module_eval(<<'.,.,', 'mvinl.y', 54)
|
391
|
+
def _reduce_18(val, _values)
|
383
392
|
STATE[:in_keyword_arg] = true; val[0]
|
384
393
|
end
|
385
394
|
.,.,
|
386
395
|
|
396
|
+
module_eval(<<'.,.,', 'mvinl.y', 57)
|
397
|
+
def _reduce_19(val, _values)
|
398
|
+
val[0]
|
399
|
+
end
|
400
|
+
.,.,
|
401
|
+
|
387
402
|
module_eval(<<'.,.,', 'mvinl.y', 58)
|
388
403
|
def _reduce_20(val, _values)
|
389
404
|
val[0]
|
390
405
|
end
|
391
406
|
.,.,
|
392
407
|
|
393
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
408
|
+
module_eval(<<'.,.,', 'mvinl.y', 61)
|
394
409
|
def _reduce_21(val, _values)
|
395
|
-
val[0]
|
410
|
+
val[0].to_i
|
396
411
|
end
|
397
412
|
.,.,
|
398
413
|
|
399
414
|
module_eval(<<'.,.,', 'mvinl.y', 62)
|
400
415
|
def _reduce_22(val, _values)
|
401
|
-
val[0].
|
416
|
+
val[0].to_f
|
402
417
|
end
|
403
418
|
.,.,
|
404
419
|
|
@@ -414,68 +429,68 @@ module_eval(<<'.,.,', 'mvinl.y', 64)
|
|
414
429
|
end
|
415
430
|
.,.,
|
416
431
|
|
417
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
432
|
+
module_eval(<<'.,.,', 'mvinl.y', 67)
|
418
433
|
def _reduce_25(val, _values)
|
419
|
-
|
420
|
-
|
434
|
+
val[0]
|
421
435
|
end
|
422
436
|
.,.,
|
423
437
|
|
424
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
438
|
+
module_eval(<<'.,.,', 'mvinl.y', 68)
|
425
439
|
def _reduce_26(val, _values)
|
426
|
-
|
440
|
+
"#{val[0]} #{val[1]}"
|
427
441
|
end
|
428
442
|
.,.,
|
429
443
|
|
430
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
444
|
+
module_eval(<<'.,.,', 'mvinl.y', 73)
|
431
445
|
def _reduce_27(val, _values)
|
432
|
-
|
446
|
+
define_function(val[2], val[3], val[4])
|
447
|
+
|
433
448
|
end
|
434
449
|
.,.,
|
435
450
|
|
436
451
|
module_eval(<<'.,.,', 'mvinl.y', 77)
|
437
452
|
def _reduce_28(val, _values)
|
438
|
-
|
453
|
+
[val[1], *val[2]]
|
439
454
|
end
|
440
455
|
.,.,
|
441
456
|
|
442
457
|
module_eval(<<'.,.,', 'mvinl.y', 78)
|
443
458
|
def _reduce_29(val, _values)
|
444
|
-
|
459
|
+
[val[1], *val[2]]
|
445
460
|
end
|
446
461
|
.,.,
|
447
462
|
|
448
463
|
module_eval(<<'.,.,', 'mvinl.y', 81)
|
449
464
|
def _reduce_30(val, _values)
|
450
|
-
|
465
|
+
evaluate_pn(val[1], val[2])
|
451
466
|
end
|
452
467
|
.,.,
|
453
468
|
|
454
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
469
|
+
module_eval(<<'.,.,', 'mvinl.y', 82)
|
455
470
|
def _reduce_31(val, _values)
|
456
|
-
|
471
|
+
evaluate_pn(val[1], val[2])
|
457
472
|
end
|
458
473
|
.,.,
|
459
474
|
|
460
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
475
|
+
module_eval(<<'.,.,', 'mvinl.y', 85)
|
461
476
|
def _reduce_32(val, _values)
|
462
|
-
|
477
|
+
STATE[:depth] += 1
|
463
478
|
end
|
464
479
|
.,.,
|
465
480
|
|
466
481
|
module_eval(<<'.,.,', 'mvinl.y', 88)
|
467
482
|
def _reduce_33(val, _values)
|
468
|
-
|
483
|
+
STATE[:depth] -= 1
|
469
484
|
end
|
470
485
|
.,.,
|
471
486
|
|
472
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
487
|
+
module_eval(<<'.,.,', 'mvinl.y', 91)
|
473
488
|
def _reduce_34(val, _values)
|
474
|
-
|
489
|
+
Array.new
|
475
490
|
end
|
476
491
|
.,.,
|
477
492
|
|
478
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
493
|
+
module_eval(<<'.,.,', 'mvinl.y', 92)
|
479
494
|
def _reduce_35(val, _values)
|
480
495
|
val[0] << val[1]
|
481
496
|
end
|
@@ -483,7 +498,7 @@ module_eval(<<'.,.,', 'mvinl.y', 90)
|
|
483
498
|
|
484
499
|
module_eval(<<'.,.,', 'mvinl.y', 93)
|
485
500
|
def _reduce_36(val, _values)
|
486
|
-
|
501
|
+
val[0] << val[1]
|
487
502
|
end
|
488
503
|
.,.,
|
489
504
|
|
@@ -493,13 +508,13 @@ module_eval(<<'.,.,', 'mvinl.y', 94)
|
|
493
508
|
end
|
494
509
|
.,.,
|
495
510
|
|
496
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
511
|
+
module_eval(<<'.,.,', 'mvinl.y', 97)
|
497
512
|
def _reduce_38(val, _values)
|
498
|
-
|
513
|
+
Array.new
|
499
514
|
end
|
500
515
|
.,.,
|
501
516
|
|
502
|
-
module_eval(<<'.,.,', 'mvinl.y',
|
517
|
+
module_eval(<<'.,.,', 'mvinl.y', 98)
|
503
518
|
def _reduce_39(val, _values)
|
504
519
|
val[0] << val[1]
|
505
520
|
end
|
@@ -507,6 +522,24 @@ module_eval(<<'.,.,', 'mvinl.y', 96)
|
|
507
522
|
|
508
523
|
module_eval(<<'.,.,', 'mvinl.y', 99)
|
509
524
|
def _reduce_40(val, _values)
|
525
|
+
val[0] << val[1]
|
526
|
+
end
|
527
|
+
.,.,
|
528
|
+
|
529
|
+
module_eval(<<'.,.,', 'mvinl.y', 100)
|
530
|
+
def _reduce_41(val, _values)
|
531
|
+
val[0] << val[1]
|
532
|
+
end
|
533
|
+
.,.,
|
534
|
+
|
535
|
+
module_eval(<<'.,.,', 'mvinl.y', 103)
|
536
|
+
def _reduce_42(val, _values)
|
537
|
+
val[0].to_sym
|
538
|
+
end
|
539
|
+
.,.,
|
540
|
+
|
541
|
+
module_eval(<<'.,.,', 'mvinl.y', 106)
|
542
|
+
def _reduce_43(val, _values)
|
510
543
|
val[0].to_sym
|
511
544
|
end
|
512
545
|
.,.,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvinl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pp
|
@@ -46,6 +46,8 @@ files:
|
|
46
46
|
- lib/mvinl/parser.rb
|
47
47
|
- mvinl.gemspec
|
48
48
|
- rakelib/build.rake
|
49
|
+
- spec/program_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
49
51
|
- spec/stack.mvnl
|
50
52
|
- syntax/mvinl.tab.rb
|
51
53
|
homepage: https://rubygems.org/gems/mvinl
|
@@ -57,9 +59,6 @@ post_install_message:
|
|
57
59
|
rdoc_options: []
|
58
60
|
require_paths:
|
59
61
|
- lib
|
60
|
-
- bin
|
61
|
-
- s
|
62
|
-
- rakelib
|
63
62
|
- syntax
|
64
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|