lexical_analyzer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17cf068290c697c20216d7e8a171392caa14dc9f
4
- data.tar.gz: 44cc961d916c2b03e226138ff11c0b637f54e52b
3
+ metadata.gz: dbf597af00d3c0d71bdc33a3c045564b93b08651
4
+ data.tar.gz: e317b6e6b78414b7640d237a758dac69c99a0508
5
5
  SHA512:
6
- metadata.gz: 80a7590b7abd987fc22cdf2be1b547a79ec2b04d4ba39d9961eb71544a03ef1604935e01b66d12da0198cb8f6e5c3e7215cb74d513b018e8ebd90307449eab82
7
- data.tar.gz: 8f0483b6d822154daf2757ebeb0fb28a35ab38a0b9e42e8da10615d5d075f7f20c78b633487b10d405792e532fd3a6546ed6568344ba29bc77939c005b8fb912
6
+ metadata.gz: 134762490b51644c6bdfc648095b821bbaeeaa339a4906f63b13c63e2612eb40dce2c0e67c517c1e44d10cd47168c48092e44a66f124fb6b88d09b0ee5f22a82
7
+ data.tar.gz: 508603f176c0d591bd80c114bb2e44a09a46238e3bbc98a2347d7a21cf9069b21d328ebf5a4cb3067a145fdf40c9e2c695d17c0d18181c86c6ec5d0a41344450
data/README.md CHANGED
@@ -62,7 +62,7 @@ LexicalRule.new(:equality, /\A==/)
62
62
  LexicalRule.new(:spaces, /\A\s+/) {|_value| false }
63
63
 
64
64
  # Rule with an integer block returns [:integer, an_integer] on a match.
65
- LexicalRule.new(:integer, /\A\d+/) {|value| [@symbol, value.to_i] }
65
+ LexicalRule.new(:integer, /\A\d+/) {|value| [symbol, value.to_i] }
66
66
 
67
67
  # Rule with a block that expands of to a sub-rule. Returns the value of the
68
68
  # lexical analyzer in the captured variable ka.
@@ -1,24 +1,27 @@
1
- # The Ruby Compiler Toolkit Project - Lexical Rule
2
- # A rule for lexical analysis.
3
-
4
- class LexicalRule
5
-
6
- # Create a lexical rule.
7
- def initialize(symbol, regex, &action)
8
- @symbol = symbol
9
- @regex = regex
10
-
11
- define_singleton_method(:call, &action) if block_given?
12
- end
13
-
14
- # Does this rule match?
15
- def match(text)
16
- text.match(@regex)
17
- end
18
-
19
- # The default rule action.
20
- def call(value)
21
- [@symbol, value]
22
- end
23
-
24
- end
1
+ # The Ruby Compiler Toolkit Project - Lexical Rule
2
+ # A rule for lexical analysis.
3
+
4
+ class LexicalRule
5
+
6
+ # Read access to the symbol instance variable.
7
+ attr_reader :symbol
8
+
9
+ # Create a lexical rule.
10
+ def initialize(symbol, regex, &action)
11
+ @symbol = symbol
12
+ @regex = regex
13
+
14
+ define_singleton_method(:call, &action) if block_given?
15
+ end
16
+
17
+ # Does this rule match?
18
+ def match(text)
19
+ text.match(@regex)
20
+ end
21
+
22
+ # The default rule action.
23
+ def call(value)
24
+ [symbol, value]
25
+ end
26
+
27
+ end
@@ -1,3 +1,3 @@
1
1
  class LexicalAnalyzer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lexical_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PeterCamilleri