class Solver::Lexer

Constants

RULE_METHODS
RULE_NAMES

Public Class Methods

new( input=nil, options = {} ) click to toggle source
Calls superclass method
# File lib/plympton/SolverLexer.rb, line 96
def initialize( input=nil, options = {} )
  super( input, options )

end

Public Instance Methods

digit!() click to toggle source

lexer rule digit! (DIGIT) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 532
def digit!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 15 )

  
  # - - - - main rule block - - - -
  # at line 117:18: '0' .. '9'
  match_range( 0x30, 0x39 )

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 15 )

end
div!() click to toggle source

lexer rule div! (DIV) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 195
def div!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 4 )

  type = DIV
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 24:7: '/'
  match( 0x2f )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 4 )

end
exp!() click to toggle source

lexer rule exp! (EXP) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 243
def exp!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 6 )

  type = EXP
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 26:7: '^'
  match( 0x5e )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 6 )

end
float!() click to toggle source

lexer rule float! (FLOAT) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 387
def float!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 11 )

  type = FLOAT
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 108:12: INT '.' INT
  int!
  match( 0x2e )
  int!

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 11 )

end
int!() click to toggle source

lexer rule int! (INT) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 339
def int!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 10 )

  type = INT
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 107:11: ( DIGIT )+
  # at file 107:11: ( DIGIT )+
  match_count_1 = 0
  while true
    alt_1 = 2
    look_1_0 = @input.peek( 1 )

    if ( look_1_0.between?( 0x30, 0x39 ) )
      alt_1 = 1

    end
    case alt_1
    when 1
      # at line 107:12: DIGIT
      digit!

    else
      match_count_1 > 0 and break
      eee = EarlyExit(1)


      raise eee
    end
    match_count_1 += 1
  end


  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 10 )

end
lparen!() click to toggle source

lexer rule lparen! (LPAREN) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 267
def lparen!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 7 )

  type = LPAREN
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 27:10: '('
  match( 0x28 )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 7 )

end
minus!() click to toggle source

lexer rule minus! (MINUS) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 147
def minus!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 2 )

  type = MINUS
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 22:9: '-'
  match( 0x2d )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 2 )

end
mod!() click to toggle source

lexer rule mod! (MOD) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 219
def mod!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 5 )

  type = MOD
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 25:7: '%'
  match( 0x25 )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 5 )

end
modifier!() click to toggle source

lexer rule modifier! (MODIFIER) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 549
def modifier!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 16 )

  
  # - - - - main rule block - - - -
  # at line
  if @input.peek(1) == 0x61 || @input.peek(1) == 0x73
    @input.consume
  else
    mse = MismatchedSet( nil )
    recover mse
    raise mse
  end



ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 16 )

end
modvar!() click to toggle source

lexer rule modvar! (MODVAR) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 413
def modvar!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 12 )

  type = MODVAR
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 109:13: 'A' .. 'G' ( MODIFIER )
  match_range( 0x41, 0x47 )
  # at line 109:21: ( MODIFIER )
  # at line 109:22: MODIFIER
  modifier!


  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 12 )

end
mult!() click to toggle source

lexer rule mult! (MULT) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 171
def mult!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 3 )

  type = MULT
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 23:8: '*'
  match( 0x2a )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 3 )

end
plus!() click to toggle source
                      • lexer rules - - - - - - - - - - - -

lexer rule plus! (PLUS) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 123
def plus!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 1 )

  type = PLUS
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 21:8: '+'
  match( 0x2b )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 1 )

end
recover( error = $! ) click to toggle source

Recovery function handling errors

# File lib/plympton/SolverLexer.rb, line 106
def recover( error = $! )
        puts "Lexer Recovering: #{error}"
        exit(1)
end
report_error( error = $! ) click to toggle source

Reporting function handling errors

# File lib/plympton/SolverLexer.rb, line 112
def report_error( error = $! )
        puts "Lexer Reporting: #{error}"
        exit(1)
end
rparen!() click to toggle source

lexer rule rparen! (RPAREN) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 291
def rparen!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 8 )

  type = RPAREN
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 28:10: ')'
  match( 0x29 )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 8 )

end
t__19!() click to toggle source

lexer rule t__19! (T__19) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 315
def t__19!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 9 )

  type = T__19
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 29:9: 'ln'
  match( "ln" )

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 9 )

end
token!() click to toggle source

main rule used to study the input at the current position, and choose the proper lexer rule to call in order to fetch the next token

usually, you don’t make direct calls to this method, but instead use the next_token method, which will build and emit the actual next token

# File lib/plympton/SolverLexer.rb, line 579
def token!
  # at line 1:8: ( PLUS | MINUS | MULT | DIV | MOD | EXP | LPAREN | RPAREN | T__19 | INT | FLOAT | MODVAR | UNMODVAR | WHITESPACE )
  alt_3 = 14
  alt_3 = @dfa3.predict( @input )
  case alt_3
  when 1
    # at line 1:10: PLUS
    plus!

  when 2
    # at line 1:15: MINUS
    minus!

  when 3
    # at line 1:21: MULT
    mult!

  when 4
    # at line 1:26: DIV
    div!

  when 5
    # at line 1:30: MOD
    mod!

  when 6
    # at line 1:34: EXP
    exp!

  when 7
    # at line 1:38: LPAREN
    lparen!

  when 8
    # at line 1:45: RPAREN
    rparen!

  when 9
    # at line 1:52: T__19
    t__19!

  when 10
    # at line 1:58: INT
    int!

  when 11
    # at line 1:62: FLOAT
    float!

  when 12
    # at line 1:68: MODVAR
    modvar!

  when 13
    # at line 1:75: UNMODVAR
    unmodvar!

  when 14
    # at line 1:84: WHITESPACE
    whitespace!

  end
end
unmodvar!() click to toggle source

lexer rule unmodvar! (UNMODVAR) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 441
def unmodvar!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 13 )

  type = UNMODVAR
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 110:14: ( 'R' | 'U' | 'V' )
  if @input.peek(1) == 0x52 || @input.peek( 1 ).between?( 0x55, 0x56 )
    @input.consume
  else
    mse = MismatchedSet( nil )
    recover mse
    raise mse
  end



  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 13 )

end
whitespace!() click to toggle source

lexer rule whitespace! (WHITESPACE) (in solver.g)

# File lib/plympton/SolverLexer.rb, line 473
def whitespace!
  # -> uncomment the next line to manually enable rule tracing
  # trace_in( __method__, 14 )

  type = WHITESPACE
  channel = ANTLR3::DEFAULT_CHANNEL

  
  # - - - - main rule block - - - -
  # at line 111:14: ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' )+
  # at file 111:14: ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' )+
  match_count_2 = 0
  while true
    alt_2 = 2
    look_2_0 = @input.peek( 1 )

    if ( look_2_0.between?( 0x9, 0xa ) || look_2_0.between?( 0xc, 0xd ) || look_2_0 == 0x20 )
      alt_2 = 1

    end
    case alt_2
    when 1
      # at line
      if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek( 1 ).between?( 0xc, 0xd ) || @input.peek(1) == 0x20
        @input.consume
      else
        mse = MismatchedSet( nil )
        recover mse
        raise mse
      end



    else
      match_count_2 > 0 and break
      eee = EarlyExit(2)


      raise eee
    end
    match_count_2 += 1
  end

  # --> action
   channel = HIDDEN; 
  # <-- action

  
  @state.type = type
  @state.channel = channel

ensure
  # -> uncomment the next line to manually enable rule tracing
  # trace_out( __method__, 14 )

end

Private Instance Methods

initialize_dfas() click to toggle source
Calls superclass method
# File lib/plympton/SolverLexer.rb, line 695
def initialize_dfas
  super rescue nil
  @dfa3 = DFA3.new( self, 3 )

end