katuv 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/katuv/dsl.rb +10 -10
- data/lib/katuv/version.rb +1 -1
- metadata +2 -2
data/lib/katuv/dsl.rb
CHANGED
@@ -3,12 +3,12 @@ module Katuv
|
|
3
3
|
def nonterminal(type)
|
4
4
|
raise "NonterminalInTerminalError" if terminal?
|
5
5
|
define_method(_type_to_method_name(type)) do |name=nil, opts={}, &block|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
if children.has_key?(type) and children[type]
|
7
|
+
children[type].run!(&block)
|
8
|
+
else
|
9
|
+
children[type] = type.new(name, opts.merge(parent: self), &block)
|
10
|
+
end
|
11
|
+
children[type]
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,8 +16,8 @@ module Katuv
|
|
16
16
|
#should only allow one.
|
17
17
|
raise "InvalidNodeTypeError" unless type.terminal?
|
18
18
|
define_method(_type_to_method_name(type)) do |name=nil, opts={}, &block|
|
19
|
-
|
20
|
-
|
19
|
+
raise "TerminalAlreadySetError" if children.has_key?(type)
|
20
|
+
children[type] = type.new(name, opts.merge(parent: self), &block)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
def terminal!
|
@@ -30,8 +30,8 @@ module Katuv
|
|
30
30
|
#it sees of this type. eg, `file 'x'; file 'y' #=> children[File] = [File<@name=x>, File<@name=y>]
|
31
31
|
raise "InvalidNodeTypeError" unless type.terminal?
|
32
32
|
define_method(_type_to_method_name(type)) do |name, opts={}, &block|
|
33
|
-
|
34
|
-
|
33
|
+
children[type] ||= ObjectSet.new
|
34
|
+
children[type] << type.new(name, opts.merge(parent: self), &block)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/lib/katuv/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: katuv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joe Fredette
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A tool for parsing and transforming internal Ruby DSLs
|
15
15
|
email:
|