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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3083af262074f545ce6cdb9afed83c0d8a5cd255
4
- data.tar.gz: d99c85423dde12c232681524dc9f8692bbd1d0ce
3
+ metadata.gz: e1e6215ec93e9404550f4ac55ac71cb294d5d3ef
4
+ data.tar.gz: 73b5089ae521c84ec6999096054dc1212e646d28
5
5
  SHA512:
6
- metadata.gz: 27b474bb46b84aad4cfa74f72cdadc4d7da99bb0a80e5d6f8e4176716a6297a5be9495adac0202f2c5791ddbeb728ef7a35a5f0dd0e22504cb3d934c2d4446c9
7
- data.tar.gz: 296215d53be774b54bff3b1b4ee316afab8ea86282d507cb72fac36f55b810c694e45554b2758a4b18c9008cb75030147129b20b730ce1b8cd1077ff582438df
6
+ metadata.gz: e954203459567724574ae05d976d5c836c21febdacc730971630a585ae73809bff5fa240238151c704ba51ccda44d9c2434f3202bdeddda75abb1b17cafa1a04
7
+ data.tar.gz: cc61845755b29425dfe538b7f7fd1605e21fb43be2d8e33956688bfca5f7626c257d31b6264ae44066875dadb4e9e4bb53a7e8a3adce16f76c14af2207ad9007
@@ -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
@@ -11,7 +11,7 @@ Command-line syntax:
11
11
  the arithmetic expression is enclosed between double quotes (")
12
12
 
13
13
  Example:
14
- ruby #{my_name} "2 * 3 + (1 + 3 ** 2)"
14
+ ruby #{my_name} "2 * 3 + (1 + 3 * 2)"
15
15
  END_MSG
16
16
  puts msg
17
17
  exit(1)
@@ -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
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Rley # Module used as a namespace
5
5
  # The version number of the gem.
6
- Version = '0.6.05'.freeze
6
+ Version = '0.6.06'.freeze
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Ruby implementation of the Earley's parsing algorithm".freeze
@@ -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}"
@@ -29,6 +29,8 @@ module Rley # This module is used as a namespace
29
29
  rescue StopIteration => exc
30
30
  # Do nothing
31
31
  end
32
+
33
+ a_builder.done!
32
34
 
33
35
  return a_builder.result
34
36
  end
@@ -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 a CST
28
- # (Concrete Syntax Tree) from a sequence of input tokens and
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 CST object (being) built.
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.05
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-02 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls