lexical_analyzer 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lexical_analyzer.gemspec +1 -0
- data/lib/lexical_analyzer.rb +2 -2
- data/lib/lexical_analyzer/lexical_rule.rb +3 -4
- data/lib/lexical_analyzer/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 273933b2287cdeb8b2b222f6e7300be549035466
|
4
|
+
data.tar.gz: 07a210f72d942e13e5e6f399a3d51738eac9eb15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0cbcf9971f958e2da32f3b86504a857c9e0dd326e6167be41b256c8dc0356eafd38c7fdf0b45f7a598ac88ab3b8aa943eceebb7c22a7f2e3440d8d48ddea3a8
|
7
|
+
data.tar.gz: 7df681c1106a6009443228ade75c3b26935b82695b89baeb8d64db62e8f81cbdeb5045dbcb4a8d5de6b84738d103b863a2a27cc464aa84673cf8c88feaa80416
|
data/README.md
CHANGED
@@ -58,6 +58,9 @@ regular expression, and an optional action.
|
|
58
58
|
# Rule with default block returns [:equality, "=="] on a match.
|
59
59
|
LexicalRule.new(:equality, /\A==/)
|
60
60
|
|
61
|
+
# Rule with block equivalent to the default.
|
62
|
+
LexicalRule.new(:lparen, /\A\(/) {|value| [symbol, value]}
|
63
|
+
|
61
64
|
# Rule with an ignore block, ignores matches.
|
62
65
|
LexicalRule.new(:spaces, /\A\s+/) {|_value| false }
|
63
66
|
|
@@ -66,9 +69,7 @@ LexicalRule.new(:integer, /\A\d+/) {|value| [symbol, value.to_i] }
|
|
66
69
|
|
67
70
|
# Rule with a block that expands of to a sub-rule. Returns the value of the
|
68
71
|
# lexical analyzer in the captured variable ka.
|
69
|
-
LexicalRule.new(:identifier, /\A[a-zA-Z_]\w*(?=\W|$|\z)/) {|value|
|
70
|
-
ka.renew(text: value).get
|
71
|
-
}
|
72
|
+
LexicalRule.new(:identifier, /\A[a-zA-Z_]\w*(?=\W|$|\z)/) {|value| ka.renew(text: value).get}
|
72
73
|
```
|
73
74
|
|
74
75
|
Notes:
|
data/lexical_analyzer.gemspec
CHANGED
@@ -22,5 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.15"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "minitest", "~> 5.0"
|
25
|
+
spec.add_development_dependency 'minitest_visible', "~> 0.1"
|
25
26
|
spec.add_development_dependency 'reek', "~> 5.0.2"
|
26
27
|
end
|
data/lib/lexical_analyzer.rb
CHANGED
@@ -6,8 +6,8 @@ require_relative 'lexical_analyzer/version'
|
|
6
6
|
|
7
7
|
# The RCTP class for lexical analysis.
|
8
8
|
class LexicalAnalyzer
|
9
|
-
attr_reader
|
10
|
-
attr_reader
|
9
|
+
attr_reader :text # Access the text in the analyzer.
|
10
|
+
attr_reader :rules # Access the array of lexical rules.
|
11
11
|
|
12
12
|
# Set things up.
|
13
13
|
def initialize(text: "", rules: [])
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# The Ruby Compiler Toolkit Project - Lexical Rule
|
2
2
|
# A rule for lexical analysis.
|
3
3
|
|
4
|
+
# The RCTP class for lexical rules.
|
4
5
|
class LexicalRule
|
5
|
-
|
6
|
-
# Read access to the
|
7
|
-
attr_reader :symbol
|
6
|
+
attr_reader :symbol # Read access to the rule's symbol.
|
7
|
+
attr_reader :regex # Read access to the rule's regex.
|
8
8
|
|
9
9
|
# Create a lexical rule.
|
10
10
|
def initialize(symbol, regex, &action)
|
@@ -23,5 +23,4 @@ class LexicalRule
|
|
23
23
|
def call(value)
|
24
24
|
[symbol, value]
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexical_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PeterCamilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest_visible
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: reek
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|