rley 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +3 -0
- data/lib/rley/constants.rb +1 -1
- data/spec/rley/parser/earley_parser_spec.rb +79 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTFlMzIyMzI5MTRiZWQwZjY2MTE3ZDNjZWMxZTUzYjc2ZmVlMGFkYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGMxNjVkMzgwMTlkYzJhMDcyOWUxMGQxZTZlYWY1YmExMGJjYmY3MA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmZiZjQ2YWFhZjdlNWE2MzhkMmFjYTVkNGRmMGMyZmRlMWY1ZTVkMWY0ZTIz
|
10
|
+
NDYyZmUwYzZjYWMwMTRhMTU3NjAxYTczZWRmMDc3OThjMmZkMDMzMjlkNmZk
|
11
|
+
NDRjNDQ2ZGM3NDhlMTk2ZDA2ZTFiMDQ3OTdhOWI4MzEyZGFkMzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjQ3YzgyNmM3NmY3Nzc1YzA2MTVlMmExZjc0YzI3NWEwM2MwZjM3OGVjMDNl
|
14
|
+
ODlkNDhiZDgwNmYyZmM4YTk3MTlhMjQ2YWY4YzczZTM5MjI3NWM5NzQwNTU4
|
15
|
+
NDAwZWZjYzY2YzQxYjJkYjkxMGU3NjQ5ZDJiMzVjYTI5MzlhMzA=
|
data/CHANGELOG.md
CHANGED
data/lib/rley/constants.rb
CHANGED
@@ -304,8 +304,8 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
304
304
|
# P => S.
|
305
305
|
# S => S "+" S.
|
306
306
|
# S => S "*" S.
|
307
|
-
# S =>
|
308
|
-
#
|
307
|
+
# S => L.
|
308
|
+
# L => an integer number token.
|
309
309
|
t_int = Syntax::Literal.new('integer', /[-+]?\d+/)
|
310
310
|
t_plus = Syntax::VerbatimSymbol.new('+')
|
311
311
|
t_star = Syntax::VerbatimSymbol.new('*')
|
@@ -328,6 +328,83 @@ module Rley # Open this namespace to avoid module qualifier prefixes
|
|
328
328
|
expect { instance.parse(tokens) }.not_to raise_error
|
329
329
|
parse_result = instance.parse(tokens)
|
330
330
|
expect(parse_result.success?).to eq(true)
|
331
|
+
|
332
|
+
###################### S(0): . 2 + 3 * 4
|
333
|
+
# Expectation chart[0]:
|
334
|
+
expected = [
|
335
|
+
"P => . S | 0", # Start rule
|
336
|
+
"S => . S '+' S | 0", # predict from (1)
|
337
|
+
"S => . S '*' S | 0", # predict from (1)
|
338
|
+
"S => . L | 0", # predict from (1)
|
339
|
+
"L => . integer | 0" # predict from (4)
|
340
|
+
]
|
341
|
+
compare_state_texts(parse_result.chart[0], expected)
|
342
|
+
|
343
|
+
###################### S(1): 2 . + 3 * 4
|
344
|
+
# Expectation chart[1]:
|
345
|
+
expected = [
|
346
|
+
"L => integer . | 0", # scan from S(0) 4
|
347
|
+
"S => L . | 0", # complete from (1) and S(0) 4
|
348
|
+
"P => S . | 0", # complete from (2) and S(0) 1
|
349
|
+
"S => S . '+' S | 0", #complete from (2) and S(0) 2
|
350
|
+
"S => S . '*' S | 0", #complete from (2) and S(0) 3
|
351
|
+
]
|
352
|
+
compare_state_texts(parse_result.chart[1], expected)
|
353
|
+
|
354
|
+
###################### S(2): 2 + . 3 * 4
|
355
|
+
# Expectation chart[2]:
|
356
|
+
expected = [
|
357
|
+
"S => S '+' . S | 0", # scan from S(1) 4
|
358
|
+
"S => . S '+' S | 2", # predict from (1)
|
359
|
+
"S => . S '*' S | 2", # predict from (1)
|
360
|
+
"S => . L | 2", # predict from (1)
|
361
|
+
"L => . integer | 2" # predict from (4)
|
362
|
+
]
|
363
|
+
compare_state_texts(parse_result.chart[2], expected)
|
364
|
+
|
365
|
+
###################### S(3): 2 + 3 . * 4
|
366
|
+
# Expectation chart[3]:
|
367
|
+
expected = [
|
368
|
+
"L => integer . | 2", # scan from S(2) 5
|
369
|
+
"S => L . | 2", # complete from (1) and S(2) 4
|
370
|
+
"S => S '+' S . | 0", # complete from (2) and S(2) 1
|
371
|
+
"S => S . '+' S | 2", # complete from (2) and S(2) 2
|
372
|
+
"S => S . '*' S | 2", # complete from (2) and S(2) 3
|
373
|
+
"P => S . | 0", # complete from (2) and S(0) 1
|
374
|
+
"S => S . '+' S | 0", #complete from (2) and S(0) 2
|
375
|
+
"S => S . '*' S | 0", #complete from (2) and S(0) 3
|
376
|
+
]
|
377
|
+
compare_state_texts(parse_result.chart[3], expected)
|
378
|
+
|
379
|
+
###################### S(4): 2 + 3 * . 4
|
380
|
+
# Expectation chart[4]:
|
381
|
+
expected = [
|
382
|
+
"S => S '*' . S | 2", # scan from S(3) 5
|
383
|
+
"S => S '*' . S | 0", # scan from S(3) 8
|
384
|
+
"S => . S '+' S | 4", # predict from (1)
|
385
|
+
"S => . S '*' S | 4", # predict from (1)
|
386
|
+
"S => . L | 4", # predict from (1)
|
387
|
+
"L => . integer | 4" # predict from (4)
|
388
|
+
]
|
389
|
+
compare_state_texts(parse_result.chart[4], expected)
|
390
|
+
|
391
|
+
###################### S(5): 2 + 3 * 4 .
|
392
|
+
# Expectation chart[5]:
|
393
|
+
expected = [
|
394
|
+
"L => integer . | 4", # scan from S(4) 6
|
395
|
+
"S => L . | 4", # complete from (1) and S(4) 5
|
396
|
+
"S => S '*' S . | 2", # complete from (2) and S(4) 1
|
397
|
+
"S => S '*' S . | 0", # complete from (2) and S(4) 2
|
398
|
+
"S => S . '+' S | 4", # complete from (2) and S(4) 3
|
399
|
+
"S => S . '*' S | 4", # complete from (2) and S(4) 4
|
400
|
+
"S => S '+' S . | 0", # complete from (2) and S(2) 1
|
401
|
+
"S => S . '+' S | 2", # complete from (2) and S(2) 2
|
402
|
+
"S => S . '*' S | 2", # complete from (2) and S(2) 3
|
403
|
+
"P => S . | 0", # Start rule
|
404
|
+
"S => S . '+' S | 0", # predict from (1)
|
405
|
+
"S => S . '*' S | 0" # predict from (1)
|
406
|
+
]
|
407
|
+
compare_state_texts(parse_result.chart[5], expected)
|
331
408
|
end
|
332
409
|
|
333
410
|
|