genmachine 0.2.1 → 0.2.2
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.
- data/TODO +5 -0
- data/VERSION +1 -1
- data/genmachine.gemspec +1 -1
- data/lib/VERSION +1 -1
- data/lib/genmachine/generators/general_helper.rb +1 -1
- data/lib/genmachine/generators/ruby/helper.rb +4 -2
- data/lib/genmachine/generators/ruby/lib.erb.rb +8 -7
- metadata +3 -3
data/TODO
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
- Fix "unexpected ..." so it works again
|
2
|
+
- Automatically put {eof?} (by itself) clauses at beginning
|
3
|
+
- Get per-state eof? detection working again (for final else clause)
|
4
|
+
|
1
5
|
- highlight `c` specially
|
2
6
|
- Allow `b<<` etc. in statements - implied 'c' source
|
3
7
|
|
8
|
+
|
4
9
|
- mechanism for simple nondeterminism
|
5
10
|
- syn highlight
|
6
11
|
- parser generator implementation notes / examples
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/genmachine.gemspec
CHANGED
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -33,7 +33,7 @@ module GenMachine
|
|
33
33
|
exprs = c[:exprs].dup
|
34
34
|
exprs << c[:acc].dup
|
35
35
|
exprs.each do |e|
|
36
|
-
if e =~ /^([a-zA-Z_][a-zA-Z0-9_]*)?\s
|
36
|
+
if e =~ /^([a-zA-Z_][a-zA-Z0-9_]*)?\s*>>>?\s*([a-zA-Z_][a-zA-Z0-9_]*)?$/
|
37
37
|
accs[$1]=true unless ($1.nil? or $1 == '' or $1 == 'p' or $1 == 's')
|
38
38
|
accs[$3]=true unless ($3.nil? or $3 == '' or $3 == 'p' or $3 == 's')
|
39
39
|
end
|
@@ -105,10 +105,12 @@ module GenMachine
|
|
105
105
|
return ['@fwd=true']
|
106
106
|
when acc_phrase.strip == '>>'
|
107
107
|
return []
|
108
|
-
when acc_phrase =~ /^\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*>>\s*$/
|
108
|
+
when acc_phrase =~ /^\s*([a-zA-Z_][a-zA-Z0-9_.]*)\s*>>\s*$/
|
109
109
|
return ["#{rb_vars($1)}.reset!"]
|
110
|
-
when acc_phrase =~ /^\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*>>\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*$/
|
110
|
+
when acc_phrase =~ /^\s*([a-zA-Z_][a-zA-Z0-9_.]*)\s*>>\s*([a-zA-Z_][a-zA-Z0-9_.]*)\s*$/
|
111
111
|
return ["#{rb_vars($1)}.into(#{rb_vars($2)})"]
|
112
|
+
when acc_phrase =~ /^\s*([a-zA-Z_][a-zA-Z0-9_.]*)\s*>>>\s*([a-zA-Z_][a-zA-Z0-9_.]*)\s*$/
|
113
|
+
return ["#{rb_vars($1)}.into!(#{rb_vars($2)})"]
|
112
114
|
else raise("Can't figure out your accumulator statement: #{acc_phrase}")
|
113
115
|
end
|
114
116
|
end
|
@@ -3,6 +3,7 @@ $KCODE="U"
|
|
3
3
|
|
4
4
|
class Integer
|
5
5
|
def into(v); v << self end
|
6
|
+
def into!(v); into(v) end
|
6
7
|
def reset!; :nop end
|
7
8
|
def reset; :nop end
|
8
9
|
end
|
@@ -13,15 +14,14 @@ module <%= @classname %>
|
|
13
14
|
|
14
15
|
|
15
16
|
class UArray < Array
|
16
|
-
def into(v)
|
17
|
-
|
18
|
-
v << self
|
19
|
-
end
|
17
|
+
def into(v); into!(v) unless size == 0 end
|
18
|
+
def into!(v); v << self end
|
20
19
|
def reset!; self.clear end
|
21
20
|
def reset; d=dup;d.reset!;d end
|
22
21
|
end
|
23
22
|
|
24
23
|
class UHash < Hash
|
24
|
+
def into!(v) v << self end
|
25
25
|
def into(v) v << self end
|
26
26
|
def <<(kv) k,v = kv; self[k] = v end
|
27
27
|
def reset!; self.clear end
|
@@ -29,8 +29,8 @@ module <%= @classname %>
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class UString < String
|
32
|
-
def into(v)
|
33
|
-
|
32
|
+
def into(v); into!(v) unless size == 0 end
|
33
|
+
def into!(v)
|
34
34
|
v << self.dup
|
35
35
|
reset!
|
36
36
|
end
|
@@ -53,6 +53,7 @@ module <%= @classname %>
|
|
53
53
|
@c= params.delete(:c) || []
|
54
54
|
@name = params.delete(:name)
|
55
55
|
end
|
56
|
+
def into!(val) val << self end
|
56
57
|
def into(val) val << self end
|
57
58
|
def <<(val) @c<<val end
|
58
59
|
def [](key) @c[key] end
|
@@ -157,7 +158,7 @@ module <%= @classname %>
|
|
157
158
|
|
158
159
|
<%- @spec_ast.each do |name, otype, args, cmds, first_state, states| -%>
|
159
160
|
<%- args << "p=nil" -%>
|
160
|
-
<%- args << "name='#{name}'" -%>
|
161
|
+
<%- args << "name=UString.new('#{name}')" -%>
|
161
162
|
def <%= name %>(<%= args.join(',') %>)
|
162
163
|
<%- cmds.each do |c| -%>
|
163
164
|
<%= rb_vars(c) %>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joseph Wecker
|