rley 0.0.07 → 0.0.08

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
- OWUyN2U0MzRhZWM3Y2MxZWU4Y2JjZWJmYjVkMGNmMmFlYzY5ODRlYQ==
4
+ MzI5OGY5NWE3MzQ1OGQ4NjFmOGIyMjQ4ZTM4Y2M0NzE4YTg2ZmRhMQ==
5
5
  data.tar.gz: !binary |-
6
- YWUzOGE1NjVhZjY3MjU1YzBhYzZkMTA5MTIwZjg2M2NlYWEwYjdjOQ==
6
+ MmNhYWMxODI3YjQ1NTMyYzk4NmE5NDk3Yzc4YTc4NTQzNjk0MzNkZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTE4NDdmNmRjZmEzNTM0OTJkZTVkMTc5OGUyMWEyNTE4ZTZkYzUxYThhYzBk
10
- YTE1ZjAyM2IzNDhjZGNiMTYwNGNlNWM3ZDYwNDBlYjM5NDlmNDcwNWNkZWI2
11
- M2MyODVkNjcwYzM5ZDgwMzVhMDY4ZjFhYWZlNjU2ZGYxYjQ3YjI=
9
+ MDZmZGFhMDVjMGI1YjQ0ZGUwNjIyMmMwNzBkYWRkOTVkMGU4ZGJhNGQ3ZDFi
10
+ YzRmMTdlMDBhZTlhOWZlMWVlNjM1ZWRhZWY5NzQ2Y2EyNDJhYzg2YWJhYjU3
11
+ YjNmMTQ5MzgwNmRlYTEyNmEyNTc1YjdhZjgxNTQ4YTNmYTA2MjA=
12
12
  data.tar.gz: !binary |-
13
- MWQ3ZTFhNjBiMmZlZGZmOWRlMzgzNjQyMWI5OTkwNjBjMzdkYmI3NDU0NzZh
14
- MWQ3Y2JlNmU3MDU3NGVmZDBhN2EyNWY2M2RhNjNlNDUwNjJhMzI0M2UwZGM4
15
- MzI0OGI3YjI5ZWM3ZDVhZDU3MTlkNjdhZGE4OWZkYWIyMGIwNTI=
13
+ ZGE3MDM5OTNlNDEwN2EwMTQzZGQ2ZmMzNmUyNjVmMGY2MmQ0MjRlMWJkMmM1
14
+ NDI3YWEzNTlhYTQzMDZlNDZjYmI1NzNiNTYwMDI0NGY4NmI4NGQ4Yjc3OGQ5
15
+ ZmE4MDQ3ZjZmYTljYTg0YjEyOWYzMmU5ODUyOTU4Yjk5MWJjZGY=
@@ -1,3 +1,7 @@
1
+ ### 0.0.08 / 2014-11-14
2
+ * [CHANGE] `EarleyParser#parse` method: Initial API documentation.
3
+ * [INFO] This version was committed to force Travis CI to execute a complete build (failed because Travis couldn't connect to GitHub)
4
+
1
5
  ### 0.0.07 / 2014-11-14
2
6
  * [CHANGE] spec file of `EarleyParser` class: Test added. Parser works with simple expression grammar.
3
7
 
@@ -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.07'
6
+ Version = '0.0.08'
7
7
 
8
8
  # Brief description of the gem.
9
9
  Description = "Ruby implementation of the Earley's parsing algorithm"
@@ -20,7 +20,8 @@ module Rley # This module is used as a namespace
20
20
  # after "advancing" the dot
21
21
  attr_reader(:next_mapping)
22
22
 
23
-
23
+ # @param aGrammar [Grammar] A context-free grammar that defines the language
24
+ # of the input to be parsed.
24
25
  def initialize(aGrammar)
25
26
  @grammar = aGrammar
26
27
  @dotted_items = build_dotted_items(grammar)
@@ -28,6 +29,9 @@ module Rley # This module is used as a namespace
28
29
  @next_mapping = build_next_mapping(dotted_items)
29
30
  end
30
31
 
32
+ # @param aTokenSequence [Array] Array of Tokens objects returned by a
33
+ # tokenizer/scanner/lexer.
34
+ # @return a Parsing object that embeds the parse result.
31
35
  def parse(aTokenSequence)
32
36
  result = Parsing.new(start_dotted_item, aTokenSequence)
33
37
  last_token_index = aTokenSequence.size
@@ -0,0 +1,22 @@
1
+ require_relative '../../../lib/rley/syntax/verbatim_symbol'
2
+ require_relative '../../../lib/rley/syntax/non_terminal'
3
+ require_relative '../../../lib/rley/syntax/production'
4
+ require_relative '../../../lib/rley/parser/token'
5
+
6
+
7
+
8
+ # Grammar 1: A very simple language
9
+ # (based on example in N. Wirth "Compiler Construction" book, p. 6)
10
+ # S ::= A.
11
+ # A ::= "a" A "c".
12
+ # A ::= "b".
13
+ # Let's create the grammar piece by piece
14
+ let(:nt_S) { Syntax::NonTerminal.new('S') }
15
+ let(:nt_A) { Syntax::NonTerminal.new('A') }
16
+ let(:a_) { Syntax::VerbatimSymbol.new('a') }
17
+ let(:b_) { Syntax::VerbatimSymbol.new('b') }
18
+ let(:c_) { Syntax::VerbatimSymbol.new('c') }
19
+ let(:prod_S) { Syntax::Production.new(nt_S, [nt_A]) }
20
+ let(:prod_A1) { Syntax::Production.new(nt_A, [a_, nt_A, c_]) }
21
+ let(:prod_A2) { Syntax::Production.new(nt_A, [b_]) }
22
+ let(:grammar_abc) { Syntax::Grammar.new([prod_S, prod_A1, prod_A2]) }
@@ -0,0 +1,16 @@
1
+ require_relative '../../../lib/rley/syntax/verbatim_symbol'
2
+ require_relative '../../../lib/rley/syntax/non_terminal'
3
+ require_relative '../../../lib/rley/syntax/production'
4
+ require_relative '../../../lib/rley/syntax/grammar'
5
+
6
+ module Rley # This module is used as a namespace
7
+ # Mix-in module that provides factory methods that simplify the construction
8
+ # of a grammar from its constituents.
9
+ module GrammarHelper
10
+ # Create a production
11
+ def production()
12
+ end
13
+ end # module
14
+ end # module
15
+
16
+ # End of file
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.07
4
+ version: 0.0.08
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
@@ -108,6 +108,8 @@ files:
108
108
  - spec/rley/parser/parsing_spec.rb
109
109
  - spec/rley/parser/state_set_spec.rb
110
110
  - spec/rley/parser/token_spec.rb
111
+ - spec/rley/support/grammar_abc.rb
112
+ - spec/rley/support/grammar_helper.rb
111
113
  - spec/rley/syntax/grammar_spec.rb
112
114
  - spec/rley/syntax/grm_symbol_spec.rb
113
115
  - spec/rley/syntax/literal_spec.rb