Class: DeadEnd::LexValue

Inherits:
Object
  • Object
show all
Defined in:
lib/dead_end/lex_value.rb

Overview

Value object for accessing lex values

This lex:

[1, 0], :on_ident, "describe", CMDARG

Would translate into:

lex.line # => 1
lex.type # => :on_indent
lex.token # => "describe"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, type, token, state, last_lex = nil) ⇒ LexValue

Returns a new instance of LexValue.



18
19
20
21
22
23
24
25
# File 'lib/dead_end/lex_value.rb', line 18

def initialize(line, type, token, state, last_lex = nil)
  @line = line
  @type = type
  @token = token
  @state = state

  set_kw_end(last_lex)
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



16
17
18
# File 'lib/dead_end/lex_value.rb', line 16

def line
  @line
end

#stateObject (readonly)

Returns the value of attribute state.



16
17
18
# File 'lib/dead_end/lex_value.rb', line 16

def state
  @state
end

#tokenObject (readonly)

Returns the value of attribute token.



16
17
18
# File 'lib/dead_end/lex_value.rb', line 16

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/dead_end/lex_value.rb', line 16

def type
  @type
end

Instance Method Details

#expr_beg?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/dead_end/lex_value.rb', line 62

def expr_beg?
  state.anybits?(Ripper::EXPR_BEG)
end

#expr_label?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/dead_end/lex_value.rb', line 66

def expr_label?
  state.allbits?(Ripper::EXPR_LABEL)
end

#fname?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/dead_end/lex_value.rb', line 46

def fname?
  state.allbits?(Ripper::EXPR_FNAME)
end

#ignore_newline?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/dead_end/lex_value.rb', line 50

def ignore_newline?
  type == :on_ignored_nl
end

#is_end?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/dead_end/lex_value.rb', line 54

def is_end?
  @is_end
end

#is_kw?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/dead_end/lex_value.rb', line 58

def is_kw?
  @is_kw
end