class AdLint::StringLexer

DESCRIPTION

Base class of the lexical analyzer of the string.

Public Class Methods

new(str) click to toggle source

DESCRIPTION

Constructs a lexical analyzer of the string.

PARAMETER

str

String – Target string.

# File lib/adlint/lexer.rb, line 231
def initialize(str)
  @str = str
end

Public Instance Methods

execute() click to toggle source

DESCRIPTION

Executes the lexical analysis.

RETURN VALUE

TokenArray – Scanned tokens.

# File lib/adlint/lexer.rb, line 240
def execute
  lexer_ctxt = create_lexer_context(@str)
  tokenize(lexer_ctxt)
rescue Error
  raise
rescue => ex
  if lexer_ctxt
    raise InternalError.new(ex, lexer_ctxt.location)
  else
    raise InternalError.new(ex, nil)
  end
end

Private Instance Methods

create_lexer_context(str) click to toggle source

DESCRIPTION

Creates the context object.

Subclasses must implement this method.

PARAMETER

str

String – Target string object.

# File lib/adlint/lexer.rb, line 261
def create_lexer_context(str)
  subclass_responsibility
end
tokenize(lexer_ctxt) click to toggle source

DESCRIPTION

Tokenize the target content.

Subclasses must implement this method.

PARAMETER

lexer_ctxt

LexerContext – Lexical analysis context.

# File lib/adlint/lexer.rb, line 272
def tokenize(lexer_ctxt)
  subclass_responsibility
end