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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f891e7bb1683b84d918155e32b06fdf03ae4d00791676e4b1dc467c30d495b90
4
- data.tar.gz: c96e8a9930ed532580014843594d70d3fb025089fdd06708e9440b5316c2a772
3
+ metadata.gz: 2e1464b5085d8cd24dc9b43f22063e675a8f6d249a2c3d716e29367726032e16
4
+ data.tar.gz: 0f8ee1fa140bf083afda23c1004e02bf3a8b3e0fcccd55f19d39135305b6b2dd
5
5
  SHA512:
6
- metadata.gz: febf482245e910fe310efae6a5aaaa115769830475678ba8b0e8b0d65dee6b0b4e22f5a4d9d5e5236f5a8e35e0125f55d406a155c6e2b3e4441ced8f7dfe05de
7
- data.tar.gz: fb604a7c640da0406c0d0a1190ba0a684491728cd1b9b666da5e870bd754b50d8ebde6ad5a2e3dfea0aecab98e98fc60e7dfbb3d35f94526d5294e981ef91bb1
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
- gem build
19
- gem install ./mvinl-0.1.0.gem
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
- font_size: 21 # END_TAG is optional
49
+ font_size: 21 # END_TAG is optional
50
50
  ```
51
51
 
52
52
  ## Contribute
data/Rakefile CHANGED
@@ -1,5 +1,11 @@
1
- task default: %w[spec]
1
+ # frozen-string-literal: true
2
2
 
3
- task :spec do
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
@@ -6,7 +6,7 @@
6
6
  # See Copyright Notice in mvnil.rb
7
7
 
8
8
  module MVinl
9
- VERSION = '0.1.3'
9
+ VERSION = '0.1.4'
10
10
  Version = VERSION
11
11
  Copyright = 'Copyright (c) 2024, Daniel Sierpiński'
12
12
  end
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 winth no matching OPEN_PARAM'
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 :NUMBER, :STRING, :SYMBOL
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
@@ -6,7 +6,7 @@ Copyright (c) 2024, Daniel Sierpiński All rights reserved.
6
6
  See Copyright Notice in mvnil.rb
7
7
  =end
8
8
 
9
- require_relative '../../syntax/mvinl.tab'
9
+ require 'mvinl.tab'
10
10
 
11
11
  class MVinl::Parser < MVinl::Program
12
12
  def initialize(lexer, debug: false)
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 bin s rakelib syntax]
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
- task 'build' do
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
@@ -0,0 +1,3 @@
1
+ # frozen-string-literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
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', 105)
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.to_sym)
51
- function = FUNCTIONS[operator.to_sym]
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.to_sym)
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
- 2, 8, 5, 6, 30, 26, 27, 28, 15, 7,
85
- 11, 11, 15, 15, 26, 27, 28, 15, 17, 11,
86
- 41, 48, 15, 26, 27, 28, 37, 41, 11, 41,
87
- 48, 15, 26, 27, 28, 43, nil, 11, 41, 15,
88
- 15, 26, 27, 28, nil, nil, 11, 41, nil, 15,
89
- -14, -14, -14, -14, nil, nil, 11, -16, 26, 27,
90
- 28, nil, nil, 11, 26, 27, 28, nil, nil, 11 ]
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
- 1, 2, 1, 1, 20, 21, 21, 21, 20, 1,
94
- 21, 7, 9, 21, 38, 38, 38, 10, 12, 38,
95
- 38, 38, 38, 39, 39, 39, 22, 31, 39, 39,
96
- 39, 39, 50, 50, 50, 32, nil, 50, 50, 32,
97
- 50, 51, 51, 51, nil, nil, 51, 51, nil, 51,
98
- 13, 13, 13, 13, nil, nil, 13, 18, 18, 18,
99
- 18, nil, nil, 18, 36, 36, 36, nil, nil, 36 ]
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, 0, 1, nil, nil, nil, nil, 0, nil, -2,
103
- 3, nil, 14, 45, nil, nil, nil, nil, 52, nil,
104
- -6, -1, 21, nil, nil, nil, nil, nil, nil, nil,
105
- nil, 15, 25, nil, nil, nil, 58, nil, 8, 17,
106
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
107
- 26, 35, nil, nil, nil ]
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, -41, -41, -2, -3, -4, -6, -41, 55, -5,
111
- -41, -30, -7, -9, -13, -40, -32, -8, -10, -12,
112
- -41, -41, -11, -15, -20, -21, -22, -23, -24, -36,
113
- -36, -35, -41, -33, -34, -17, -41, -19, -41, -41,
114
- -25, -31, -32, -32, -18, -28, -37, -38, -39, -29,
115
- -41, -41, -26, -35, -27 ]
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, 23, 38, 39, 1, 21, 40,
119
- 3, 4, 29, 9, 32, 12, 45, 49, 13, 18,
120
- 22, 19, 44, 35, 42, 36, 31, nil, 52, 54,
121
- 47, 47, 34, 34, 50, 51, nil, nil, nil, nil,
122
- nil, nil, nil, 32, 32 ]
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
- 15, 10, 10, 14, 11, 19, 19, 1, 16, 18,
126
- 2, 3, 10, 4, 15, 5, 18, 18, 6, 7,
127
- 8, 9, 11, 12, 10, 13, 17, nil, 18, 18,
128
- 10, 10, 14, 14, 16, 16, nil, nil, nil, nil,
129
- nil, nil, nil, 15, 15 ]
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, 7, 9, 10, 7, 6, 9, 6, 2, 8,
133
- -8, -14, 1, 3, -18, -7, -8, 5, -22, -24 ]
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, 25,
137
- 33, 46, nil, nil, 24, 20, nil, 53, nil, nil ]
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, 16, :_reduce_1,
142
- 2, 16, :_reduce_2,
143
- 2, 16, :_reduce_3,
144
- 2, 16, :_reduce_4,
145
- 2, 17, :_reduce_5,
146
- 0, 19, :_reduce_6,
147
- 2, 19, :_reduce_7,
148
- 3, 19, :_reduce_8,
149
- 1, 20, :_reduce_9,
150
- 2, 20, :_reduce_10,
151
- 3, 20, :_reduce_11,
152
- 2, 20, :_reduce_12,
153
- 1, 21, :_reduce_13,
154
- 0, 22, :_reduce_14,
155
- 2, 22, :_reduce_15,
156
- 0, 23, :_reduce_16,
157
- 2, 23, :_reduce_17,
158
- 2, 27, :_reduce_18,
159
- 1, 28, :_reduce_19,
160
- 1, 26, :_reduce_20,
161
- 1, 26, :_reduce_21,
162
- 1, 29, :_reduce_22,
163
- 1, 29, :_reduce_23,
164
- 1, 29, :_reduce_24,
165
- 6, 18, :_reduce_25,
166
- 4, 32, :_reduce_26,
167
- 4, 32, :_reduce_27,
168
- 4, 24, :_reduce_28,
169
- 4, 24, :_reduce_29,
170
- 1, 30, :_reduce_30,
171
- 1, 33, :_reduce_31,
172
- 0, 31, :_reduce_32,
173
- 2, 31, :_reduce_33,
174
- 2, 31, :_reduce_34,
175
- 2, 31, :_reduce_35,
176
- 0, 34, :_reduce_36,
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
- 2, 34, :_reduce_38,
179
- 2, 34, :_reduce_39,
180
- 1, 25, :_reduce_40 ]
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 = 41
191
+ racc_reduce_n = 44
183
192
 
184
- racc_shift_n = 55
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
- :STRING => 7,
203
+ :FLOAT => 7,
195
204
  :SYMBOL => 8,
196
- :DEF => 9,
197
- :OPER => 10,
198
- :OPEN_PAREN => 11,
199
- :CLOSE_PAREN => 12,
200
- :polish_notation => 13,
201
- :ID => 14 }
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 = 15
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
- "STRING",
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', 29)
349
+ module_eval(<<'.,.,', 'mvinl.y', 31)
335
350
  def _reduce_12(val, _values)
336
- create_property(val[0], val[1])
351
+ STATE[:in_prop] = true; val[0]
337
352
  end
338
353
  .,.,
339
354
 
340
- module_eval(<<'.,.,', 'mvinl.y', 32)
355
+ module_eval(<<'.,.,', 'mvinl.y', 34)
341
356
  def _reduce_13(val, _values)
342
- STATE[:in_prop] = true; val[0]
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', 39)
359
- def _reduce_16(val, _values)
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', 42)
365
- def _reduce_17(val, _values)
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', 49)
373
- def _reduce_18(val, _values)
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', 55)
382
- def _reduce_19(val, _values)
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', 59)
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].to_i
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', 69)
432
+ module_eval(<<'.,.,', 'mvinl.y', 67)
418
433
  def _reduce_25(val, _values)
419
- define_function(val[2], val[3], val[4])
420
-
434
+ val[0]
421
435
  end
422
436
  .,.,
423
437
 
424
- module_eval(<<'.,.,', 'mvinl.y', 73)
438
+ module_eval(<<'.,.,', 'mvinl.y', 68)
425
439
  def _reduce_26(val, _values)
426
- [val[1], *val[2]]
440
+ "#{val[0]} #{val[1]}"
427
441
  end
428
442
  .,.,
429
443
 
430
- module_eval(<<'.,.,', 'mvinl.y', 74)
444
+ module_eval(<<'.,.,', 'mvinl.y', 73)
431
445
  def _reduce_27(val, _values)
432
- [val[1], *val[2]]
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
- evaluate_pn(val[1], val[2])
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
- evaluate_pn(val[1], val[2])
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
- STATE[:depth] += 1
465
+ evaluate_pn(val[1], val[2])
451
466
  end
452
467
  .,.,
453
468
 
454
- module_eval(<<'.,.,', 'mvinl.y', 84)
469
+ module_eval(<<'.,.,', 'mvinl.y', 82)
455
470
  def _reduce_31(val, _values)
456
- STATE[:depth] -= 1
471
+ evaluate_pn(val[1], val[2])
457
472
  end
458
473
  .,.,
459
474
 
460
- module_eval(<<'.,.,', 'mvinl.y', 87)
475
+ module_eval(<<'.,.,', 'mvinl.y', 85)
461
476
  def _reduce_32(val, _values)
462
- Array.new
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
- val[0] << val[1]
483
+ STATE[:depth] -= 1
469
484
  end
470
485
  .,.,
471
486
 
472
- module_eval(<<'.,.,', 'mvinl.y', 89)
487
+ module_eval(<<'.,.,', 'mvinl.y', 91)
473
488
  def _reduce_34(val, _values)
474
- val[0] << val[1]
489
+ Array.new
475
490
  end
476
491
  .,.,
477
492
 
478
- module_eval(<<'.,.,', 'mvinl.y', 90)
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
- Array.new
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', 95)
511
+ module_eval(<<'.,.,', 'mvinl.y', 97)
497
512
  def _reduce_38(val, _values)
498
- val[0] << val[1]
513
+ Array.new
499
514
  end
500
515
  .,.,
501
516
 
502
- module_eval(<<'.,.,', 'mvinl.y', 96)
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.3
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-06 00:00:00.000000000 Z
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: