zenlish 0.2.02 → 0.2.06
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +455 -0
- data/CHANGELOG.md +58 -1
- data/Gemfile +5 -3
- data/README.md +27 -0
- data/Rakefile +5 -3
- data/lib/zenlish/feature/boolean_domain.rb +9 -3
- data/lib/zenlish/feature/boolean_value.rb +3 -2
- data/lib/zenlish/feature/enumeration_domain.rb +8 -1
- data/lib/zenlish/feature/feature.rb +9 -7
- data/lib/zenlish/feature/feature_def.rb +10 -6
- data/lib/zenlish/feature/feature_domain.rb +9 -3
- data/lib/zenlish/feature/feature_struct.rb +3 -1
- data/lib/zenlish/feature/feature_struct_def.rb +5 -1
- data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
- data/lib/zenlish/feature/feature_value.rb +4 -2
- data/lib/zenlish/feature/identifier_domain.rb +5 -3
- data/lib/zenlish/feature/identifier_value.rb +3 -2
- data/lib/zenlish/feature/symbol_value.rb +3 -1
- data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
- data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
- data/lib/zenlish/inflect/concatenation.rb +3 -2
- data/lib/zenlish/inflect/equals_literal.rb +7 -1
- data/lib/zenlish/inflect/feature_heading.rb +11 -5
- data/lib/zenlish/inflect/formal_argument.rb +3 -1
- data/lib/zenlish/inflect/function_call.rb +4 -1
- data/lib/zenlish/inflect/heading.rb +5 -0
- data/lib/zenlish/inflect/inflection_rule.rb +2 -0
- data/lib/zenlish/inflect/inflection_table.rb +29 -4
- data/lib/zenlish/inflect/inflection_table_builder.rb +27 -20
- data/lib/zenlish/inflect/input_asis.rb +3 -0
- data/lib/zenlish/inflect/input_expression.rb +4 -2
- data/lib/zenlish/inflect/literal_asis.rb +4 -1
- data/lib/zenlish/inflect/matches_pattern.rb +2 -0
- data/lib/zenlish/inflect/membership.rb +2 -0
- data/lib/zenlish/inflect/method_heading.rb +7 -6
- data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
- data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
- data/lib/zenlish/inflect/output_expression.rb +2 -0
- data/lib/zenlish/inflect/substitution.rb +3 -1
- data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
- data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
- data/lib/zenlish/lang/dictionary.rb +35 -29
- data/lib/zenlish/lang/lemmatizer.rb +40 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +9 -6
- data/lib/zenlish/lex/empty_lexicon_factory.rb +4 -3
- data/lib/zenlish/lex/lexeme.rb +9 -2
- data/lib/zenlish/lex/lexical_entry.rb +6 -4
- data/lib/zenlish/lex/lexicon.rb +10 -8
- data/lib/zenlish/lex/literal.rb +3 -1
- data/lib/zenlish/lexer/lexer.rb +144 -0
- data/lib/zenlish/trie/base_trie_node.rb +27 -0
- data/lib/zenlish/trie/trie.rb +132 -0
- data/lib/zenlish/trie/trie_node.rb +21 -0
- data/lib/zenlish/trie/trie_root.rb +10 -0
- data/lib/zenlish/version.rb +3 -1
- data/lib/zenlish/wclasses/adjective.rb +5 -2
- data/lib/zenlish/wclasses/adverb.rb +3 -1
- data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
- data/lib/zenlish/wclasses/adverb_not.rb +2 -0
- data/lib/zenlish/wclasses/all_word_classes.rb +4 -2
- data/lib/zenlish/wclasses/article.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary.rb +5 -2
- data/lib/zenlish/wclasses/auxiliary_be.rb +34 -1
- data/lib/zenlish/wclasses/auxiliary_do.rb +31 -0
- data/lib/zenlish/wclasses/cardinal.rb +3 -1
- data/lib/zenlish/wclasses/common_noun.rb +2 -0
- data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
- data/lib/zenlish/wclasses/conjunction.rb +2 -0
- data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/coordinator.rb +4 -2
- data/lib/zenlish/wclasses/definite_article.rb +2 -0
- data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
- data/lib/zenlish/wclasses/demonstrative_determiner.rb +40 -1
- data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/determiner.rb +3 -1
- data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
- data/lib/zenlish/wclasses/existential_there.rb +2 -0
- data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
- data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
- data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
- data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb.rb +14 -22
- data/lib/zenlish/wclasses/irregular_verb_be.rb +41 -1
- data/lib/zenlish/wclasses/irregular_verb_can.rb +35 -0
- data/lib/zenlish/wclasses/irregular_verb_do.rb +38 -1
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -6
- data/lib/zenlish/wclasses/irregular_verb_have.rb +38 -1
- data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
- data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
- data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
- data/lib/zenlish/wclasses/modal_verb_can.rb +27 -0
- data/lib/zenlish/wclasses/noun.rb +4 -2
- data/lib/zenlish/wclasses/numeral.rb +2 -0
- data/lib/zenlish/wclasses/personal_pronoun.rb +70 -1
- data/lib/zenlish/wclasses/possessive_determiner.rb +60 -0
- data/lib/zenlish/wclasses/preposition.rb +3 -1
- data/lib/zenlish/wclasses/preposition_of.rb +2 -0
- data/lib/zenlish/wclasses/preposition_than.rb +2 -0
- data/lib/zenlish/wclasses/pronoun.rb +3 -1
- data/lib/zenlish/wclasses/proper_noun.rb +10 -8
- data/lib/zenlish/wclasses/quantifier.rb +3 -1
- data/lib/zenlish/wclasses/regular_verb.rb +13 -18
- data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
- data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
- data/lib/zenlish/wclasses/verb.rb +16 -8
- data/lib/zenlish/wclasses/word_class.rb +11 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/zenlish/feature/boolean_domain_spec.rb +6 -1
- data/spec/zenlish/feature/boolean_value_spec.rb +1 -1
- data/spec/zenlish/feature/enumeration_domain_spec.rb +9 -5
- data/spec/zenlish/feature/feature_spec.rb +3 -3
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +10 -8
- data/spec/zenlish/feature/feature_struct_def_spec.rb +3 -2
- data/spec/zenlish/feature/identifier_domain_spec.rb +3 -3
- data/spec/zenlish/feature/identifier_value_spec.rb +4 -4
- data/spec/zenlish/feature/symbol_value_spec.rb +3 -3
- data/spec/zenlish/inflect/concatenation_spec.rb +7 -7
- data/spec/zenlish/inflect/feature_heading_spec.rb +23 -3
- data/spec/zenlish/inflect/formal_argument_spec.rb +2 -2
- data/spec/zenlish/inflect/function_call_spec.rb +4 -4
- data/spec/zenlish/inflect/inflection_rule_spec.rb +9 -5
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +26 -21
- data/spec/zenlish/inflect/inflection_table_spec.rb +39 -22
- data/spec/zenlish/inflect/input_asis_spec.rb +2 -6
- data/spec/zenlish/inflect/literal_asis_spec.rb +3 -3
- data/spec/zenlish/inflect/matches_pattern_spec.rb +1 -1
- data/spec/zenlish/inflect/membership_spec.rb +2 -2
- data/spec/zenlish/inflect/method_heading_spec.rb +7 -1
- data/spec/zenlish/inflect/substitution_spec.rb +1 -1
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +2 -2
- data/spec/zenlish/lang/dictionary_spec.rb +51 -16
- data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +2 -2
- data/spec/zenlish/lex/lexeme_spec.rb +16 -11
- data/spec/zenlish/lex/lexical_entry_spec.rb +1 -2
- data/spec/zenlish/lex/lexicon_spec.rb +9 -8
- data/spec/zenlish/lex/literal_spec.rb +2 -2
- data/spec/zenlish/lexer/lexer_spec.rb +52 -0
- data/spec/zenlish/parser/lesson1_spec.rb +2 -2
- data/spec/zenlish/parser/lesson2_spec.rb +31 -36
- data/spec/zenlish/parser/lesson3_spec.rb +98 -138
- data/spec/zenlish/parser/zparser_spec.rb +2 -1
- data/spec/zenlish/support/minimal_lexicon.rb +2 -0
- data/spec/zenlish/support/var2word.rb +27 -18
- data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
- data/spec/zenlish/trie/trie_spec.rb +108 -0
- data/spec/zenlish/wclasses/common_noun_spec.rb +19 -7
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +47 -0
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +60 -0
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +14 -4
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -2
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +50 -0
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +66 -0
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +69 -0
- data/spec/zenlish/wclasses/regular_verb_spec.rb +35 -15
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -2
- data/spec/zenlish_spec.rb +3 -1
- data/zenlish.gemspec +17 -14
- metadata +37 -10
- data/lib/zenlish/wclasses/modal_verb_could.rb +0 -9
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,62 @@
|
|
1
1
|
# CHANGELOG
|
2
|
+
## [0.2.06] - 2021-09-04
|
3
|
+
- Fixes and code re-styling to please `Rubocop` 1.19.1
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
- File `zenlish.gemspec` updated dependency towards `rley` gem (now ~> 0.8.03)
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- File `zenlish_grammar.rb` fixed small code breaking caused due to `Rley` v.0.8+ library.
|
10
|
+
- File `lexer_spec.rb` corrected a test.
|
11
|
+
|
12
|
+
# CHANGELOG
|
13
|
+
## [0.2.05] - 2020-02-16
|
14
|
+
Zenlish can now inflect all the lexemes in its lexicon.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- File `README.md` added demo example showing the inflection capabilities of Zenlish
|
18
|
+
- Method `Lex::Lexeme#all_inflections` added.
|
19
|
+
- Method `Inflect::InflectionTable#all_inflections` added.
|
20
|
+
- Class `WClass::DemonstrativeDeterminer`: added specific inflection tables.
|
21
|
+
- Class `WClass::PersonalPronoun`: added specific inflection tables.
|
22
|
+
- Class `WClass::PossessiveDeterminer`: added specific inflection tables.
|
23
|
+
- Method `Feature::BooleanDomain#to_a` added.
|
24
|
+
- Method `Feature::EnumerationDomain#to_a` added.
|
25
|
+
- Method `WClasses::WordClass#add_paradigm` added.
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
- Inflection table of `WClasses::IrregularVerb`
|
29
|
+
- Inflection table of `WClasses::RegularVerb`
|
30
|
+
|
31
|
+
### Removed
|
32
|
+
- Method `WClasses::Verb#add_paradigm` removed.
|
33
|
+
|
34
|
+
## [0.2.04] - 2020-02-09
|
35
|
+
Zenlish can now inflect all the verbs in its lexicon.
|
36
|
+
|
37
|
+
### Added
|
38
|
+
- Module `WordClasses::IrregularVerbCan` for cases where `can` isn't used as a modal verb.
|
39
|
+
|
40
|
+
## Changed
|
41
|
+
- File `dictionary.rb`: .
|
42
|
+
- Class `Lex::Lexicon`: more explicit error message in case of ambiguous lexeme search.
|
43
|
+
- Class `WClass::AuxiliaryBe`: added specific inflection table.
|
44
|
+
- Class `WClass::AuxiliaryDo`: added specific inflection table.
|
45
|
+
- Class `WClass::ModalVerbCan`: added specific inflection table.
|
46
|
+
|
47
|
+
### Fixed
|
48
|
+
- Class `WordClass::IrregularVerb` fixed rule for gerund spelling for verbs ending with 'oe' or 'ye'.
|
49
|
+
- Class `WordClass::RegularVerb` fixed rule for gerund spelling for verbs ending with 'oe' or 'ye'.
|
50
|
+
|
51
|
+
# CHANGELOG
|
52
|
+
## [0.2.03] - 2020-02-07
|
53
|
+
Zenlish can now inflect the irregular verbs `be`, `do`, and `have`.
|
54
|
+
|
55
|
+
## Changed
|
56
|
+
- Class `WClass::IrregularVerbBe`: added specific inflection table.
|
57
|
+
- Class `WClass::IrregularVerbDo`: added specific inflection table.
|
58
|
+
- Class `WClass::IrregularVerbHave`: added specific inflection table.
|
59
|
+
|
2
60
|
## [0.2.02] - 2020-02-06
|
3
61
|
Extending the inflection model to irregular verbs. Zenlish can inflect all irregular verbs in its dictionary (except modals and be).
|
4
62
|
|
@@ -23,7 +81,6 @@ Extending the inflection model to regular verbs. Zenlish can inflect all regular
|
|
23
81
|
- Class `Inflect::Membership` Now an inflection table can test whether a value is included in a set of values.
|
24
82
|
- Class `Inflect::NotEquals` Now an inflection table can test for inequality
|
25
83
|
|
26
|
-
|
27
84
|
## [0.2.00] - 2020-01-30
|
28
85
|
A lot of internal additions, such an initial feature model, embryonic inflection model.
|
29
86
|
This is WIP.
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in zenlish.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -101,6 +101,33 @@ end
|
|
101
101
|
# Rley::Syntax::Terminal
|
102
102
|
```
|
103
103
|
|
104
|
+
Demo of lexeme inflections
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
# Demo inflection (aka declension, conjugation)
|
108
|
+
require 'zenlish'
|
109
|
+
|
110
|
+
# The Zenlish dictionary is more than a list of words...
|
111
|
+
dict = Zenlish::Lang::Dictionary
|
112
|
+
|
113
|
+
# What are the spellings of a given common noun?
|
114
|
+
noun_body = dict.get_lexeme('body')
|
115
|
+
p noun_body.all_inflections # => ["body", "bodies"]
|
116
|
+
|
117
|
+
# What are the word forms of a personal pronoun (3rd person)?
|
118
|
+
p_3rd_pn = dict.get_lexeme('it')
|
119
|
+
p p_3rd_pn.all_inflections # => ["she", "her", "he", "him", "it", "they", "them"]
|
120
|
+
|
121
|
+
# What are the distinct forms of a regular verb?
|
122
|
+
vb_touch = dict.get_lexeme('touch')
|
123
|
+
p vb_touch.all_inflections # => ["touch", "touching", "touched", "touches"]
|
124
|
+
|
125
|
+
# What are the forms of the (highly) irregular verb be?
|
126
|
+
vb_be = dict.get_lexeme('be', Zenlish::WClasses::IrregularVerbBe)
|
127
|
+
p vb_be.all_inflections # => ["am", "being", "was", "been", "are", "were", "is"]
|
128
|
+
```
|
129
|
+
|
130
|
+
|
104
131
|
More to come...
|
105
132
|
|
106
133
|
## Principles behind the Zenlish language
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
require_relative 'feature_domain'
|
3
5
|
require_relative 'boolean_value'
|
@@ -6,19 +8,23 @@ module Zenlish
|
|
6
8
|
module Feature
|
7
9
|
class BooleanDomain < FeatureDomain
|
8
10
|
include Singleton # Use the Singleton design patttern
|
9
|
-
|
11
|
+
|
10
12
|
def build_value(aValue)
|
11
13
|
BooleanValue.new(validated_value(aValue))
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def include?(aValue)
|
15
17
|
aValue.kind_of?(TrueClass) || aValue.kind_of?(FalseClass)
|
16
18
|
end
|
17
19
|
|
20
|
+
def to_a
|
21
|
+
[false, true]
|
22
|
+
end
|
23
|
+
|
18
24
|
private
|
19
25
|
|
20
26
|
def validated_value(aValue)
|
21
|
-
if
|
27
|
+
if !aValue.is_a?(FalseClass) && !aValue.is_a?(TrueClass)
|
22
28
|
raise StandardError, "Expected a boolean instead of #{aValue.class}."
|
23
29
|
end
|
24
30
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'feature_domain'
|
2
4
|
require_relative 'symbol_value'
|
3
5
|
|
@@ -7,17 +9,22 @@ module Zenlish
|
|
7
9
|
attr_reader :enum
|
8
10
|
|
9
11
|
def initialize(*symbols)
|
12
|
+
super()
|
10
13
|
@enum = symbols
|
11
14
|
end
|
12
15
|
|
13
16
|
def build_value(aValue)
|
14
17
|
SymbolValue.new(validated_value(aValue))
|
15
18
|
end
|
16
|
-
|
19
|
+
|
17
20
|
def include?(aValue)
|
18
21
|
enum.include?(aValue)
|
19
22
|
end
|
20
23
|
|
24
|
+
def to_a
|
25
|
+
enum
|
26
|
+
end
|
27
|
+
|
21
28
|
private
|
22
29
|
|
23
30
|
def validated_value(aValue)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -5,26 +7,26 @@ module Zenlish
|
|
5
7
|
class Feature
|
6
8
|
# Forwardable mix-in module to implement delegation of specified methods.
|
7
9
|
extend Forwardable
|
8
|
-
|
10
|
+
|
9
11
|
# The feature definition
|
10
12
|
attr_reader :definition
|
11
|
-
|
13
|
+
|
12
14
|
attr_reader :binding
|
13
15
|
|
14
16
|
def_delegators :@definition, :name, :domain
|
15
|
-
|
17
|
+
|
16
18
|
# @param aDefinition [FeatureDef]
|
17
19
|
def initialize(aDefinition)
|
18
20
|
@definition = aDefinition
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
def bound?
|
22
|
-
|
24
|
+
!binding.nil?
|
23
25
|
end
|
24
|
-
|
26
|
+
|
25
27
|
def bind_to(aFeatureValue)
|
26
28
|
@binding = aFeatureValue
|
27
29
|
end
|
28
30
|
end # class
|
29
31
|
end # module
|
30
|
-
end # module
|
32
|
+
end # module
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'boolean_domain'
|
1
4
|
require_relative 'enumeration_domain'
|
2
5
|
require_relative 'feature_value'
|
3
6
|
|
@@ -26,23 +29,24 @@ module Zenlish
|
|
26
29
|
|
27
30
|
def validated_name(aName)
|
28
31
|
raise StandardError, 'feature name cannot be empty.' if aName.empty?
|
32
|
+
|
29
33
|
aName.dup
|
30
34
|
end
|
31
35
|
|
32
36
|
def validated_default(aDomain, aDefault)
|
33
37
|
if aDefault
|
34
|
-
default = aDefault
|
38
|
+
@default = aDefault
|
35
39
|
elsif aDomain.is_a?(BooleanDomain)
|
36
|
-
default = nil
|
37
|
-
|
40
|
+
@default = nil
|
41
|
+
elsif aDomain.is_a?(EnumerationDomain)
|
38
42
|
if aDomain.enum.size == 1
|
39
43
|
val = FeatureValue.new(aDomain.enum[0])
|
40
|
-
default = val
|
44
|
+
@default = val
|
41
45
|
else
|
42
|
-
default = nil
|
46
|
+
@default = nil
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end # class
|
47
51
|
end # module
|
48
|
-
end # module
|
52
|
+
end # module
|
@@ -1,9 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Zenlish
|
2
4
|
module Feature
|
3
5
|
class FeatureDomain
|
4
|
-
def include?(
|
5
|
-
raise NotImplementedError,
|
6
|
+
def include?(_value)
|
7
|
+
raise NotImplementedError, "Implement #{__callee__} method in subclass(es)."
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_a
|
11
|
+
raise NotImplementedError, "Implement #{__callee__} method in subclass(es)."
|
6
12
|
end
|
7
13
|
end # class
|
8
14
|
end # module
|
9
|
-
end # module
|
15
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'feature_domain'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -8,6 +10,7 @@ module Zenlish
|
|
8
10
|
|
9
11
|
# @param aParent [FeatureStructDef]
|
10
12
|
def initialize(aParent = nil)
|
13
|
+
super()
|
11
14
|
@parent = validated_parent(aParent)
|
12
15
|
@struct = {}
|
13
16
|
end
|
@@ -15,6 +18,7 @@ module Zenlish
|
|
15
18
|
# @param aFeatureName [String]
|
16
19
|
def [](aFeatureName)
|
17
20
|
return struct[aFeatureName] if struct.include? aFeatureName
|
21
|
+
|
18
22
|
if parent
|
19
23
|
p_struct = parent.struct
|
20
24
|
return p_struct[aFeatureName] if p_struct.include? aFeatureName
|
@@ -41,4 +45,4 @@ module Zenlish
|
|
41
45
|
end
|
42
46
|
end # class
|
43
47
|
end # module
|
44
|
-
end # module
|
48
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'boolean_domain'
|
2
4
|
require_relative 'identifier_domain'
|
3
5
|
require_relative 'enumeration_domain'
|
@@ -31,17 +33,17 @@ module Zenlish
|
|
31
33
|
struct[aName]
|
32
34
|
end
|
33
35
|
|
34
|
-
# @return [Feature::BooleanDomain]
|
36
|
+
# @return [Feature::BooleanDomain]
|
35
37
|
def boolean
|
36
38
|
BooleanDomain.instance
|
37
39
|
end
|
38
40
|
|
39
|
-
# @return [Feature::EnumerationDomain]
|
41
|
+
# @return [Feature::EnumerationDomain]
|
40
42
|
def enumeration(*items)
|
41
43
|
EnumerationDomain.new(*items)
|
42
44
|
end
|
43
|
-
|
44
|
-
def identifier(
|
45
|
+
|
46
|
+
def identifier(_default_value = nil)
|
45
47
|
IdentifierDomain.instance
|
46
48
|
end
|
47
49
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Zenlish
|
2
4
|
module Feature
|
3
5
|
class FeatureValue
|
@@ -9,9 +11,9 @@ module Zenlish
|
|
9
11
|
|
10
12
|
protected
|
11
13
|
|
12
|
-
def valid_value
|
14
|
+
def valid_value
|
13
15
|
raise NotImplementedError
|
14
16
|
end
|
15
17
|
end # class
|
16
18
|
end # module
|
17
|
-
end # module
|
19
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
require_relative 'feature_domain'
|
3
5
|
require_relative 'identifier_value'
|
@@ -10,9 +12,9 @@ module Zenlish
|
|
10
12
|
def build_value(aValue)
|
11
13
|
IdentifierValue.new(validated_value(aValue))
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def include?(aValue)
|
15
|
-
aValue =~ /^[a-zA-
|
17
|
+
aValue =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
@@ -23,7 +25,7 @@ module Zenlish
|
|
23
25
|
end
|
24
26
|
|
25
27
|
aValue
|
26
|
-
end
|
28
|
+
end
|
27
29
|
end # class
|
28
30
|
end # module
|
29
31
|
end # module
|