rley 0.8.00 → 0.8.05
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +47 -3
- data/CHANGELOG.md +32 -4
- data/examples/NLP/pico_en_demo.rb +2 -2
- data/examples/data_formats/JSON/README.md +34 -0
- data/examples/data_formats/JSON/sample01.json +3 -0
- data/examples/data_formats/JSON/sample01.svg +36 -0
- data/examples/data_formats/JSON/sample02.json +6 -0
- data/examples/data_formats/JSON/sample02.svg +128 -0
- data/examples/data_formats/JSON/sample03.json +88 -0
- data/examples/general/calc_iter1/README.md +26 -0
- data/examples/general/calc_iter2/README.md +55 -0
- data/examples/general/general_examples.md +37 -0
- data/examples/tokenizer/README.md +46 -0
- data/examples/tokenizer/loxxy_raw_scanner.rex +98 -0
- data/examples/tokenizer/loxxy_raw_scanner.rex.rb +256 -0
- data/examples/tokenizer/loxxy_tokenizer.rb +94 -0
- data/examples/tokenizer/run_tokenizer.rb +29 -0
- data/lib/rley/constants.rb +1 -1
- data/lib/rley/lexical/literal.rb +29 -0
- data/lib/rley/lexical/token.rb +7 -4
- data/lib/rley/notation/all_notation_nodes.rb +3 -1
- data/lib/rley/notation/ast_builder.rb +185 -191
- data/lib/rley/notation/ast_node.rb +5 -5
- data/lib/rley/notation/ast_visitor.rb +3 -1
- data/lib/rley/notation/grammar.rb +1 -1
- data/lib/rley/notation/grammar_builder.rb +87 -33
- data/lib/rley/notation/grouping_node.rb +1 -1
- data/lib/rley/notation/parser.rb +56 -56
- data/lib/rley/notation/sequence_node.rb +3 -3
- data/lib/rley/notation/symbol_node.rb +2 -2
- data/lib/rley/notation/tokenizer.rb +3 -15
- data/lib/rley/parse_rep/ast_base_builder.rb +35 -4
- data/lib/rley/parser/gfg_chart.rb +5 -4
- data/lib/rley/parser/gfg_earley_parser.rb +1 -1
- data/lib/rley/syntax/base_grammar_builder.rb +8 -2
- data/lib/rley/syntax/match_closest.rb +7 -7
- data/lib/rley.rb +1 -1
- data/spec/rley/lexical/literal_spec.rb +33 -0
- data/spec/rley/lexical/token_spec.rb +15 -4
- data/spec/rley/notation/grammar_builder_spec.rb +57 -50
- data/spec/rley/notation/parser_spec.rb +183 -184
- data/spec/rley/notation/tokenizer_spec.rb +98 -104
- data/spec/rley/parser/dangling_else_spec.rb +20 -20
- data/spec/rley/parser/gfg_chart_spec.rb +0 -1
- data/spec/rley/parser/gfg_earley_parser_spec.rb +166 -147
- data/spec/rley/parser/gfg_parsing_spec.rb +2 -2
- data/spec/rley/syntax/base_grammar_builder_spec.rb +7 -8
- data/spec/rley/syntax/grammar_spec.rb +6 -9
- data/spec/rley/syntax/match_closest_spec.rb +4 -4
- metadata +19 -9
- data/lib/rley/parser/parse_tracer.rb +0 -103
- data/lib/rley/syntax/literal.rb +0 -20
- data/lib/rley/syntax/verbatim_symbol.rb +0 -27
- data/spec/rley/syntax/literal_spec.rb +0 -31
- data/spec/rley/syntax/verbatim_symbol_spec.rb +0 -38
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
|
5
|
-
require_relative '../../../lib/rley/syntax/
|
5
|
+
require_relative '../../../lib/rley/syntax/terminal'
|
6
6
|
require_relative '../../../lib/rley/syntax/non_terminal'
|
7
7
|
require_relative '../../../lib/rley/syntax/production'
|
8
8
|
|
@@ -25,7 +25,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
25
25
|
|
26
26
|
def build_verbatim_symbols(symbols)
|
27
27
|
result = {}
|
28
|
-
symbols.each { |symb| result[symb] =
|
28
|
+
symbols.each { |symb| result[symb] = Terminal.new(symb) }
|
29
29
|
result
|
30
30
|
end
|
31
31
|
|
@@ -36,7 +36,7 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Grammar symbols for integer arithmetic expressions
|
39
|
-
let(:number) {
|
39
|
+
let(:number) { Terminal.new('number') } # Positive integers only
|
40
40
|
let(:add_op) { NonTerminal.new('add_op') }
|
41
41
|
let(:add_operators) { [grm1_ops['+'], grm1_ops['-']] }
|
42
42
|
let(:mult_op) { NonTerminal.new('mult_op') }
|
@@ -75,9 +75,9 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
75
75
|
let(:nt_B) { NonTerminal.new('B') }
|
76
76
|
let(:nt_C) { NonTerminal.new('C') }
|
77
77
|
let(:nt_D) { NonTerminal.new('D') }
|
78
|
-
let(:a_) {
|
79
|
-
let(:b_) {
|
80
|
-
let(:c_) {
|
78
|
+
let(:a_) { Terminal.new('a') }
|
79
|
+
let(:b_) { Terminal.new('b') }
|
80
|
+
let(:c_) { Terminal.new('c') }
|
81
81
|
let(:prod_S) { Production.new(nt_S, [nt_A]) }
|
82
82
|
let(:prod_A1) { Production.new(nt_A, [a_, nt_A, c_]) }
|
83
83
|
let(:prod_A2) { Production.new(nt_A, [b_]) }
|
@@ -104,9 +104,6 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
104
104
|
let(:conjunction) { NonTerminal.new('Conjunction') }
|
105
105
|
let(:conjunction_list) { %w(and or but) }
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
107
|
let(:noun_prods) { prods_for_list(noun, noun_list) }
|
111
108
|
let(:verb_prods) { prods_for_list(verb, verb_list) }
|
112
109
|
let(:adjective_prods) { prods_for_list(adjective, adjective_list) }
|
@@ -16,19 +16,19 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
16
16
|
module Syntax # Open this namespace to avoid module qualifier prefixes
|
17
17
|
describe MatchClosest do
|
18
18
|
# 'stmt' => 'IF boolean THEN stmt ELSE stmt'
|
19
|
-
let(:boolean) { NonTerminal.new('boolean') }
|
19
|
+
let(:boolean) { NonTerminal.new('boolean') }
|
20
20
|
let(:stmt) { NonTerminal.new('stmt') }
|
21
21
|
let(:if_t) { Terminal.new('IF') }
|
22
22
|
let(:then_t) { Terminal.new('THEN') }
|
23
|
-
let(:else_t) { Terminal.new('ELSE') }
|
23
|
+
let(:else_t) { Terminal.new('ELSE') }
|
24
24
|
let(:sequence) { [if_t, boolean, then_t, stmt, else_t, stmt] }
|
25
25
|
let(:prod) { Production.new(stmt, sequence) }
|
26
26
|
|
27
|
-
subject{ MatchClosest.new(prod.rhs.members, 4, 'IF') }
|
27
|
+
subject { MatchClosest.new(prod.rhs.members, 4, 'IF') }
|
28
28
|
|
29
29
|
context 'Initialization:' do
|
30
30
|
it 'should be created with an symbol seq., an indice and a name' do
|
31
|
-
expect { MatchClosest.new(prod.rhs.members, 4, 'IF')
|
31
|
+
expect { MatchClosest.new(prod.rhs.members, 4, 'IF') }.not_to raise_error
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should know the index argument' do
|
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.8.
|
4
|
+
version: 0.8.05
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- examples/NLP/nano_eng/nano_en_demo.rb
|
93
93
|
- examples/NLP/nano_eng/nano_grammar.rb
|
94
94
|
- examples/NLP/pico_en_demo.rb
|
95
|
+
- examples/data_formats/JSON/README.md
|
95
96
|
- examples/data_formats/JSON/cli_options.rb
|
96
97
|
- examples/data_formats/JSON/json_ast_builder.rb
|
97
98
|
- examples/data_formats/JSON/json_ast_nodes.rb
|
@@ -99,20 +100,33 @@ files:
|
|
99
100
|
- examples/data_formats/JSON/json_grammar.rb
|
100
101
|
- examples/data_formats/JSON/json_lexer.rb
|
101
102
|
- examples/data_formats/JSON/json_minifier.rb
|
103
|
+
- examples/data_formats/JSON/sample01.json
|
104
|
+
- examples/data_formats/JSON/sample01.svg
|
105
|
+
- examples/data_formats/JSON/sample02.json
|
106
|
+
- examples/data_formats/JSON/sample02.svg
|
107
|
+
- examples/data_formats/JSON/sample03.json
|
108
|
+
- examples/general/calc_iter1/README.md
|
102
109
|
- examples/general/calc_iter1/calc_ast_builder.rb
|
103
110
|
- examples/general/calc_iter1/calc_ast_nodes.rb
|
104
111
|
- examples/general/calc_iter1/calc_demo.rb
|
105
112
|
- examples/general/calc_iter1/calc_grammar.rb
|
106
113
|
- examples/general/calc_iter1/calc_lexer.rb
|
107
114
|
- examples/general/calc_iter1/spec/calculator_spec.rb
|
115
|
+
- examples/general/calc_iter2/README.md
|
108
116
|
- examples/general/calc_iter2/calc_ast_builder.rb
|
109
117
|
- examples/general/calc_iter2/calc_ast_nodes.rb
|
110
118
|
- examples/general/calc_iter2/calc_demo.rb
|
111
119
|
- examples/general/calc_iter2/calc_grammar.rb
|
112
120
|
- examples/general/calc_iter2/calc_lexer.rb
|
113
121
|
- examples/general/calc_iter2/spec/calculator_spec.rb
|
122
|
+
- examples/general/general_examples.md
|
114
123
|
- examples/general/left.rb
|
115
124
|
- examples/general/right.rb
|
125
|
+
- examples/tokenizer/README.md
|
126
|
+
- examples/tokenizer/loxxy_raw_scanner.rex
|
127
|
+
- examples/tokenizer/loxxy_raw_scanner.rex.rb
|
128
|
+
- examples/tokenizer/loxxy_tokenizer.rb
|
129
|
+
- examples/tokenizer/run_tokenizer.rb
|
116
130
|
- lib/rley.rb
|
117
131
|
- lib/rley/base/base_parser.rb
|
118
132
|
- lib/rley/base/dotted_item.rb
|
@@ -137,6 +151,7 @@ files:
|
|
137
151
|
- lib/rley/gfg/start_vertex.rb
|
138
152
|
- lib/rley/gfg/vertex.rb
|
139
153
|
- lib/rley/interface.rb
|
154
|
+
- lib/rley/lexical/literal.rb
|
140
155
|
- lib/rley/lexical/token.rb
|
141
156
|
- lib/rley/lexical/token_range.rb
|
142
157
|
- lib/rley/notation/all_notation_nodes.rb
|
@@ -166,7 +181,6 @@ files:
|
|
166
181
|
- lib/rley/parser/parse_entry.rb
|
167
182
|
- lib/rley/parser/parse_entry_set.rb
|
168
183
|
- lib/rley/parser/parse_entry_tracker.rb
|
169
|
-
- lib/rley/parser/parse_tracer.rb
|
170
184
|
- lib/rley/parser/parse_walker_factory.rb
|
171
185
|
- lib/rley/ptree/non_terminal_node.rb
|
172
186
|
- lib/rley/ptree/parse_tree.rb
|
@@ -184,13 +198,11 @@ files:
|
|
184
198
|
- lib/rley/syntax/base_grammar_builder.rb
|
185
199
|
- lib/rley/syntax/grammar.rb
|
186
200
|
- lib/rley/syntax/grm_symbol.rb
|
187
|
-
- lib/rley/syntax/literal.rb
|
188
201
|
- lib/rley/syntax/match_closest.rb
|
189
202
|
- lib/rley/syntax/non_terminal.rb
|
190
203
|
- lib/rley/syntax/production.rb
|
191
204
|
- lib/rley/syntax/symbol_seq.rb
|
192
205
|
- lib/rley/syntax/terminal.rb
|
193
|
-
- lib/rley/syntax/verbatim_symbol.rb
|
194
206
|
- lib/support/base_tokenizer.rb
|
195
207
|
- spec/rley/base/dotted_item_spec.rb
|
196
208
|
- spec/rley/base/grm_items_builder_spec.rb
|
@@ -211,6 +223,7 @@ files:
|
|
211
223
|
- spec/rley/gfg/shortcut_edge_spec.rb
|
212
224
|
- spec/rley/gfg/start_vertex_spec.rb
|
213
225
|
- spec/rley/gfg/vertex_spec.rb
|
226
|
+
- spec/rley/lexical/literal_spec.rb
|
214
227
|
- spec/rley/lexical/token_range_spec.rb
|
215
228
|
- spec/rley/lexical/token_spec.rb
|
216
229
|
- spec/rley/notation/grammar_builder_spec.rb
|
@@ -254,13 +267,11 @@ files:
|
|
254
267
|
- spec/rley/syntax/base_grammar_builder_spec.rb
|
255
268
|
- spec/rley/syntax/grammar_spec.rb
|
256
269
|
- spec/rley/syntax/grm_symbol_spec.rb
|
257
|
-
- spec/rley/syntax/literal_spec.rb
|
258
270
|
- spec/rley/syntax/match_closest_spec.rb
|
259
271
|
- spec/rley/syntax/non_terminal_spec.rb
|
260
272
|
- spec/rley/syntax/production_spec.rb
|
261
273
|
- spec/rley/syntax/symbol_seq_spec.rb
|
262
274
|
- spec/rley/syntax/terminal_spec.rb
|
263
|
-
- spec/rley/syntax/verbatim_symbol_spec.rb
|
264
275
|
- spec/spec_helper.rb
|
265
276
|
- spec/support/base_tokenizer_spec.rb
|
266
277
|
homepage: https://github.com/famished-tiger/Rley
|
@@ -310,6 +321,7 @@ test_files:
|
|
310
321
|
- spec/rley/gfg/shortcut_edge_spec.rb
|
311
322
|
- spec/rley/gfg/start_vertex_spec.rb
|
312
323
|
- spec/rley/gfg/vertex_spec.rb
|
324
|
+
- spec/rley/lexical/literal_spec.rb
|
313
325
|
- spec/rley/lexical/token_range_spec.rb
|
314
326
|
- spec/rley/lexical/token_spec.rb
|
315
327
|
- spec/rley/notation/grammar_builder_spec.rb
|
@@ -342,11 +354,9 @@ test_files:
|
|
342
354
|
- spec/rley/syntax/base_grammar_builder_spec.rb
|
343
355
|
- spec/rley/syntax/grammar_spec.rb
|
344
356
|
- spec/rley/syntax/grm_symbol_spec.rb
|
345
|
-
- spec/rley/syntax/literal_spec.rb
|
346
357
|
- spec/rley/syntax/match_closest_spec.rb
|
347
358
|
- spec/rley/syntax/non_terminal_spec.rb
|
348
359
|
- spec/rley/syntax/production_spec.rb
|
349
360
|
- spec/rley/syntax/symbol_seq_spec.rb
|
350
361
|
- spec/rley/syntax/terminal_spec.rb
|
351
|
-
- spec/rley/syntax/verbatim_symbol_spec.rb
|
352
362
|
- spec/support/base_tokenizer_spec.rb
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
module Rley # This module is used as a namespace
|
6
|
-
module Parser # This module is used as a namespace
|
7
|
-
# Utility class used to trace the parsing of a token sequence.
|
8
|
-
class ParseTracer
|
9
|
-
# The stream where the trace output is sent
|
10
|
-
attr_reader(:ostream)
|
11
|
-
|
12
|
-
# The trace level
|
13
|
-
attr_reader(:level)
|
14
|
-
attr_reader(:lexemes)
|
15
|
-
attr_reader(:col_width)
|
16
|
-
|
17
|
-
def initialize(aTraceLevel, anIO, aTokenSequence)
|
18
|
-
@level = aTraceLevel <= 0 ? 0 : [aTraceLevel, 2].min
|
19
|
-
@ostream = anIO
|
20
|
-
@lexemes = aTokenSequence.map(&:lexeme)
|
21
|
-
|
22
|
-
emit_tokens
|
23
|
-
emit_heading
|
24
|
-
end
|
25
|
-
|
26
|
-
# Emit the trace text to the output IO
|
27
|
-
# if the given trace level is equal or greater to the
|
28
|
-
# trace level of the tracer instance.
|
29
|
-
def print_if(aLevel, text)
|
30
|
-
ostream.print(text) if level >= aLevel
|
31
|
-
end
|
32
|
-
|
33
|
-
# Emit the trace of a scanning step.
|
34
|
-
def trace_scanning(aStatesetIndex, aParseState)
|
35
|
-
return unless level
|
36
|
-
|
37
|
-
scan_picture = "[#{'-' * (col_width - 1)}]"
|
38
|
-
org = OpenStruct.new(origin: aStatesetIndex - 1,
|
39
|
-
dotted_rule: aParseState.dotted_rule)
|
40
|
-
trace_diagram(aStatesetIndex, org, scan_picture)
|
41
|
-
end
|
42
|
-
|
43
|
-
def trace_prediction(aStatesetIndex, aParseState)
|
44
|
-
return unless level
|
45
|
-
|
46
|
-
trace_diagram(aStatesetIndex, aParseState, '>')
|
47
|
-
end
|
48
|
-
|
49
|
-
def trace_completion(aStatesetIndex, aParseState)
|
50
|
-
return unless level
|
51
|
-
|
52
|
-
if aStatesetIndex == lexemes.size && aParseState.origin.zero? &&
|
53
|
-
aParseState.complete?
|
54
|
-
picture = '=' * (col_width * lexemes.size - 1)
|
55
|
-
else
|
56
|
-
count = col_width * (aStatesetIndex - aParseState.origin) - 1
|
57
|
-
picture = '-' * count
|
58
|
-
end
|
59
|
-
completion_picture = "[#{picture}#{aParseState.complete? ? ']' : '>'}"
|
60
|
-
trace_diagram(aStatesetIndex, aParseState, completion_picture)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def emit_tokens
|
66
|
-
literals = lexemes.map { |lx| "'#{lx}'" }
|
67
|
-
print_if 1, "[#{literals.join(', ')}]\n"
|
68
|
-
end
|
69
|
-
|
70
|
-
def emit_heading
|
71
|
-
longest = lexemes.map(&:length).max
|
72
|
-
@col_width = longest + 3
|
73
|
-
headers = lexemes.map { |l| l.center(col_width - 1, ' ').to_s }
|
74
|
-
print_if 1, "|.#{headers.join('.')}.|\n"
|
75
|
-
end
|
76
|
-
|
77
|
-
# rubocop: disable Style/StringConcatenation
|
78
|
-
def padding(aStatesetIndex, aParseState, aPicture)
|
79
|
-
l_pad_pattern = '.' + ' ' * (col_width - 1)
|
80
|
-
left_padding = l_pad_pattern * [0, aParseState.origin].max
|
81
|
-
r_pad_pattern = ' ' * (col_width - 1) + '.'
|
82
|
-
right_padding = r_pad_pattern * (lexemes.size - aStatesetIndex)
|
83
|
-
return left_padding + aPicture + right_padding
|
84
|
-
end
|
85
|
-
# rubocop: enable Style/StringConcatenation
|
86
|
-
|
87
|
-
def parse_state_str(aStatesetIndex, aParseState)
|
88
|
-
"[#{aParseState.origin}:#{aStatesetIndex}] #{aParseState.dotted_rule}"
|
89
|
-
end
|
90
|
-
|
91
|
-
def trace_diagram(aStatesetIndex, aParseState, aPicture)
|
92
|
-
diagram = padding(aStatesetIndex, aParseState, aPicture)
|
93
|
-
prefix = '|'
|
94
|
-
suffix = "| #{parse_state_str(aStatesetIndex, aParseState)}"
|
95
|
-
trace = prefix + diagram + suffix
|
96
|
-
|
97
|
-
print_if 1, "#{trace}\n"
|
98
|
-
end
|
99
|
-
end # class
|
100
|
-
end # module
|
101
|
-
end # module
|
102
|
-
|
103
|
-
# End of file
|
data/lib/rley/syntax/literal.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'terminal' # Load superclass
|
4
|
-
|
5
|
-
module Rley # This module is used as a namespace
|
6
|
-
module Syntax # This module is used as a namespace
|
7
|
-
# A literal is terminal symbol that matches a lexical pattern
|
8
|
-
class Literal < Terminal
|
9
|
-
# The exact text representation of the word.
|
10
|
-
attr_reader(:pattern)
|
11
|
-
|
12
|
-
def initialize(aName, aPattern)
|
13
|
-
super(aName)
|
14
|
-
@pattern = aPattern
|
15
|
-
end
|
16
|
-
end # class
|
17
|
-
end # module
|
18
|
-
end # module
|
19
|
-
|
20
|
-
# End of file
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'terminal' # Load superclass
|
4
|
-
|
5
|
-
module Rley # This module is used as a namespace
|
6
|
-
module Syntax # This module is used as a namespace
|
7
|
-
# A verbatim word is terminal symbol that represents one unique word
|
8
|
-
# in the language defined the grammar.
|
9
|
-
class VerbatimSymbol < Terminal
|
10
|
-
# The exact text representation of the word.
|
11
|
-
attr_reader(:text)
|
12
|
-
|
13
|
-
def initialize(aText)
|
14
|
-
super(aText) # Do we need to separate the text from the name?
|
15
|
-
@text = aText.dup
|
16
|
-
end
|
17
|
-
|
18
|
-
# The String representation of the verbatim symbol
|
19
|
-
# @return [String]
|
20
|
-
def to_s
|
21
|
-
"'#{text}'"
|
22
|
-
end
|
23
|
-
end # class
|
24
|
-
end # module
|
25
|
-
end # module
|
26
|
-
|
27
|
-
# End of file
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../spec_helper'
|
4
|
-
|
5
|
-
# Load the class under test
|
6
|
-
require_relative '../../../lib/rley/syntax/literal'
|
7
|
-
|
8
|
-
module Rley # Open this namespace to avoid module qualifier prefixes
|
9
|
-
module Syntax # Open this namespace to avoid module qualifier prefixes
|
10
|
-
describe Literal do
|
11
|
-
let(:sample_name) { 'ordinal' }
|
12
|
-
subject { Literal.new(sample_name, /\d+/) }
|
13
|
-
|
14
|
-
context 'Initialization:' do
|
15
|
-
it 'should be created with a name and regexp' do
|
16
|
-
expect { Literal.new(sample_name, /\d+/) }.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should know its name' do
|
20
|
-
expect(subject.name).to eq(sample_name)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should know its pattern' do
|
24
|
-
expect(subject.pattern).to eq(/\d+/)
|
25
|
-
end
|
26
|
-
end # context
|
27
|
-
end # describe
|
28
|
-
end # module
|
29
|
-
end # module
|
30
|
-
|
31
|
-
# End of file
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../spec_helper'
|
4
|
-
|
5
|
-
# Load the class under test
|
6
|
-
require_relative '../../../lib/rley/syntax/verbatim_symbol'
|
7
|
-
|
8
|
-
module Rley # Open this namespace to avoid module qualifier prefixes
|
9
|
-
module Syntax # Open this namespace to avoid module qualifier prefixes
|
10
|
-
describe VerbatimSymbol do
|
11
|
-
let(:sample_name) { 'cheapest' }
|
12
|
-
subject { VerbatimSymbol.new(sample_name) }
|
13
|
-
|
14
|
-
context 'Initialization:' do
|
15
|
-
it 'should be created with a word' do
|
16
|
-
expect { VerbatimSymbol.new('cheapest') }.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should know its name' do
|
20
|
-
expect(subject.name).to eq(sample_name)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should know its text representation' do
|
24
|
-
expect(subject.text).to eq(sample_name)
|
25
|
-
end
|
26
|
-
end # context
|
27
|
-
|
28
|
-
context 'Provided services:' do
|
29
|
-
it 'should give its text representation' do
|
30
|
-
expected = "'#{sample_name}'"
|
31
|
-
expect(subject.to_s).to eq(expected)
|
32
|
-
end
|
33
|
-
end # context
|
34
|
-
end # describe
|
35
|
-
end # module
|
36
|
-
end # module
|
37
|
-
|
38
|
-
# End of file
|