Class: Ibex::IR::LexerRule

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/ir/lexer_ir.rb

Overview

One normalized, state-scoped lexer rule.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, state:, kind:, token:, pattern:, pattern_kind:, options:, action:, location:) ⇒ LexerRule

Returns a new instance of LexerRule.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ibex/ir/lexer_ir.rb', line 22

def initialize(id:, state:, kind:, token:, pattern:, pattern_kind:, options:, action:, location:)
  @id = id
  @state = state.freeze
  @kind = kind
  @token = token&.freeze
  @pattern = pattern.freeze
  @pattern_kind = pattern_kind
  @options = options.freeze
  @action = action&.freeze
  @location = IR.deep_freeze(location)
  freeze
end

Instance Attribute Details

#actionObject (readonly)

: String?



17
18
19
# File 'lib/ibex/ir/lexer_ir.rb', line 17

def action
  @action
end

#idObject (readonly)

: Integer



10
11
12
# File 'lib/ibex/ir/lexer_ir.rb', line 10

def id
  @id
end

#kindObject (readonly)

: Symbol



12
13
14
# File 'lib/ibex/ir/lexer_ir.rb', line 12

def kind
  @kind
end

#locationObject (readonly)

: location



18
19
20
# File 'lib/ibex/ir/lexer_ir.rb', line 18

def location
  @location
end

#optionsObject (readonly)

: String



16
17
18
# File 'lib/ibex/ir/lexer_ir.rb', line 16

def options
  @options
end

#patternObject (readonly)

: String



14
15
16
# File 'lib/ibex/ir/lexer_ir.rb', line 14

def pattern
  @pattern
end

#pattern_kindObject (readonly)

: Symbol



15
16
17
# File 'lib/ibex/ir/lexer_ir.rb', line 15

def pattern_kind
  @pattern_kind
end

#stateObject (readonly)

: String



11
12
13
# File 'lib/ibex/ir/lexer_ir.rb', line 11

def state
  @state
end

#tokenObject (readonly)

: String?



13
14
15
# File 'lib/ibex/ir/lexer_ir.rb', line 13

def token
  @token
end

Instance Method Details

#to_hObject



36
37
38
39
40
41
# File 'lib/ibex/ir/lexer_ir.rb', line 36

def to_h
  {
    id: @id, state: @state, kind: @kind, token: @token, pattern: @pattern,
    pattern_kind: @pattern_kind, options: @options, action: @action, loc: @location
  }
end