Class: SeccompTools::Asm::Token
- Inherits:
-
Object
- Object
- SeccompTools::Asm::Token
- Defined in:
- lib/seccomp-tools/asm/token.rb
Overview
Records information of a token.
Beyond the token itself, a Token remembers where it was found so that Scanner#format_error can point at it in the source.
Instance Attribute Summary collapse
-
#col ⇒ Integer
readonly
Zero-based column number where this token starts.
-
#line ⇒ Integer
readonly
Zero-based line number where this token starts.
-
#str ⇒ String
readonly
The matched text.
-
#sym ⇒ Symbol
readonly
Type of this token, e.g.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
To compare with another Token object.
-
#initialize(sym, str, line, col) ⇒ Token
constructor
Instantiates a Token object.
Constructor Details
#initialize(sym, str, line, col) ⇒ Token
Instantiates a SeccompTools::Asm::Token object.
30 31 32 33 34 35 |
# File 'lib/seccomp-tools/asm/token.rb', line 30 def initialize(sym, str, line, col) @sym = sym @str = str @line = line @col = col end |
Instance Attribute Details
#col ⇒ Integer (readonly)
Returns Zero-based column number where this token starts.
19 20 21 |
# File 'lib/seccomp-tools/asm/token.rb', line 19 def col @col end |
#line ⇒ Integer (readonly)
Returns Zero-based line number where this token starts.
17 18 19 |
# File 'lib/seccomp-tools/asm/token.rb', line 17 def line @line end |
#str ⇒ String (readonly)
Returns The matched text.
15 16 17 |
# File 'lib/seccomp-tools/asm/token.rb', line 15 def str @str end |
#sym ⇒ Symbol (readonly)
Returns Type of this token, e.g. :NEWLINE, :SYMBOL, :GOTO, or :unknown for text the
scanner failed to recognize.
13 14 15 |
# File 'lib/seccomp-tools/asm/token.rb', line 13 def sym @sym end |
Instance Method Details
#==(other) ⇒ Boolean
To compare with another SeccompTools::Asm::Token object.
42 43 44 |
# File 'lib/seccomp-tools/asm/token.rb', line 42 def ==(other) [other.sym, other.str, other.line, other.col] == [sym, str, line, col] end |