dendroid 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dendroid.gemspec +6 -2
- data/lib/dendroid/syntax/non_terminal.rb +43 -0
- data/lib/dendroid/syntax/terminal.rb +4 -4
- data/spec/dendroid/syntax/non_terminal_spec.rb +16 -0
- data/version.txt +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff4ff7eb5079476c9a8e2dffc5bfa1a52fe1d801f03f275a89815c272a806805
|
4
|
+
data.tar.gz: 34ea2ca6aa3eb8370a818f87a39ede323422acbf2007a63cf5c2524a41f85064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d77f31670304b1a34c9ce7dd596bdc221a78d607e0f2a1b820f31b8b82f0c1da41a031bc33d7829296acba4c613299428962567f3942ee3843edbd8e64c908ce
|
7
|
+
data.tar.gz: 28515f2fb59f08da94a6af6cd3b05dbacf1c10ebe9bc49c1f44e312b4f3d2d1068d6699f8cbe2d6aae0f1a75be9ccf7177c6b17c91ac836441cc41c2eb541c5d
|
data/dendroid.gemspec
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'dendroid'
|
5
|
-
s.version =
|
5
|
+
s.version = begin
|
6
|
+
LIBPATH = ::File.expand_path( __FILE__) + ::File::SEPARATOR
|
7
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
8
|
+
::File.read(PATH + 'version.txt').strip
|
9
|
+
end
|
6
10
|
s.summary = 'Dendroid. TODO'
|
7
11
|
s.description = 'WIP. A Ruby implementation of a Earley parser'
|
8
12
|
s.authors = ['Dimitri Geshef']
|
@@ -18,6 +22,6 @@ Gem::Specification.new do |s|
|
|
18
22
|
'README.md',
|
19
23
|
'version.txt'
|
20
24
|
]
|
21
|
-
s.homepage = 'https://
|
25
|
+
s.homepage = 'https://github.com/famished-tiger/Dendroid'
|
22
26
|
s.license = 'MIT'
|
23
27
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'grm_symbol'
|
3
|
+
|
4
|
+
module Dendroid
|
5
|
+
module Syntax
|
6
|
+
# A non-terminal symbol (sometimes called a syntactic variable) represents
|
7
|
+
# a composition of terminal or non-terminal symbols
|
8
|
+
class NonTerminal < GrmSymbol
|
9
|
+
# @return [Boolean] true if symbol can derive the null token
|
10
|
+
attr_accessor :nullable
|
11
|
+
|
12
|
+
# @return [Boolean] true iff the symbol always matches a non-empty
|
13
|
+
# sequence of terminal symbols
|
14
|
+
attr_accessor :productive
|
15
|
+
|
16
|
+
# Constructor.
|
17
|
+
# aSymbolName [String] The name of the grammar symbol.
|
18
|
+
def initialize(symbolName)
|
19
|
+
super(symbolName)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Predicate method to check whether the symbol is a terminal symbol.
|
23
|
+
# @return [FalseClass]
|
24
|
+
def terminal?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Predicate method to check whether the symbol can derive (match)
|
29
|
+
# the null token.
|
30
|
+
# @return [Boolean]
|
31
|
+
def nullable?
|
32
|
+
@nullable
|
33
|
+
end
|
34
|
+
|
35
|
+
# Predicate method to check whether the symbol always matches
|
36
|
+
# a non-empty sequence of terminal symbols.
|
37
|
+
# @return [Boolean]
|
38
|
+
def productive?
|
39
|
+
@productive
|
40
|
+
end
|
41
|
+
end # class
|
42
|
+
end # module
|
43
|
+
end # module
|
@@ -20,15 +20,15 @@ module Dendroid
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Predicate method to check whether the symbol derives (matches)
|
23
|
-
# the empty string. As terminal symbol corresponds to an input token,
|
24
|
-
#
|
23
|
+
# the empty string. As a terminal symbol corresponds to an input token,
|
24
|
+
# it is by definition non-nullable.
|
25
25
|
# @return [FalseClass]
|
26
26
|
def nullable?
|
27
27
|
false
|
28
28
|
end
|
29
29
|
|
30
|
-
# Predicate method to check whether the symbol matches
|
31
|
-
# of terminal symbols.
|
30
|
+
# Predicate method to check whether the symbol always matches
|
31
|
+
# a non-empty sequence of terminal symbols.
|
32
32
|
# @return [TrueClass]
|
33
33
|
def productive?
|
34
34
|
true
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '..\..\spec_helper'
|
4
|
+
require_relative '..\..\..\lib\dendroid\syntax\non_terminal'
|
5
|
+
|
6
|
+
describe Dendroid::Syntax::NonTerminal do
|
7
|
+
let(:sample_nonterminal_name) { 'EXPRESSION' }
|
8
|
+
|
9
|
+
subject { described_class.new(sample_nonterminal_name) }
|
10
|
+
|
11
|
+
context 'Provided services:' do
|
12
|
+
it 'knows it is not a terminal symbol' do
|
13
|
+
expect(subject.terminal?).to be_falsey
|
14
|
+
end
|
15
|
+
end # context
|
16
|
+
end # describe
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dendroid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
@@ -24,12 +24,14 @@ files:
|
|
24
24
|
- dendroid.gemspec
|
25
25
|
- lib/dendroid/dendroid.rb
|
26
26
|
- lib/dendroid/syntax/grm_symbol.rb
|
27
|
+
- lib/dendroid/syntax/non_terminal.rb
|
27
28
|
- lib/dendroid/syntax/terminal.rb
|
28
29
|
- spec/dendroid/syntax/grm_symbol_spec.rb
|
30
|
+
- spec/dendroid/syntax/non_terminal_spec.rb
|
29
31
|
- spec/dendroid/syntax/terminal_spec.rb
|
30
32
|
- spec/spec_helper.rb
|
31
33
|
- version.txt
|
32
|
-
homepage: https://
|
34
|
+
homepage: https://github.com/famished-tiger/Dendroid
|
33
35
|
licenses:
|
34
36
|
- MIT
|
35
37
|
metadata: {}
|