spitewaste 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -3
- data/bin/spw +1 -0
- data/lib/spitewaste.rb +4 -0
- data/lib/spitewaste/assembler.rb +1 -1
- data/lib/spitewaste/cli/version.rb +9 -0
- data/lib/spitewaste/emitters/image.rb +3 -2
- data/lib/spitewaste/emitters/schemes.yaml +127 -0
- data/lib/spitewaste/libspw/array.spw +54 -17
- data/lib/spitewaste/libspw/bits.spw +4 -4
- data/lib/spitewaste/libspw/docs.json +551 -16
- data/lib/spitewaste/libspw/fun.spw +36 -5
- data/lib/spitewaste/libspw/io.spw +13 -11
- data/lib/spitewaste/libspw/math.spw +6 -9
- data/lib/spitewaste/libspw/random.spw +32 -9
- data/lib/spitewaste/libspw/rational.spw +2 -2
- data/lib/spitewaste/libspw/stack.spw +23 -14
- data/lib/spitewaste/libspw/string.spw +45 -24
- data/lib/spitewaste/libspw/test.spw +3 -0
- data/lib/spitewaste/libspw/util.spw +41 -13
- data/lib/spitewaste/parsers/spitewaste.rb +8 -6
- data/lib/spitewaste/version.rb +1 -1
- metadata +4 -3
@@ -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!(/\^(
|
121
|
+
@src.gsub!(/\^(\S+)/, 'push \1 swap store')
|
122
122
|
# quick load (`@2` = `push 2 load`)
|
123
|
-
@src.gsub!(/@(
|
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+?)\(([^)]
|
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
|
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!(/(
|
157
|
+
@src.gsub!(/(\$[^)\s]+)/) { @macros[$1] || raise("no macro '#$1'") }
|
156
158
|
end
|
157
159
|
|
158
160
|
def eliminate_dead_code!
|
data/lib/spitewaste/version.rb
CHANGED
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.
|
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-
|
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.
|
142
|
+
rubygems_version: 3.2.18
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Make programming in Whitespace even better.
|