spitewaste 0.2.0 → 0.2.5

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.
@@ -118,9 +118,9 @@ module Spitewaste
118
118
  # quick push (`push 1,2,3` desugars to individual pushes)
119
119
  @src.gsub!(/push \S+/) { |m| m.split(?,) * ' push ' }
120
120
  # quick store (`^2` = `push 2 swap store`)
121
- @src.gsub!(/\^(-?\d+)/, 'push \1 swap store')
121
+ @src.gsub!(/\^(\S+)/, 'push \1 swap store')
122
122
  # quick load (`@2` = `push 2 load`)
123
- @src.gsub!(/@(-?\d+)/, 'push \1 load')
123
+ @src.gsub!(/@(\S+)/, 'push \1 load')
124
124
  end
125
125
 
126
126
  def gensym
@@ -141,18 +141,20 @@ module Spitewaste
141
141
  parse = -> s { s.split(?,).map &:strip }
142
142
 
143
143
  # Macro "functions" get handled first.
144
- @src.gsub!(/(\$\S+?)\(([^)]+)\)\s*{(.+?)}/m) {
144
+ @src.gsub!(/(\$\S+?)\(([^)]*)\)\s*{(.+?)}/m) {
145
145
  @macros[$1] ||= [$2, $3]; ''
146
146
  }
147
- @src.gsub!(/(\$\S+?)\(([^)]+)\)/) {
147
+ @src.gsub!(/(\$\S+?)\(([^)]*)\)/) {
148
148
  params, body = @macros[$1]
149
149
  raise "no macro function '#$1'" unless body
150
150
  map = parse[params].zip(parse[$2]).to_h
151
- body.gsub(/`(.+?)`/) { map[$1] }
151
+ body
152
+ .gsub(/`(.+?)`/) { map[$1] }
153
+ .gsub(/#(\S+)/) { "push #{Spitewaste.strpack map[$1]}" }
152
154
  }
153
155
 
154
156
  @src.gsub!(/(\$\S+)\s*=\s*(.+)/) { @macros[$1] ||= $2; '' }
155
- @src.gsub!(/(\$\S+)/) { @macros[$1] || raise("no macro '#$1'") }
157
+ @src.gsub!(/(\$[^)\s]+)/) { @macros[$1] || raise("no macro '#$1'") }
156
158
  end
157
159
 
158
160
  def eliminate_dead_code!
@@ -1,3 +1,3 @@
1
1
  module Spitewaste
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spitewaste
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Collided Scope (collidedscope)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-03 00:00:00.000000000 Z
11
+ date: 2021-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -89,6 +89,7 @@ files:
89
89
  - lib/spitewaste/cli/docs.rb
90
90
  - lib/spitewaste/cli/exec.rb
91
91
  - lib/spitewaste/cli/image.rb
92
+ - lib/spitewaste/cli/version.rb
92
93
  - lib/spitewaste/emitter.rb
93
94
  - lib/spitewaste/emitters/assembly.rb
94
95
  - lib/spitewaste/emitters/codegen.rb
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 3.1.4
142
+ rubygems_version: 3.2.18
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Make programming in Whitespace even better.