Class: Wool::LexicalAnalysis::Token
- Inherits:
-
Struct
- Object
- Struct
- Wool::LexicalAnalysis::Token
- Defined in:
- lib/wool/analysis/lexical_analysis.rb
Overview
This is a wrapper class around the tokens returned by Ripper. Since the tokens are just arrays, this class lets us use nice mnemonics with almost zero runtime overhead.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#col ⇒ Object
Returns the value of attribute col.
-
#line ⇒ Object
Returns the value of attribute line.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(token) ⇒ Token
constructor
Unpacks the token from Ripper and breaks it into its separate components.
Constructor Details
#initialize(token) ⇒ Token
Unpacks the token from Ripper and breaks it into its separate components.
14 15 16 17 |
# File 'lib/wool/analysis/lexical_analysis.rb', line 14 def initialize(token) pos, self.type, self.body = token self.line, self.col = pos end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
9 10 11 |
# File 'lib/wool/analysis/lexical_analysis.rb', line 9 def body @body end |
#col ⇒ Object
Returns the value of attribute col
9 10 11 |
# File 'lib/wool/analysis/lexical_analysis.rb', line 9 def col @col end |
#line ⇒ Object
Returns the value of attribute line
9 10 11 |
# File 'lib/wool/analysis/lexical_analysis.rb', line 9 def line @line end |
#type ⇒ Object
Returns the value of attribute type
9 10 11 |
# File 'lib/wool/analysis/lexical_analysis.rb', line 9 def type @type end |