Class: OpenvoxLint::Token
- Inherits:
-
Object
- Object
- OpenvoxLint::Token
- Defined in:
- lib/openvox-lint/token.rb
Overview
Represents a single token produced by the lexer.
Each token has a type (Symbol), a raw value (String), and positional metadata (line, column). Tokens are linked together in a doubly-linked list via prev_token / next_token so that check plugins can easily navigate the stream.
Constant Summary collapse
- FORMATTING_TYPES =
%i[ WHITESPACE INDENT NEWLINE COMMENT MLCOMMENT SLASH_COMMENT ].freeze
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#line ⇒ Object
Returns the value of attribute line.
-
#next_token ⇒ Object
Returns the value of attribute next_token.
-
#prev_token ⇒ Object
Returns the value of attribute prev_token.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#formatting? ⇒ Boolean
Convenience: is this token a formatting/whitespace token?.
-
#initialize(type, value, line, column) ⇒ Token
constructor
A new instance of Token.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, value, line, column) ⇒ Token
Returns a new instance of Token.
14 15 16 17 18 19 |
# File 'lib/openvox-lint/token.rb', line 14 def initialize(type, value, line, column) @type = type @value = value @line = line @column = column end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def column @column end |
#line ⇒ Object
Returns the value of attribute line.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def line @line end |
#next_token ⇒ Object
Returns the value of attribute next_token.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def next_token @next_token end |
#prev_token ⇒ Object
Returns the value of attribute prev_token.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def prev_token @prev_token end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/openvox-lint/token.rb', line 11 def value @value end |
Instance Method Details
#formatting? ⇒ Boolean
Convenience: is this token a formatting/whitespace token?
30 31 32 |
# File 'lib/openvox-lint/token.rb', line 30 def formatting? FORMATTING_TYPES.include?(type) end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/openvox-lint/token.rb', line 25 def inspect "#<OpenvoxLint::Token #{self}>" end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/openvox-lint/token.rb', line 21 def to_s "#{type}(#{value.inspect}) @ #{line}:#{column}" end |