Class: Lrama::Lexer::Token::Base
- Inherits:
-
Object
- Object
- Lrama::Lexer::Token::Base
show all
- Defined in:
- lib/lrama/lexer/token/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(s_value:, alias_name: nil, location: nil) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
20
21
|
# File 'lib/lrama/lexer/token/base.rb', line 15
def initialize(s_value:, alias_name: nil, location: nil)
s_value.freeze
@s_value = s_value
@alias_name = alias_name
@location = location
@errors = []
end
|
Instance Attribute Details
#alias_name ⇒ Object
10
11
12
|
# File 'lib/lrama/lexer/token/base.rb', line 10
def alias_name
@alias_name
end
|
#errors ⇒ Object
12
13
14
|
# File 'lib/lrama/lexer/token/base.rb', line 12
def errors
@errors
end
|
#location ⇒ Object
9
10
11
|
# File 'lib/lrama/lexer/token/base.rb', line 9
def location
@location
end
|
#referred ⇒ Object
11
12
13
|
# File 'lib/lrama/lexer/token/base.rb', line 11
def referred
@referred
end
|
#s_value ⇒ Object
8
9
10
|
# File 'lib/lrama/lexer/token/base.rb', line 8
def s_value
@s_value
end
|
Instance Method Details
#==(other) ⇒ Object
34
35
36
|
# File 'lib/lrama/lexer/token/base.rb', line 34
def ==(other)
self.class == other.class && self.s_value == other.s_value
end
|
#first_column ⇒ Object
Also known as:
column
45
46
47
|
# File 'lib/lrama/lexer/token/base.rb', line 45
def first_column
location.first_column
end
|
#first_line ⇒ Object
Also known as:
line
39
40
41
|
# File 'lib/lrama/lexer/token/base.rb', line 39
def first_line
location.first_line
end
|
#invalid_ref(ref, message) ⇒ Object
61
62
63
64
|
# File 'lib/lrama/lexer/token/base.rb', line 61
def invalid_ref(ref, message)
location = self.location.partial_location(ref.first_column, ref.last_column)
raise location.generate_error_message(message)
end
|
#last_column ⇒ Object
56
57
58
|
# File 'lib/lrama/lexer/token/base.rb', line 56
def last_column
location.last_column
end
|
#last_line ⇒ Object
51
52
53
|
# File 'lib/lrama/lexer/token/base.rb', line 51
def last_line
location.last_line
end
|
#referred_by?(string) ⇒ Boolean
29
30
31
|
# File 'lib/lrama/lexer/token/base.rb', line 29
def referred_by?(string)
[self.s_value, self.alias_name].compact.include?(string)
end
|
#to_s ⇒ Object
24
25
26
|
# File 'lib/lrama/lexer/token/base.rb', line 24
def to_s
"value: `#{s_value}`, location: #{location}"
end
|
#validate ⇒ Object
67
68
69
|
# File 'lib/lrama/lexer/token/base.rb', line 67
def validate
true
end
|