HTParser class abstract

A general parser, with abstract method to parse a token list or string content.

Mixed in types
Implementers

Constructors

HTParser({ParserConfig? config, required HTLexicon lexicon})

Properties

column int
getter/setter pairinherited
config ParserConfig
getter/setter pair
currentModuleImports List<ImportExportDecl>
getter/setter pair
currentPrecedings List<ASTAnnotation>
getter/setter pair
currentSource HTSource?
getter/setter pair
currrentFileName String?
The file current under processing, used in error message.
getter/setter pairinherited
curTok Token
Get current token.
getter/setter pairinherited
endOfFile Token
getter/setter pairinherited
errors List<HTError>
getter/setter pairinherited
firstTok Token
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
lexer HTLexer
Lexer used by this parser, created from lexicon.
latefinal
lexicon HTLexicon
Lexicon definition used by this parser.
latefinal
line int
getter/setter pairinherited
name String
the identity name of this parser.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

advance([int distance = 1]) Token
Advance till reach distance, return the token at original position.
inherited
expect(List<String> types, {bool consume = false}) bool
Check current token and some tokens after it to see if the types match, return a boolean result. If consume is true, will advance.
inherited
handlePrecedings() bool
To handle the comments & empty lines before a expr;
handleTrailing(ASTNode expr, {bool handleComma = true, String? endMarkForCommaExpressions}) → void
match(String type) Token
If the token match the type provided, advance 1 and return the original token. If not, generate an error.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseExpr() ASTNode
To read the current token from current position and produce an AST expression. Normally this is the entry point of recursive descent parsing. Class that implements HTParser must define this method.
parseExprList<T extends ASTNode>({required String endToken, bool handleComma = true, required T? parseFunction()}) List<T>
A functional programming way to parse expression seperated by comma, such as parameter list, argumetn list, list, group... etc. the comma after the last expression is optional. Note that this method will not consume either the start or the end mark.
parseSource(HTSource source, {bool printPerformanceStatistics = false}) ASTSource
Convert string content into ASTSource by a certain grammar rules set.
parseStmt({required ParseStyle style}) ASTNode?
parseTokens(Token token, {HTSource? source, ParseStyle? style}) List<ASTNode>
Convert tokens into a list of ASTNode by a certain grammar rules set.
peek(int distance) Token
Get a token at a relative distance from current position.
inherited
resetFlags() → void
savePrecedings() List<ASTAnnotation>
seek(String type) Token
Search for a token type, return the token next to it.
inherited
seekGroupClosing(Map<String, String> groupClosings) Token
Search for parentheses end that can close the current one, return the token next to it.
inherited
setPrecedings(ASTNode expr) bool
setTokens({required Token token, int? line, int? column}) → void
Set current tokens.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

anonymousFunctionIndex int
getter/setter pair