Class: Electr::LexicalUnit
- Inherits:
-
Object
- Object
- Electr::LexicalUnit
- Defined in:
- lib/electr/parser/lexical_unit.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .closed_parenthesis ⇒ Object
- .constant(value) ⇒ Object
- .fcall(value) ⇒ Object
- .fname(value) ⇒ Object
- .name(value) ⇒ Object
- .numeric(value) ⇒ Object
- .open_parenthesis ⇒ Object
- .operator(value) ⇒ Object
- .value(value) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #closed_parenthesis? ⇒ Boolean
- #constant? ⇒ Boolean
- #fcall? ⇒ Boolean
- #fname? ⇒ Boolean
-
#initialize(type, value) ⇒ LexicalUnit
constructor
type - Symbol value - String.
- #number? ⇒ Boolean
- #numeric? ⇒ Boolean
- #open_parenthesis? ⇒ Boolean
- #operator? ⇒ Boolean
- #value? ⇒ Boolean
Constructor Details
#initialize(type, value) ⇒ LexicalUnit
type - Symbol value - String
11 12 13 14 |
# File 'lib/electr/parser/lexical_unit.rb', line 11 def initialize(type, value) @type = type @value = value end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/electr/parser/lexical_unit.rb', line 7 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/electr/parser/lexical_unit.rb', line 7 def value @value end |
Class Method Details
.closed_parenthesis ⇒ Object
24 |
# File 'lib/electr/parser/lexical_unit.rb', line 24 def self.closed_parenthesis ; new(:closed_parenthesis, ")") ; end |
.constant(value) ⇒ Object
18 |
# File 'lib/electr/parser/lexical_unit.rb', line 18 def self.constant(value) ; new(:constant, value) ; end |
.fcall(value) ⇒ Object
22 |
# File 'lib/electr/parser/lexical_unit.rb', line 22 def self.fcall(value) ; new(:fcall, value) ; end |
.fname(value) ⇒ Object
21 |
# File 'lib/electr/parser/lexical_unit.rb', line 21 def self.fname(value) ; new(:fname, value) ; end |
.name(value) ⇒ Object
20 |
# File 'lib/electr/parser/lexical_unit.rb', line 20 def self.name(value) ; new(:name, value) ; end |
.numeric(value) ⇒ Object
16 |
# File 'lib/electr/parser/lexical_unit.rb', line 16 def self.numeric(value) ; new(:numeric, value) ; end |
.open_parenthesis ⇒ Object
23 |
# File 'lib/electr/parser/lexical_unit.rb', line 23 def self.open_parenthesis ; new(:open_parenthesis, "(") ; end |
.operator(value) ⇒ Object
17 |
# File 'lib/electr/parser/lexical_unit.rb', line 17 def self.operator(value) ; new(:operator, value) ; end |
.value(value) ⇒ Object
19 |
# File 'lib/electr/parser/lexical_unit.rb', line 19 def self.value(value) ; new(:value, value) ; end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'lib/electr/parser/lexical_unit.rb', line 26 def ==(other) @type == other.type && @value == other.value end |
#closed_parenthesis? ⇒ Boolean
58 59 60 |
# File 'lib/electr/parser/lexical_unit.rb', line 58 def closed_parenthesis? @type == :closed_parenthesis end |
#constant? ⇒ Boolean
38 39 40 |
# File 'lib/electr/parser/lexical_unit.rb', line 38 def constant? @type == :constant end |
#fcall? ⇒ Boolean
50 51 52 |
# File 'lib/electr/parser/lexical_unit.rb', line 50 def fcall? @type == :fcall end |
#fname? ⇒ Boolean
46 47 48 |
# File 'lib/electr/parser/lexical_unit.rb', line 46 def fname? @type == :fname end |
#number? ⇒ Boolean
54 55 56 |
# File 'lib/electr/parser/lexical_unit.rb', line 54 def number? numeric? || constant? || value? end |
#numeric? ⇒ Boolean
30 31 32 |
# File 'lib/electr/parser/lexical_unit.rb', line 30 def numeric? @type == :numeric end |
#open_parenthesis? ⇒ Boolean
62 63 64 |
# File 'lib/electr/parser/lexical_unit.rb', line 62 def open_parenthesis? @type == :open_parenthesis end |
#operator? ⇒ Boolean
34 35 36 |
# File 'lib/electr/parser/lexical_unit.rb', line 34 def operator? @type == :operator end |
#value? ⇒ Boolean
42 43 44 |
# File 'lib/electr/parser/lexical_unit.rb', line 42 def value? @type == :value end |