dendroid 0.0.0
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 +7 -0
- data/.rubocop.yml +8 -0
- data/LICENSE +22 -0
- data/README.md +60 -0
- data/Rakefile +10 -0
- data/bin/dendroid +7 -0
- data/dendroid.gemspec +23 -0
- data/lib/dendroid/dendroid.rb +0 -0
- data/lib/dendroid/syntax/grm_symbol.rb +45 -0
- data/lib/dendroid/syntax/terminal.rb +40 -0
- data/spec/dendroid/syntax/grm_symbol_spec.rb +43 -0
- data/spec/dendroid/syntax/terminal_spec.rb +29 -0
- data/spec/spec_helper.rb +13 -0
- data/version.txt +1 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c0559bafc9e9cb01c84eff72c403a538e744b88fb12b02f59f2e2de6cfb8a93
|
4
|
+
data.tar.gz: 238e91d9e6e909062c7fca3fb8a9455795fb6f24861fd5ad3be973bdda2c4269
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 779c2551fc57e8f2e0c185e5307815348bda51b2782f4b2fd616112e831cf847920f787b115c5d65035303bdab53aa2768f1f0a36e8c3da409fb4e8a7cd44094
|
7
|
+
data.tar.gz: 5be45c19d4d7ae74fc88333367362cf6c05f3278ecf94fe4110bd6f51db682edf33a1584155cfd3cffc67bc9c4efafa1c1e0444fa96a7bfea639539c1f9c4f69
|
data/.rubocop.yml
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Dimitri Geshef
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
dendroid
|
2
|
+
===========
|
3
|
+
|
4
|
+
FIXME (describe your package)
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
|
9
|
+
* FIXME (list of features and unsolved problems)
|
10
|
+
|
11
|
+
Examples
|
12
|
+
--------
|
13
|
+
|
14
|
+
FIXME (code sample of usage)
|
15
|
+
|
16
|
+
Requirements
|
17
|
+
------------
|
18
|
+
|
19
|
+
* FIXME (list of requirements)
|
20
|
+
|
21
|
+
Install
|
22
|
+
-------
|
23
|
+
|
24
|
+
* FIXME (sudo gem install, anything else)
|
25
|
+
|
26
|
+
Author
|
27
|
+
------
|
28
|
+
|
29
|
+
Original author: FIXME (author's name)
|
30
|
+
|
31
|
+
Contributors:
|
32
|
+
|
33
|
+
* FIXME (contributor 1?)
|
34
|
+
* FIXME (contributor 2?)
|
35
|
+
|
36
|
+
License
|
37
|
+
-------
|
38
|
+
|
39
|
+
(The MIT License) FIXME (different license?)
|
40
|
+
|
41
|
+
Copyright (c) 2023 FIXME (author's name)
|
42
|
+
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
44
|
+
a copy of this software and associated documentation files (the
|
45
|
+
'Software'), to deal in the Software without restriction, including
|
46
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
47
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
48
|
+
permit persons to whom the Software is furnished to do so, subject to
|
49
|
+
the following conditions:
|
50
|
+
|
51
|
+
The above copyright notice and this permission notice shall be
|
52
|
+
included in all copies or substantial portions of the Software.
|
53
|
+
|
54
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
55
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
56
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
57
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
58
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
59
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
60
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/dendroid
ADDED
data/dendroid.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'dendroid'
|
5
|
+
s.version = '0.0.0'
|
6
|
+
s.summary = 'Dendroid. TODO'
|
7
|
+
s.description = 'WIP. A Ruby implementation of a Earley parser'
|
8
|
+
s.authors = ['Dimitri Geshef']
|
9
|
+
s.email = 'famished.tiger@yahoo.com'
|
10
|
+
s.files = Dir['bin/dendroid',
|
11
|
+
'lib/*.*',
|
12
|
+
'lib/**/*.rb',
|
13
|
+
'spec/**/*.rb',
|
14
|
+
'.rubocop.yml',
|
15
|
+
'dendroid.gemspec',
|
16
|
+
'LICENSE',
|
17
|
+
'Rakefile',
|
18
|
+
'README.md',
|
19
|
+
'version.txt'
|
20
|
+
]
|
21
|
+
s.homepage = 'https://rubygems.org/gems/dendroid'
|
22
|
+
s.license = 'MIT'
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dendroid
|
4
|
+
module Syntax
|
5
|
+
# Abstract class for grammar symbols.
|
6
|
+
# A grammar symbol is an element that appears in grammar rules.
|
7
|
+
class GrmSymbol
|
8
|
+
# @return [String] The name of the grammar symbol
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
# Constructor.
|
12
|
+
# aSymbolName [String] The name of the grammar symbol.
|
13
|
+
def initialize(symbolName)
|
14
|
+
@name = valid_name(symbolName)
|
15
|
+
end
|
16
|
+
|
17
|
+
# The String representation of the grammar symbol
|
18
|
+
# @return [String]
|
19
|
+
def to_s
|
20
|
+
name.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
# Equality testing (based on symbol name)
|
24
|
+
# @return [Boolean]
|
25
|
+
def ==(other)
|
26
|
+
name == other.name
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def valid_name(symbolName)
|
32
|
+
if symbolName.is_a?(String)
|
33
|
+
stripped = symbolName.strip
|
34
|
+
if stripped.empty?
|
35
|
+
err_msg = 'A symbol name cannot be empty.'
|
36
|
+
raise StandardError, err_msg
|
37
|
+
end
|
38
|
+
stripped.to_sym
|
39
|
+
else
|
40
|
+
symbolName
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end # class
|
44
|
+
end # module
|
45
|
+
end # module
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'grm_symbol'
|
3
|
+
|
4
|
+
module Dendroid
|
5
|
+
module Syntax
|
6
|
+
# A terminal symbol is an elementary symbol of the language defined by the grammar.
|
7
|
+
# More specifically, it represents a class of 'words'(or a token) of the language.
|
8
|
+
class Terminal < GrmSymbol
|
9
|
+
# Constructor.
|
10
|
+
# aSymbolName [String] The name of the grammar symbol.
|
11
|
+
def initialize(symbolName)
|
12
|
+
super(symbolName)
|
13
|
+
freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
# Predicate method to check whether the symbol is a terminal symbol.
|
17
|
+
# @return [TrueClass]
|
18
|
+
def terminal?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
# Predicate method to check whether the symbol derives (matches)
|
23
|
+
# the empty string. As terminal symbol corresponds to an input token,
|
24
|
+
# so it is by definition non-nullable.
|
25
|
+
# @return [FalseClass]
|
26
|
+
def nullable?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
# Predicate method to check whether the symbol matches a non-empty sequence
|
31
|
+
# of terminal symbols.
|
32
|
+
# @return [TrueClass]
|
33
|
+
def productive?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end # class
|
37
|
+
end # module
|
38
|
+
end # module
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '..\..\spec_helper'
|
4
|
+
require_relative '..\..\..\lib\dendroid\syntax\grm_symbol'
|
5
|
+
|
6
|
+
describe Dendroid::Syntax::GrmSymbol do
|
7
|
+
let(:sample_symbol_name) { 'INTEGER' }
|
8
|
+
|
9
|
+
subject { described_class.new(sample_symbol_name) }
|
10
|
+
|
11
|
+
context 'Initialization:' do
|
12
|
+
it 'is initialized with a name as String' do
|
13
|
+
expect { described_class.new(sample_symbol_name) }.not_to raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is initialized with a name as Symbol' do
|
17
|
+
expect { described_class.new(:INTEGER) }.not_to raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'raises an error if the symbol name is empty' do
|
21
|
+
err_msg = 'A symbol name cannot be empty.'
|
22
|
+
expect { described_class.new('') }.to raise_error(StandardError, err_msg)
|
23
|
+
end
|
24
|
+
end # context
|
25
|
+
|
26
|
+
context 'Provided services:' do
|
27
|
+
it 'knows its name as a Symbol' do
|
28
|
+
expect(subject.name).to eq(sample_symbol_name.to_sym)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'renders a String representation of itself' do
|
32
|
+
expect(subject.to_s).to eq(sample_symbol_name)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can compare with another symbol' do
|
36
|
+
expect(subject == subject).to be_truthy
|
37
|
+
same = described_class.new(sample_symbol_name)
|
38
|
+
expect(subject == same).to be_truthy
|
39
|
+
different = described_class.new('NUMBER')
|
40
|
+
expect(subject == different).to be_falsey
|
41
|
+
end
|
42
|
+
end # context
|
43
|
+
end # describe
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '..\..\spec_helper'
|
4
|
+
require_relative '..\..\..\lib\dendroid\syntax\terminal'
|
5
|
+
|
6
|
+
describe Dendroid::Syntax::Terminal do
|
7
|
+
let(:sample_terminal_name) { 'INTEGER' }
|
8
|
+
|
9
|
+
subject { described_class.new(sample_terminal_name) }
|
10
|
+
|
11
|
+
context 'Provided services:' do
|
12
|
+
it 'knows it is a terminal symbol' do
|
13
|
+
expect(subject.terminal?).to be_truthy
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is frozen after initialization' do
|
17
|
+
expect(subject).to be_frozen
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'is not nullable' do
|
21
|
+
expect(subject).not_to be_nullable
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'is productive (generative)' do
|
25
|
+
expect(subject).to be_productive
|
26
|
+
end
|
27
|
+
end # context
|
28
|
+
end # describe
|
29
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'rubygems'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
8
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = :expect
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/version.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dendroid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dimitri Geshef
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: WIP. A Ruby implementation of a Earley parser
|
14
|
+
email: famished.tiger@yahoo.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".rubocop.yml"
|
20
|
+
- LICENSE
|
21
|
+
- README.md
|
22
|
+
- Rakefile
|
23
|
+
- bin/dendroid
|
24
|
+
- dendroid.gemspec
|
25
|
+
- lib/dendroid/dendroid.rb
|
26
|
+
- lib/dendroid/syntax/grm_symbol.rb
|
27
|
+
- lib/dendroid/syntax/terminal.rb
|
28
|
+
- spec/dendroid/syntax/grm_symbol_spec.rb
|
29
|
+
- spec/dendroid/syntax/terminal_spec.rb
|
30
|
+
- spec/spec_helper.rb
|
31
|
+
- version.txt
|
32
|
+
homepage: https://rubygems.org/gems/dendroid
|
33
|
+
licenses:
|
34
|
+
- MIT
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.3.7
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Dendroid. TODO
|
55
|
+
test_files: []
|