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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2UzY2I3ZGYxOWEyMDIyOTg4NTc3OGNmZjBmNmQ2ZjE1ZjVjYjI4ZQ==
4
+ MTFlMzIyMzI5MTRiZWQwZjY2MTE3ZDNjZWMxZTUzYjc2ZmVlMGFkYQ==
5
5
  data.tar.gz: !binary |-
6
- YWZjNjYzZmFkOWEyNjU2NGU1NjVmOWU2ZDdjZThiZjBhNzEyMTVmZg==
6
+ ZGMxNjVkMzgwMTlkYzJhMDcyOWUxMGQxZTZlYWY1YmExMGJjYmY3MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTNlOThlZTYzNjBkZTMzNzBmOGYwM2RkNmM0M2IxNGQyMmU5NTZjMjQyMTM5
10
- MzFmZGNmYTIyYWExMDc3ZjA0Nzc1YTc1ZWI5YjIwYjBiMzgzYTQ0Mjk3NDk3
11
- MDVmYjk2NGUxMGY0NzBmOTk1NmFkY2I2YjNlZmRhZDk2MGMyYTA=
9
+ NmZiZjQ2YWFhZjdlNWE2MzhkMmFjYTVkNGRmMGMyZmRlMWY1ZTVkMWY0ZTIz
10
+ NDYyZmUwYzZjYWMwMTRhMTU3NjAxYTczZWRmMDc3OThjMmZkMDMzMjlkNmZk
11
+ NDRjNDQ2ZGM3NDhlMTk2ZDA2ZTFiMDQ3OTdhOWI4MzEyZGFkMzg=
12
12
  data.tar.gz: !binary |-
13
- ZDI3MWMzMzVjMDBkZDFiZDlmODNmM2MwYTI1ZTFiM2I1YmY3NjY1MDQ4Mjlj
14
- ZDA4ZWFlZDFjZGNhNmM4YTJiYjg0YmM1ZGI0ZGExMmQxN2U5NzlmNDg2MTA3
15
- MWRhZDdkYTBkODJhOWZmZDI2NDFmNGVlZWI5MDRmMTQyMTQwN2E=
13
+ YjQ3YzgyNmM3NmY3Nzc1YzA2MTVlMmExZjc0YzI3NWEwM2MwZjM3OGVjMDNl
14
+ ODlkNDhiZDgwNmYyZmM4YTk3MTlhMjQ2YWY4YzczZTM5MjI3NWM5NzQwNTU4
15
+ NDAwZWZjYzY2YzQxYjJkYjkxMGU3NjQ5ZDJiMzVjYTI5MzlhMzA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### 0.0.17 / 2014-11-23
2
+ * [CHANGE] File `earley_parser_spec.rb`: Added step-by-step test of ambiguous grammar parsing.
3
+
1
4
  ### 0.0.16 / 2014-11-23
2
5
  * [NEW] Method `DottedItem#to_s` Returns a text representation of an instance.
3
6
  * [NEW] Method `ParseState#to_s`
@@ -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.0.16'
6
+ Version = '0.0.17'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Ruby implementation of the Earley's parsing algorithm"
@@ -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 => T.
308
- # T => an integer number token.
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef