Class: PuppetLint::Lexer::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-lint/lexer/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value, line, column) ⇒ Token

Internal: Initialise a new Token object.

type - An upper case Symbol describing the type of Token. value - The String value of the Token. line - The Integer line number where the Token can be found in the

manifest.

column - The Integer number of characters from the start of the line to

the start of the Token.

Returns the instantiated Token.



42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet-lint/lexer/token.rb', line 42

def initialize(type, value, line, column)
  @value = value
  @type = type
  @line = line
  @column = column
  @next_token = nil
  @prev_token = nil
  @next_code_token = nil
  @prev_code_token = nil
end

Instance Attribute Details

#columnObject (readonly)

Internal: Returns the Integer column number of the line of the manifest text where the Token can be found.



16
17
18
# File 'lib/puppet-lint/lexer/token.rb', line 16

def column
  @column
end

#lineObject (readonly)

Internal: Returns the Integer line number of the manifest text where the Token can be found.



12
13
14
# File 'lib/puppet-lint/lexer/token.rb', line 12

def line
  @line
end

#next_code_tokenObject

Internal: Gets/sets the next code token (skips whitespace, comments, etc) in the manifest.



26
27
28
# File 'lib/puppet-lint/lexer/token.rb', line 26

def next_code_token
  @next_code_token
end

#next_tokenObject

Internal: Gets/sets the next token in the manifest.



19
20
21
# File 'lib/puppet-lint/lexer/token.rb', line 19

def next_token
  @next_token
end

#prev_code_tokenObject

Internal: Gets/sets the previous code tokne (skips whitespace, comments, etc) in the manifest.



30
31
32
# File 'lib/puppet-lint/lexer/token.rb', line 30

def prev_code_token
  @prev_code_token
end

#prev_tokenObject

Internal: Gets/sets the previous token in the manifest.



22
23
24
# File 'lib/puppet-lint/lexer/token.rb', line 22

def prev_token
  @prev_token
end

#typeObject (readonly)

Internal: Returns the Symbol type of the Token.



5
6
7
# File 'lib/puppet-lint/lexer/token.rb', line 5

def type
  @type
end

#valueObject (readonly)

Internal: Returns the String value of the Token.



8
9
10
# File 'lib/puppet-lint/lexer/token.rb', line 8

def value
  @value
end

Instance Method Details

#inspectObject

Internal: Produce a human friendly description of the Token when inspected.

Returns a String describing the Token.



57
58
59
# File 'lib/puppet-lint/lexer/token.rb', line 57

def inspect
  "<Token #{@type.inspect} (#{@value}) @#{@line}:#{@column}>"
end