Lexer¶
- class understand.Lexer¶
Bases:
objectA lexical stream generated for a file
entity.The original file must exist and be unchanged from the last database reparse. The first
lexeme(token) in the stream can be accessed usingfirst. A lexer can be iterated over, where each item returned is alexeme.Lexer and lexeme line and column numbers are 1-based.
Methods Summary
first()Return the first lexeme for the lexer.
lexeme(line, column)Return the lexeme at the specified line and column.
lexemes([start_line [,end_line]])Return a list of lexemes.
lines()Return the number of lines in the lexer.
Methods Documentation
- first() understand.Lexeme¶
Return the first lexeme for the lexer.
- Return type:
- Returns:
the first understand.Lexeme
- lexeme(line, column) understand.Lexeme¶
Return the lexeme at the specified line and column.
- Parameters:
line (integer) – the line number
column (integer) – the column number
- Return type:
- Returns:
the lexeme at the location
- lexemes([start_line[, end_line]]) list[understand.Lexeme]¶
Return a list of lexemes.
If the optional parameters start_line or end_line are are specified, only the lexemes within these lines are returned.
- Parameters:
start_line (integer or None) – Optional start line
end_line (integer or None) – Optional start line
- Return type:
list[understand.Lexeme]
- Returns:
a list of lexemes
- lines() int¶
Return the number of lines in the lexer.
- Return type:
int
- Returns:
the number of lines