indentation-parser 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/indentation-parser.gemspec +1 -1
- data/lib/indentation-parser.rb +3 -3
- data/lib/indentation-parser/handlers.rb +21 -7
- data/lib/indentation-parser/hooks.rb +0 -0
- data/lib/indentation-parser/node.rb +0 -0
- data/spec/material/an.example +0 -0
- data/spec/material/test.mylang +0 -0
- data/spec/material/the.universe +0 -0
- data/spec/readme_example_spec.rb +0 -0
- data/spec/simple_spec.rb +0 -0
- data/spec/universe_spec.rb +0 -0
- metadata +2 -2
data/.gitignore
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/indentation-parser.gemspec
CHANGED
data/lib/indentation-parser.rb
CHANGED
@@ -47,7 +47,7 @@ class IndentationParser
|
|
47
47
|
handle_less_indentation previous_node, new_node, node_stack
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
handle_node node_stack.last, true
|
51
51
|
root
|
52
52
|
end
|
53
53
|
|
@@ -59,14 +59,14 @@ class IndentationParser
|
|
59
59
|
|
60
60
|
def handle_same_indentation new_node, node_stack
|
61
61
|
leaf = node_stack.pop
|
62
|
-
|
62
|
+
handle_node leaf, true
|
63
63
|
node_stack.last.add new_node
|
64
64
|
node_stack.push new_node
|
65
65
|
end
|
66
66
|
|
67
67
|
def handle_less_indentation previous_node, new_node, node_stack
|
68
68
|
leaf = node_stack.pop
|
69
|
-
|
69
|
+
handle_node leaf, true
|
70
70
|
(previous_node.indentation - new_node.indentation).times do
|
71
71
|
node_stack.pop
|
72
72
|
end
|
@@ -33,25 +33,39 @@ class IndentationParser
|
|
33
33
|
handled
|
34
34
|
end
|
35
35
|
|
36
|
-
def handle_node node
|
36
|
+
def handle_node node, leaf = false
|
37
37
|
handled = execute_child_of_handler node
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
return true if handled
|
39
|
+
|
41
40
|
handled = try_to_handle @node_handlers, node
|
42
|
-
if
|
41
|
+
return true if handled
|
42
|
+
|
43
|
+
if leaf
|
44
|
+
handled = handle_leaf node
|
45
|
+
end
|
46
|
+
|
47
|
+
return true if handled
|
48
|
+
|
49
|
+
if @default
|
43
50
|
node_value = call_handler @default, node if @default
|
44
51
|
node.set_value node_value
|
52
|
+
return true
|
53
|
+
else
|
54
|
+
return false
|
45
55
|
end
|
46
56
|
end
|
47
57
|
|
48
58
|
def handle_leaf node
|
49
59
|
handled = try_to_handle @leaf_handlers, node
|
50
|
-
|
60
|
+
|
61
|
+
return true if handled
|
62
|
+
|
63
|
+
if @on_leaf
|
51
64
|
node_value = call_handler @on_leaf, node
|
52
65
|
node.set_value node_value
|
66
|
+
return true
|
53
67
|
else
|
54
|
-
|
68
|
+
return false
|
55
69
|
end
|
56
70
|
end
|
57
71
|
|
File without changes
|
File without changes
|
data/spec/material/an.example
CHANGED
File without changes
|
data/spec/material/test.mylang
CHANGED
File without changes
|
data/spec/material/the.universe
CHANGED
File without changes
|
data/spec/readme_example_spec.rb
CHANGED
File without changes
|
data/spec/simple_spec.rb
CHANGED
File without changes
|
data/spec/universe_spec.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indentation-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|