Class: Ibex::IR::LexerRule

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

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.

RBS:

  • (id: Integer, state: String, kind: Symbol, token: String?, pattern: String, pattern_kind: Symbol, options: String, action: String?, location: location) -> void

Parameters:

  • id: (Integer)
  • state: (String)
  • kind: (Symbol)
  • token: (String, nil)
  • pattern: (String)
  • pattern_kind: (Symbol)
  • options: (String)
  • action: (String, nil)
  • location: (location)


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

#actionString? (readonly)

Signature:

  • String?

Returns:

  • (String, nil)


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

def action
  @action
end

#idInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def id
  @id
end

#kindSymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def kind
  @kind
end

#locationlocation (readonly)

Signature:

  • location

Returns:



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

def location
  @location
end

#optionsString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def options
  @options
end

#patternString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def pattern
  @pattern
end

#pattern_kindSymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def pattern_kind
  @pattern_kind
end

#stateString (readonly)

Signature:

  • String

Returns:

  • (String)


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

def state
  @state
end

#tokenString? (readonly)

Signature:

  • String?

Returns:

  • (String, nil)


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

def token
  @token
end

Instance Method Details

#to_hHash[Symbol, untyped]

RBS:

  • () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


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