rley 0.6.05 → 0.6.06
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/examples/general/calc_iter1/calc_ast_nodes.rb +8 -0
- data/examples/general/calc_iter1/calc_demo.rb +1 -1
- data/examples/general/calc_iter2/calc_ast_nodes.rb +8 -0
- data/lib/rley/constants.rb +1 -1
- data/lib/rley/parse_rep/parse_forest_builder.rb +5 -0
- data/lib/rley/parse_rep/parse_rep_creator.rb +2 -0
- data/lib/rley/parse_rep/parse_tree_builder.rb +8 -3
- data/lib/rley/parser/gfg_parsing.rb +0 -14
- data/lib/rley/ptree/parse_tree.rb +6 -0
- data/lib/rley/ptree/parse_tree_node.rb +4 -0
- data/lib/rley/sppf/parse_forest.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1e6215ec93e9404550f4ac55ac71cb294d5d3ef
|
4
|
+
data.tar.gz: 73b5089ae521c84ec6999096054dc1212e646d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e954203459567724574ae05d976d5c836c21febdacc730971630a585ae73809bff5fa240238151c704ba51ccda44d9c2434f3202bdeddda75abb1b17cafa1a04
|
7
|
+
data.tar.gz: cc61845755b29425dfe538b7f7fd1605e21fb43be2d8e33956688bfca5f7626c257d31b6264ae44066875dadb4e9e4bb53a7e8a3adce16f76c14af2207ad9007
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 0.6.06 / 2018-04-12
|
2
|
+
* [ADDED] Method `done!`: added to classes involved parse tree and parse forest creation. This method signals the end of parsing.
|
3
|
+
* [CHANGE] Method `ParseTreeBuilder#process_item_entry`: added an explicit message in case of ambiguous parse.
|
4
|
+
* [REMOVED] Deprecated method `GFGParsing#parse_tree`, to generate parse trees use the `Engine` class.
|
5
|
+
|
1
6
|
### 0.6.05 / 2018-04-02
|
2
7
|
* [CHANGE] Method `ParseTreeBuilder#process_end_entry`: added an explicit message in case of ambiguous parse.
|
3
8
|
* [CHANGE] Method `ParseTreeBuilder#process_item_entry`: added an explicit message in case of ambiguous parse.
|
@@ -22,6 +22,10 @@ CalcTerminalNode = Struct.new(:token, :value, :position) do
|
|
22
22
|
return value
|
23
23
|
end
|
24
24
|
|
25
|
+
def done!()
|
26
|
+
# Do nothing
|
27
|
+
end
|
28
|
+
|
25
29
|
# Part of the 'visitee' role in Visitor design pattern.
|
26
30
|
# @param aVisitor[ParseTreeVisitor] the visitor
|
27
31
|
def accept(aVisitor)
|
@@ -49,6 +53,10 @@ class CalcCompositeNode
|
|
49
53
|
@symbol = aSymbol
|
50
54
|
@children = []
|
51
55
|
end
|
56
|
+
|
57
|
+
def done!()
|
58
|
+
# Do nothing
|
59
|
+
end
|
52
60
|
|
53
61
|
# Part of the 'visitee' role in Visitor design pattern.
|
54
62
|
# @param aVisitor[ParseTreeVisitor] the visitor
|
@@ -21,6 +21,10 @@ CalcTerminalNode = Struct.new(:token, :value, :position) do
|
|
21
21
|
def interpret()
|
22
22
|
return value
|
23
23
|
end
|
24
|
+
|
25
|
+
def done!()
|
26
|
+
# Do nothing
|
27
|
+
end
|
24
28
|
|
25
29
|
# Part of the 'visitee' role in Visitor design pattern.
|
26
30
|
# @param aVisitor[ParseTreeVisitor] the visitor
|
@@ -77,6 +81,10 @@ class CalcCompositeNode
|
|
77
81
|
def accept(aVisitor)
|
78
82
|
aVisitor.visit_nonterminal(self)
|
79
83
|
end
|
84
|
+
|
85
|
+
def done!()
|
86
|
+
# Do nothing
|
87
|
+
end
|
80
88
|
|
81
89
|
alias subnodes children
|
82
90
|
end # class
|
data/lib/rley/constants.rb
CHANGED
@@ -40,6 +40,11 @@ module Rley # This module is used as a namespace
|
|
40
40
|
@entry2node = {}
|
41
41
|
@entry2path_to_alt = {}
|
42
42
|
end
|
43
|
+
|
44
|
+
# Notify the builder that the construction is over
|
45
|
+
def done!()
|
46
|
+
result.done!
|
47
|
+
end
|
43
48
|
|
44
49
|
def receive_event(anEvent, anEntry, anIndex)
|
45
50
|
# puts "Event: #{anEvent} #{anEntry} #{anIndex}"
|
@@ -24,8 +24,8 @@ module Rley # This module is used as a namespace
|
|
24
24
|
end # Struct
|
25
25
|
|
26
26
|
|
27
|
-
# The purpose of a ParseTreeBuilder is to build piece by piece
|
28
|
-
#
|
27
|
+
# The purpose of a ParseTreeBuilder is to build piece by piece
|
28
|
+
# a parse tree from a sequence of input tokens and
|
29
29
|
# visit events produced by walking over a GFGParsing object.
|
30
30
|
# Uses the Builder GoF pattern.
|
31
31
|
# The Builder pattern creates a complex object
|
@@ -35,7 +35,7 @@ module Rley # This module is used as a namespace
|
|
35
35
|
# @return [Array<Token>] The sequence of input tokens
|
36
36
|
attr_reader(:tokens)
|
37
37
|
|
38
|
-
# Link to
|
38
|
+
# Link to Parse tree object (being) built.
|
39
39
|
attr_reader(:result)
|
40
40
|
|
41
41
|
|
@@ -46,6 +46,11 @@ module Rley # This module is used as a namespace
|
|
46
46
|
@stack = []
|
47
47
|
@dummy_node = Object.new.freeze
|
48
48
|
end
|
49
|
+
|
50
|
+
# Notify the builder that the construction is over
|
51
|
+
def done!()
|
52
|
+
result.done!
|
53
|
+
end
|
49
54
|
|
50
55
|
# Receive events resulting from a visit of GFGParsing object.
|
51
56
|
# These events are produced by a specialized Enumerator created
|
@@ -199,20 +199,6 @@ END_MSG
|
|
199
199
|
return factory.create
|
200
200
|
end
|
201
201
|
|
202
|
-
# Factory method. Builds a ParseTree from the parse result.
|
203
|
-
# @return [ParseTree]
|
204
|
-
def parse_tree(aBuilder = nil)
|
205
|
-
msg = <<-END_MSG
|
206
|
-
Method Rley::Parser::GFGParsing.parse_tree is deprecated, call
|
207
|
-
Rley::Engine::to_ptree. It will be removed April 1st
|
208
|
-
or version 0.6.1 (whichever is first)
|
209
|
-
END_MSG
|
210
|
-
warn(msg)
|
211
|
-
factory = ParseRep::ParseTreeFactory.new(self)
|
212
|
-
|
213
|
-
return factory.create(aBuilder)
|
214
|
-
end
|
215
|
-
|
216
202
|
# Retrieve the very first parse entry added to the chart.
|
217
203
|
# This entry corresponds to the start vertex of the GF graph
|
218
204
|
# with origin equal to zero.
|
@@ -19,6 +19,12 @@ module Rley # This module is used as a namespace
|
|
19
19
|
def initialize(theRootNode)
|
20
20
|
@root = theRootNode
|
21
21
|
end
|
22
|
+
|
23
|
+
# Notify the builder that the construction is over.
|
24
|
+
# This method can be overriden
|
25
|
+
def done!()
|
26
|
+
@root.done!
|
27
|
+
end
|
22
28
|
|
23
29
|
# Part of the 'visitee' role in the Visitor design pattern.
|
24
30
|
# A visitee is expected to accept the visit from a visitor object
|
@@ -13,6 +13,10 @@ module Rley # This module is used as a namespace
|
|
13
13
|
@symbol = aSymbol
|
14
14
|
@range = Lexical::TokenRange.new(aRange)
|
15
15
|
end
|
16
|
+
|
17
|
+
# Notify the builder that the construction is over
|
18
|
+
def done!()
|
19
|
+
end
|
16
20
|
|
17
21
|
# Assign a value from given range to each undefined range bound
|
18
22
|
def range=(aRange)
|
@@ -29,6 +29,10 @@ module Rley # This module is used as a namespace
|
|
29
29
|
@is_ambiguous = false
|
30
30
|
end
|
31
31
|
|
32
|
+
# Notification that the SPPF construction is over
|
33
|
+
def done!()
|
34
|
+
end
|
35
|
+
|
32
36
|
# Returns true if the given node is present in the forest.
|
33
37
|
def include?(aNode)
|
34
38
|
return key2node.include?(aNode)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.06
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|