Class: Electr::LexicalUnit

Inherits:
Object
  • Object
show all
Defined in:
lib/electr/parser/lexical_unit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/electr/parser/lexical_unit.rb', line 7

def type
  @type
end

#valueObject (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_parenthesisObject



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_parenthesisObject



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

Returns:

  • (Boolean)


58
59
60
# File 'lib/electr/parser/lexical_unit.rb', line 58

def closed_parenthesis?
  @type == :closed_parenthesis
end

#constant?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/electr/parser/lexical_unit.rb', line 38

def constant?
  @type == :constant
end

#fcall?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/electr/parser/lexical_unit.rb', line 50

def fcall?
  @type == :fcall
end

#fname?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/electr/parser/lexical_unit.rb', line 46

def fname?
  @type == :fname
end

#number?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/electr/parser/lexical_unit.rb', line 54

def number?
  numeric? || constant? || value?
end

#numeric?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/electr/parser/lexical_unit.rb', line 30

def numeric?
  @type == :numeric
end

#open_parenthesis?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/electr/parser/lexical_unit.rb', line 62

def open_parenthesis?
  @type == :open_parenthesis
end

#operator?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/electr/parser/lexical_unit.rb', line 34

def operator?
  @type == :operator
end

#value?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/electr/parser/lexical_unit.rb', line 42

def value?
  @type == :value
end