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, HTLexicon? lexicon, HTLexer? lexer})

Properties

column int
getter/setter pairinherited
config ParserConfig
getter/setter pair
currentModuleImports List<ImportExportDecl>
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.
getter/setter pair
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> lexemes, {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
handleTrailing(ASTNode expr, {String? separateToken}) bool
return true if separateToken is found
match(String lexeme) Token
If the token lexeme the lexeme provided, advance 1 and return the original token. If not, generate an error.
inherited
match2(Set<String> lexemes) Token
same with match, with plural types provided.
inherited
matchId() TokenIdentifier
If the current token is an identifier, advance 1 and return the original token. If not, generate an error.
inherited
matchString() TokenStringLiteral
If the current token is an identifier, advance 1 and return the original token. If not, generate an error. Note this only accept string literal but not string interpolation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseEndOfStmtMark({bool required = false}) bool
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, String? separateToken, 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) 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>
To handle the comments & empty lines before a expr;
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
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