Class: AdLint::StringLexer

Inherits:
Object
  • Object
show all
Defined in:
lib/adlint/lexer.rb

Overview

DESCRIPTION

Base class of the lexical analyzer of the string.

Direct Known Subclasses

Cpp::StringToPPTokensLexer

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ StringLexer

DESCRIPTION

Constructs a lexical analyzer of the string.

PARAMETER

str

String – Target string.



231
232
233
# File 'lib/adlint/lexer.rb', line 231

def initialize(str)
  @str = str
end

Instance Method Details

#executeObject

DESCRIPTION

Executes the lexical analysis.

RETURN VALUE

TokenArray – Scanned tokens.



240
241
242
243
244
245
246
247
248
249
250
251
# 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