sexp_processor 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/README.txt +20 -7
- data/lib/sexp.rb +33 -2
- data/lib/sexp_processor.rb +1 -1
- metadata +7 -7
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,32 +1,45 @@
|
|
1
1
|
= SexpProcessor
|
2
2
|
|
3
|
-
*
|
3
|
+
* http://rubyforge.org/projects/parsetree/
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
|
-
|
7
|
+
sexp_processor branches from ParseTree bringing all the generic sexp
|
8
|
+
processing tools with it. Sexp, SexpProcessor, Environment, etc... all
|
9
|
+
for your language processing pleasure.
|
8
10
|
|
9
11
|
== FEATURES/PROBLEMS:
|
10
12
|
|
11
|
-
*
|
13
|
+
* Includes SexpProcessor and CompositeSexpProcessor.
|
14
|
+
|
15
|
+
* Allows you to write very clean filters.
|
12
16
|
|
13
17
|
== SYNOPSIS:
|
14
18
|
|
15
|
-
|
19
|
+
class MyProcessor < SexpProcessor
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
self.strict = false
|
23
|
+
end
|
24
|
+
def process_lit(exp)
|
25
|
+
val = exp.shift
|
26
|
+
return val
|
27
|
+
end
|
28
|
+
end
|
16
29
|
|
17
30
|
== REQUIREMENTS:
|
18
31
|
|
19
|
-
*
|
32
|
+
* rubygems
|
20
33
|
|
21
34
|
== INSTALL:
|
22
35
|
|
23
|
-
*
|
36
|
+
* sudo gem install sexp_processor
|
24
37
|
|
25
38
|
== LICENSE:
|
26
39
|
|
27
40
|
(The MIT License)
|
28
41
|
|
29
|
-
Copyright (c) 2008
|
42
|
+
Copyright (c) 2008 Ryan Davis, Seattle.rb
|
30
43
|
|
31
44
|
Permission is hereby granted, free of charge, to any person obtaining
|
32
45
|
a copy of this software and associated documentation files (the
|
data/lib/sexp.rb
CHANGED
@@ -9,6 +9,9 @@ $TESTING ||= false # unless defined $TESTING
|
|
9
9
|
|
10
10
|
class Sexp < Array # ZenTest FULL
|
11
11
|
|
12
|
+
attr_writer :line
|
13
|
+
attr_accessor :file, :comments
|
14
|
+
|
12
15
|
@@array_types = [ :array, :args, ]
|
13
16
|
|
14
17
|
##
|
@@ -131,7 +134,11 @@ class Sexp < Array # ZenTest FULL
|
|
131
134
|
|
132
135
|
def inspect # :nodoc:
|
133
136
|
sexp_str = self.map {|x|x.inspect}.join(', ')
|
134
|
-
|
137
|
+
if line && ENV['VERBOSE'] then
|
138
|
+
"s(#{sexp_str}).line(#{line})"
|
139
|
+
else
|
140
|
+
"s(#{sexp_str})"
|
141
|
+
end
|
135
142
|
end
|
136
143
|
|
137
144
|
def find_node name, delete = false
|
@@ -149,10 +156,27 @@ class Sexp < Array # ZenTest FULL
|
|
149
156
|
end
|
150
157
|
end
|
151
158
|
|
159
|
+
##
|
160
|
+
# Find every node with type +name+.
|
161
|
+
|
152
162
|
def find_nodes name
|
153
163
|
find_all { | sexp | Sexp === sexp and sexp.first == name }
|
154
164
|
end
|
155
165
|
|
166
|
+
##
|
167
|
+
# If passed a line number, sets the line and returns self. Otherwise
|
168
|
+
# returns the line number. This allows you to do message cascades
|
169
|
+
# and still get the sexp back.
|
170
|
+
|
171
|
+
def line(n=nil)
|
172
|
+
if n then
|
173
|
+
@line = n
|
174
|
+
self
|
175
|
+
else
|
176
|
+
@line ||= nil
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
156
180
|
##
|
157
181
|
# Returns the node named +node+, deleting it if +delete+ is true.
|
158
182
|
|
@@ -167,7 +191,14 @@ class Sexp < Array # ZenTest FULL
|
|
167
191
|
end
|
168
192
|
|
169
193
|
##
|
170
|
-
# Returns the
|
194
|
+
# Returns the node type of the Sexp.
|
195
|
+
|
196
|
+
def sexp_type
|
197
|
+
first
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Returns the Sexp body, ie the values without the node type.
|
171
202
|
|
172
203
|
def sexp_body
|
173
204
|
self[1..-1]
|
data/lib/sexp_processor.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sexp_processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-20 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,9 +20,9 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.8.
|
23
|
+
version: 1.8.2
|
24
24
|
version:
|
25
|
-
description:
|
25
|
+
description: sexp_processor branches from ParseTree bringing all the generic sexp processing tools with it. Sexp, SexpProcessor, Environment, etc... all for your language processing pleasure.
|
26
26
|
email:
|
27
27
|
- ryand-ruby@zenspider.com
|
28
28
|
executables: []
|
@@ -46,7 +46,7 @@ files:
|
|
46
46
|
- test/test_sexp.rb
|
47
47
|
- test/test_sexp_processor.rb
|
48
48
|
has_rdoc: true
|
49
|
-
homepage:
|
49
|
+
homepage: http://rubyforge.org/projects/parsetree/
|
50
50
|
post_install_message:
|
51
51
|
rdoc_options:
|
52
52
|
- --main
|
@@ -68,10 +68,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements: []
|
69
69
|
|
70
70
|
rubyforge_project: parsetree
|
71
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.1
|
72
72
|
signing_key:
|
73
73
|
specification_version: 2
|
74
|
-
summary:
|
74
|
+
summary: sexp_processor branches from ParseTree bringing all the generic sexp processing tools with it
|
75
75
|
test_files:
|
76
76
|
- test/test_composite_sexp_processor.rb
|
77
77
|
- test/test_environment.rb
|