genmachine 0.2.3 → 0.2.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/genmachine.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{genmachine}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joseph Wecker"]
12
- s.date = %q{2011-08-20}
12
+ s.date = %q{2011-08-23}
13
13
  s.default_executable = %q{genmachine}
14
14
  s.description = %q{Takes a state table where the following are defined: state, input+conditions, accumulate-action, pre-transition-actions, and transition-to. It takes that state table and generates very fast parsers. Similar to Ragel. Currently only outputs pure Ruby.}
15
15
  s.email = %q{joseph.wecker@gmail.com}
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -22,18 +22,18 @@ class String
22
22
  def reset; d=dup;d.reset!;d end
23
23
  end
24
24
 
25
+ class Array
26
+ def into(v); into!(v) unless size == 0 end
27
+ def into!(v); v << self end
28
+ def reset!; self.clear end
29
+ def reset; d=dup;d.reset!;d end
30
+ end
25
31
 
26
32
  module <%= @classname %>
27
33
  def self.parse(str) Parser.new(str).parse end
28
34
  def self.parse_file(fname) Parser.new(IO.read(fname)).parse end
29
35
 
30
36
 
31
- class UArray < Array
32
- def into(v); into!(v) unless size == 0 end
33
- def into!(v); v << self end
34
- def reset!; self.clear end
35
- def reset; d=dup;d.reset!;d end
36
- end
37
37
 
38
38
  class UHash < Hash
39
39
  def into!(v) v << self end
@@ -168,7 +168,7 @@ module <%= @classname %>
168
168
  <%- if otype == 'U' -%>
169
169
  s = UNode.new(:name=>name,:sline=>@line,:schr=>@pos)
170
170
  <%- elsif otype == '[]' -%>
171
- s = UArray.new
171
+ s = []
172
172
  <%- elsif otype == '{}' -%>
173
173
  s = UHash.new
174
174
  <%- end -%>
@@ -83,6 +83,8 @@ module GenMachine
83
83
  def parse_input(val,inputs=nil)
84
84
  iters = 0
85
85
  conds = []
86
+ val.gsub! /([^\\])\\\[/, '\1<left-square-bracket>'
87
+ val.gsub! /([^\\])\\\]/, '\1<right-square-bracket>'
86
88
  while val.strip.length > 0 && iters < 100
87
89
  case
88
90
  when val =~ /--+/um
@@ -112,10 +114,11 @@ module GenMachine
112
114
  '\r' => "\r", '\f' => "\f",
113
115
  '\b' => "\b", '\a' => "\a",
114
116
  '\e' => "\e", '\s' => " ",
115
- '\[' => '[', '\]' => ']',
116
117
  "\\\\" => '\\'}
117
118
  def parse_combine_ranges(raw, input)
118
- raw.gsub!(/\\[tnrfbaes\[\]]/){|m| ESCAPES[m]}
119
+ raw.gsub!(/\\[tnrfbaes\\]/){|m| ESCAPES[m]}
120
+ raw.gsub!('<left-square-bracket>', '[')
121
+ raw.gsub!('<right-square-bracket>', ']')
119
122
  if raw =~ /((?:.-.)*)((?:.)*)/um
120
123
  ranges = $1
121
124
  singles = $2
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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joseph Wecker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-20 00:00:00 -07:00
18
+ date: 2011-08-23 00:00:00 -07:00
19
19
  default_executable: genmachine
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency