Appearance
Parser Class
Definition
Recursive-descent parser that transforms a linear stream of Token instances into an abstract syntax tree rooted at AstNode.
- Namespace:
JASE.Expressions - Assembly:
JASE.Expressions.dll
Constructors
| Name | Description |
|---|---|
Parser(IEnumerable<Token> tokens) | Initializes a new instance of the Parser class. |
Methods
| Name | Description |
|---|---|
AstNode ParseExpression() | Parses a full expression and enforces that all tokens are consumed. |
bool TryParseExpression(out AstNode node) | Attempts to parse an expression from the current token stream. |
Remarks
The parser implements:
Numeric, boolean, string, and date literalsUnary operators: +, -, !Binary operators with precedence: ??, ||, &&, equality, comparison, additive, multiplicativeConditional (ternary) operator: cond ? a : bFunction calls and general invocation: f(x), obj.Method(x)Member access: obj.Property, Type.StaticMemberImplied multiplication: 2x, 2(3+4) Use ParseExpression for top-level parsing to ensure that no trailing tokens remain after the main expression.