fn base_expr_precedence<'db, const SELECT: u32>(
db: &'db dyn Db,
parser: &mut Parser<'_, 'db>,
) -> Result<Option<AstExprKind<'db>>, ParseFail<'db>>Expand description
Parses base expressions - the “atoms” of the expression grammar.
Base expressions are those that don’t involve operators or complex precedence:
- Literals: Numbers, strings, booleans (
42,"hello",true) - Identifiers: Variable names and
self - Control flow:
ifexpressions,returnstatements - Constructors:
Type { field: value }(whenSELECT_STRUCTis enabled) - Unary operators:
!expr,-expr
This function is called at the highest precedence level, meaning these expressions bind most tightly and are parsed first before any binary operators.
§String Literal Handling
String literals are parsed through [Literal::opt_parse], which:
- Recognizes
TokenKind::Literal(LiteralKind::String, text)tokens - Creates a
LiteralAST node with the raw tokenizer text - Wraps it in
AstExprKind::Literalfor the expression tree
Note: The current implementation has a bug where escape sequences are validated
but never interpreted - "hello\nworld" remains as literal \n characters.