rley 0.7.03 → 0.7.04
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -4
- data/CHANGELOG.md +10 -1
- data/README.md +3 -5
- data/Rakefile +2 -0
- data/appveyor.yml +4 -2
- data/examples/NLP/benchmark_pico_en.rb +2 -0
- data/examples/NLP/engtagger.rb +2 -0
- data/examples/NLP/nano_eng/nano_en_demo.rb +2 -0
- data/examples/NLP/nano_eng/nano_grammar.rb +2 -0
- data/examples/NLP/pico_en_demo.rb +2 -0
- data/examples/data_formats/JSON/cli_options.rb +2 -0
- data/examples/data_formats/JSON/json_ast_builder.rb +2 -0
- data/examples/data_formats/JSON/json_ast_nodes.rb +2 -0
- data/examples/data_formats/JSON/json_demo.rb +2 -0
- data/examples/data_formats/JSON/json_grammar.rb +2 -0
- data/examples/data_formats/JSON/json_lexer.rb +2 -0
- data/examples/data_formats/JSON/json_minifier.rb +2 -0
- data/examples/general/calc_iter1/calc_ast_builder.rb +2 -0
- data/examples/general/calc_iter1/calc_ast_nodes.rb +2 -0
- data/examples/general/calc_iter1/calc_demo.rb +2 -0
- data/examples/general/calc_iter1/calc_grammar.rb +2 -0
- data/examples/general/calc_iter1/calc_lexer.rb +2 -0
- data/examples/general/calc_iter1/spec/calculator_spec.rb +2 -0
- data/examples/general/calc_iter2/calc_ast_builder.rb +2 -0
- data/examples/general/calc_iter2/calc_ast_nodes.rb +2 -0
- data/examples/general/calc_iter2/calc_demo.rb +2 -0
- data/examples/general/calc_iter2/calc_grammar.rb +2 -0
- data/examples/general/calc_iter2/calc_lexer.rb +2 -0
- data/examples/general/calc_iter2/spec/calculator_spec.rb +2 -0
- data/examples/general/left.rb +2 -0
- data/examples/general/right.rb +2 -0
- data/lib/rley.rb +2 -0
- data/lib/rley/base/base_parser.rb +2 -0
- data/lib/rley/base/dotted_item.rb +17 -12
- data/lib/rley/base/grm_items_builder.rb +2 -0
- data/lib/rley/constants.rb +4 -2
- data/lib/rley/engine.rb +2 -1
- data/lib/rley/formatter/asciitree.rb +3 -1
- data/lib/rley/formatter/base_formatter.rb +2 -0
- data/lib/rley/formatter/bracket_notation.rb +2 -0
- data/lib/rley/formatter/debug.rb +2 -0
- data/lib/rley/formatter/json.rb +2 -0
- data/lib/rley/gfg/call_edge.rb +2 -0
- data/lib/rley/gfg/edge.rb +2 -0
- data/lib/rley/gfg/end_vertex.rb +2 -0
- data/lib/rley/gfg/epsilon_edge.rb +2 -0
- data/lib/rley/gfg/grm_flow_graph.rb +4 -2
- data/lib/rley/gfg/item_vertex.rb +2 -12
- data/lib/rley/gfg/non_terminal_vertex.rb +2 -0
- data/lib/rley/gfg/return_edge.rb +2 -0
- data/lib/rley/gfg/scan_edge.rb +2 -0
- data/lib/rley/gfg/shortcut_edge.rb +2 -0
- data/lib/rley/gfg/start_vertex.rb +2 -0
- data/lib/rley/gfg/vertex.rb +4 -2
- data/lib/rley/lexical/token.rb +2 -0
- data/lib/rley/lexical/token_range.rb +2 -0
- data/lib/rley/parse_forest_visitor.rb +2 -0
- data/lib/rley/parse_rep/ast_base_builder.rb +2 -0
- data/lib/rley/parse_rep/cst_builder.rb +2 -0
- data/lib/rley/parse_rep/parse_forest_builder.rb +2 -0
- data/lib/rley/parse_rep/parse_forest_factory.rb +2 -0
- data/lib/rley/parse_rep/parse_rep_creator.rb +2 -0
- data/lib/rley/parse_rep/parse_tree_builder.rb +11 -11
- data/lib/rley/parse_rep/parse_tree_factory.rb +2 -0
- data/lib/rley/parse_tree_visitor.rb +2 -0
- data/lib/rley/parser/error_reason.rb +5 -3
- data/lib/rley/parser/gfg_chart.rb +2 -0
- data/lib/rley/parser/gfg_earley_parser.rb +3 -1
- data/lib/rley/parser/gfg_parsing.rb +7 -1
- data/lib/rley/parser/parse_entry.rb +4 -3
- data/lib/rley/parser/parse_entry_set.rb +9 -13
- data/lib/rley/parser/parse_entry_tracker.rb +2 -0
- data/lib/rley/parser/parse_state.rb +2 -0
- data/lib/rley/parser/parse_state_tracker.rb +2 -0
- data/lib/rley/parser/parse_tracer.rb +2 -0
- data/lib/rley/parser/parse_walker_factory.rb +2 -0
- data/lib/rley/parser/state_set.rb +2 -0
- data/lib/rley/ptree/non_terminal_node.rb +3 -1
- data/lib/rley/ptree/parse_tree.rb +3 -1
- data/lib/rley/ptree/parse_tree_node.rb +2 -0
- data/lib/rley/ptree/terminal_node.rb +2 -0
- data/lib/rley/rley_error.rb +2 -0
- data/lib/rley/sppf/alternative_node.rb +2 -0
- data/lib/rley/sppf/composite_node.rb +2 -0
- data/lib/rley/sppf/epsilon_node.rb +2 -0
- data/lib/rley/sppf/leaf_node.rb +2 -0
- data/lib/rley/sppf/non_terminal_node.rb +2 -0
- data/lib/rley/sppf/parse_forest.rb +3 -1
- data/lib/rley/sppf/sppf_node.rb +2 -0
- data/lib/rley/sppf/token_node.rb +2 -0
- data/lib/rley/syntax/grammar.rb +2 -0
- data/lib/rley/syntax/grammar_builder.rb +2 -0
- data/lib/rley/syntax/grm_symbol.rb +2 -0
- data/lib/rley/syntax/literal.rb +2 -0
- data/lib/rley/syntax/non_terminal.rb +2 -0
- data/lib/rley/syntax/production.rb +3 -1
- data/lib/rley/syntax/symbol_seq.rb +3 -1
- data/lib/rley/syntax/terminal.rb +2 -0
- data/lib/rley/syntax/verbatim_symbol.rb +2 -0
- data/lib/support/base_tokenizer.rb +4 -2
- data/spec/rley/base/dotted_item_spec.rb +2 -0
- data/spec/rley/base/grm_items_builder_spec.rb +2 -0
- data/spec/rley/engine_spec.rb +2 -0
- data/spec/rley/formatter/asciitree_spec.rb +4 -2
- data/spec/rley/formatter/bracket_notation_spec.rb +4 -2
- data/spec/rley/formatter/debug_spec.rb +4 -2
- data/spec/rley/formatter/json_spec.rb +4 -2
- data/spec/rley/gfg/call_edge_spec.rb +2 -0
- data/spec/rley/gfg/edge_spec.rb +2 -0
- data/spec/rley/gfg/end_vertex_spec.rb +2 -0
- data/spec/rley/gfg/epsilon_edge_spec.rb +2 -0
- data/spec/rley/gfg/grm_flow_graph_spec.rb +2 -0
- data/spec/rley/gfg/item_vertex_spec.rb +2 -0
- data/spec/rley/gfg/non_terminal_vertex_spec.rb +2 -0
- data/spec/rley/gfg/return_edge_spec.rb +2 -0
- data/spec/rley/gfg/scan_edge_spec.rb +2 -0
- data/spec/rley/gfg/shortcut_edge_spec.rb +2 -0
- data/spec/rley/gfg/start_vertex_spec.rb +2 -0
- data/spec/rley/gfg/vertex_spec.rb +2 -0
- data/spec/rley/lexical/token_range_spec.rb +2 -0
- data/spec/rley/lexical/token_spec.rb +2 -0
- data/spec/rley/parse_forest_visitor_spec.rb +2 -0
- data/spec/rley/parse_rep/ambiguous_parse_spec.rb +2 -0
- data/spec/rley/parse_rep/ast_builder_spec.rb +2 -0
- data/spec/rley/parse_rep/cst_builder_spec.rb +2 -0
- data/spec/rley/parse_rep/groucho_spec.rb +2 -0
- data/spec/rley/parse_rep/parse_forest_builder_spec.rb +2 -0
- data/spec/rley/parse_rep/parse_forest_factory_spec.rb +2 -0
- data/spec/rley/parse_rep/parse_tree_factory_spec.rb +2 -0
- data/spec/rley/parse_tree_visitor_spec.rb +2 -0
- data/spec/rley/parser/error_reason_spec.rb +2 -0
- data/spec/rley/parser/gfg_chart_spec.rb +2 -0
- data/spec/rley/parser/gfg_earley_parser_spec.rb +7 -5
- data/spec/rley/parser/gfg_parsing_spec.rb +2 -0
- data/spec/rley/parser/parse_entry_set_spec.rb +2 -0
- data/spec/rley/parser/parse_entry_spec.rb +2 -0
- data/spec/rley/parser/parse_state_spec.rb +2 -0
- data/spec/rley/parser/parse_tracer_spec.rb +16 -14
- data/spec/rley/parser/parse_walker_factory_spec.rb +2 -0
- data/spec/rley/parser/state_set_spec.rb +2 -0
- data/spec/rley/ptree/non_terminal_node_spec.rb +2 -0
- data/spec/rley/ptree/parse_tree_node_spec.rb +2 -0
- data/spec/rley/ptree/parse_tree_spec.rb +2 -0
- data/spec/rley/ptree/terminal_node_spec.rb +2 -0
- data/spec/rley/sppf/alternative_node_spec.rb +2 -0
- data/spec/rley/sppf/non_terminal_node_spec.rb +2 -0
- data/spec/rley/sppf/token_node_spec.rb +2 -0
- data/spec/rley/support/ambiguous_grammar_helper.rb +2 -0
- data/spec/rley/support/expectation_helper.rb +2 -0
- data/spec/rley/support/grammar_abc_helper.rb +2 -0
- data/spec/rley/support/grammar_ambig01_helper.rb +2 -0
- data/spec/rley/support/grammar_arr_int_helper.rb +2 -0
- data/spec/rley/support/grammar_b_expr_helper.rb +2 -0
- data/spec/rley/support/grammar_helper.rb +2 -0
- data/spec/rley/support/grammar_l0_helper.rb +2 -0
- data/spec/rley/support/grammar_pb_helper.rb +2 -0
- data/spec/rley/support/grammar_sppf_helper.rb +2 -0
- data/spec/rley/syntax/grammar_builder_spec.rb +2 -0
- data/spec/rley/syntax/grammar_spec.rb +2 -0
- data/spec/rley/syntax/grm_symbol_spec.rb +2 -0
- data/spec/rley/syntax/literal_spec.rb +2 -0
- data/spec/rley/syntax/non_terminal_spec.rb +2 -0
- data/spec/rley/syntax/production_spec.rb +2 -0
- data/spec/rley/syntax/symbol_seq_spec.rb +2 -0
- data/spec/rley/syntax/terminal_spec.rb +2 -0
- data/spec/rley/syntax/verbatim_symbol_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/base_tokenizer_spec.rb +2 -0
- metadata +4 -5
- data/Gemfile +0 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'parse_tree_node' # Load superclass
|
2
4
|
|
3
5
|
module Rley # This module is used as a namespace
|
@@ -23,7 +25,7 @@ module Rley # This module is used as a namespace
|
|
23
25
|
connector = '+- '
|
24
26
|
selfie = super(indentation)
|
25
27
|
prefix = "\n" + (' ' * connector.size * indentation) + connector
|
26
|
-
subnodes_repr = subnodes.reduce('') do |sub_result, subnode|
|
28
|
+
subnodes_repr = subnodes.reduce(+'') do |sub_result, subnode|
|
27
29
|
sub_result << prefix + subnode.to_string(indentation + 1)
|
28
30
|
end
|
29
31
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'terminal_node'
|
2
4
|
require_relative 'non_terminal_node'
|
3
5
|
|
@@ -33,7 +35,7 @@ module Rley # This module is used as a namespace
|
|
33
35
|
aVisitor.start_visit_ptree(self)
|
34
36
|
|
35
37
|
# Let's proceed with the visit of nodes
|
36
|
-
root
|
38
|
+
root&.accept(aVisitor)
|
37
39
|
|
38
40
|
aVisitor.end_visit_ptree(self)
|
39
41
|
end
|
data/lib/rley/rley_error.rb
CHANGED
data/lib/rley/sppf/leaf_node.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'token_node'
|
2
4
|
require_relative 'non_terminal_node'
|
3
5
|
require_relative 'alternative_node'
|
@@ -64,7 +66,7 @@ module Rley # This module is used as a namespace
|
|
64
66
|
aVisitor.start_visit_pforest(self)
|
65
67
|
|
66
68
|
# Let's proceed with the visit of nodes
|
67
|
-
root
|
69
|
+
root&.accept(aVisitor)
|
68
70
|
|
69
71
|
aVisitor.end_visit_pforest(self)
|
70
72
|
end
|
data/lib/rley/sppf/sppf_node.rb
CHANGED
data/lib/rley/sppf/token_node.rb
CHANGED
data/lib/rley/syntax/grammar.rb
CHANGED
data/lib/rley/syntax/literal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'symbol_seq'
|
2
4
|
|
3
5
|
module Rley # This module is used as a namespace
|
@@ -65,7 +67,7 @@ module Rley # This module is used as a namespace
|
|
65
67
|
# production.
|
66
68
|
# @return [String]
|
67
69
|
def inspect()
|
68
|
-
result = "#<#{self.class.name}:#{object_id}"
|
70
|
+
result = +"#<#{self.class.name}:#{object_id}"
|
69
71
|
result << " @name=\"#{name}\""
|
70
72
|
result << " @lhs=#{lhs.name}"
|
71
73
|
result << " @rhs=#{rhs.inspect}"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
|
3
5
|
module Rley # This module is used as a namespace
|
@@ -38,7 +40,7 @@ module Rley # This module is used as a namespace
|
|
38
40
|
# sequence of symbols.
|
39
41
|
# @return [String]
|
40
42
|
def inspect()
|
41
|
-
result = "#<#{self.class.name}:#{object_id}"
|
43
|
+
result = +"#<#{self.class.name}:#{object_id}"
|
42
44
|
symbol_names = members.map(&:name)
|
43
45
|
result << " @members=#{symbol_names}>"
|
44
46
|
return result
|
data/lib/rley/syntax/terminal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'strscan'
|
2
4
|
require_relative '../rley/lexical/token'
|
3
5
|
|
@@ -66,9 +68,9 @@ class BaseTokenizer
|
|
66
68
|
col = scanner.pos - aLexeme.size - @line_start + 1
|
67
69
|
pos = Rley::Lexical::Position.new(@lineno, col)
|
68
70
|
token = Rley::Lexical::Token.new(value, aSymbolName, pos)
|
69
|
-
rescue StandardError =>
|
71
|
+
rescue StandardError => e
|
70
72
|
puts "Failing with '#{aSymbolName}' and '#{aLexeme}'"
|
71
|
-
raise
|
73
|
+
raise e
|
72
74
|
end
|
73
75
|
|
74
76
|
return token
|
data/spec/rley/engine_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -54,12 +56,12 @@ module Rley # Re-open the module to get rid of qualified names
|
|
54
56
|
ptree
|
55
57
|
end
|
56
58
|
|
57
|
-
let(:destination) { StringIO.new('', 'w') }
|
59
|
+
let(:destination) { StringIO.new(+'', 'w') }
|
58
60
|
subject { Asciitree.new(destination) }
|
59
61
|
|
60
62
|
context 'Standard creation & initialization:' do
|
61
63
|
it 'should be initialized with an IO argument' do
|
62
|
-
expect { Asciitree.new(StringIO.new('', 'w')) }.not_to raise_error
|
64
|
+
expect { Asciitree.new(StringIO.new(+'', 'w')) }.not_to raise_error
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'should know its output destination' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -54,13 +56,13 @@ module Rley # Re-open the module to get rid of qualified names
|
|
54
56
|
ptree
|
55
57
|
end
|
56
58
|
|
57
|
-
let(:destination) { StringIO.new('', 'w') }
|
59
|
+
let(:destination) { StringIO.new(+'', 'w') }
|
58
60
|
subject { BracketNotation.new(destination) }
|
59
61
|
|
60
62
|
context 'Standard creation & initialization:' do
|
61
63
|
it 'should be initialized with an IO argument' do
|
62
64
|
expect do
|
63
|
-
BracketNotation.new(StringIO.new('', 'w'))
|
65
|
+
BracketNotation.new(StringIO.new(+'', 'w'))
|
64
66
|
end.not_to raise_error
|
65
67
|
end
|
66
68
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -74,11 +76,11 @@ module Rley # Re-open the module to get rid of qualified names
|
|
74
76
|
engine.to_pforest(parse_result)
|
75
77
|
end
|
76
78
|
|
77
|
-
let(:destination) { StringIO.new('', 'w') }
|
79
|
+
let(:destination) { StringIO.new(+'', 'w') }
|
78
80
|
|
79
81
|
context 'Standard creation & initialization:' do
|
80
82
|
it 'should be initialized with an IO argument' do
|
81
|
-
expect { Debug.new(StringIO.new('', 'w')) }.not_to raise_error
|
83
|
+
expect { Debug.new(StringIO.new(+'', 'w')) }.not_to raise_error
|
82
84
|
end
|
83
85
|
|
84
86
|
it 'should know its output destination' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../spec_helper'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -53,11 +55,11 @@ module Rley # Re-open the module to get rid of qualified names
|
|
53
55
|
ptree
|
54
56
|
end
|
55
57
|
|
56
|
-
let(:destination) { StringIO.new('', 'w') }
|
58
|
+
let(:destination) { StringIO.new(+'', 'w') }
|
57
59
|
|
58
60
|
context 'Standard creation & initialization:' do
|
59
61
|
it 'should be initialized with an IO argument' do
|
60
|
-
expect { Json.new(StringIO.new('', 'w')) }.not_to raise_error
|
62
|
+
expect { Json.new(StringIO.new(+'', 'w')) }.not_to raise_error
|
61
63
|
end
|
62
64
|
|
63
65
|
it 'should know its output destination' do
|
data/spec/rley/gfg/edge_spec.rb
CHANGED