spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::Parser Class Reference

Recursive-descent parser that produces an AST from a token stream. More...

#include <parser.h>

Public Member Functions

 Parser (Lexer lexer)
 Constructs a Parser that reads tokens from the given Lexer.
 
Program parse ()
 Parses the full program and returns the top-level AST node.
 
ExprPtr parseExpression ()
 Parses a single expression starting at the current token.
 
StmtPtr parseAsk ()
 Parses an ask statement.
 
StmtPtr parseLet ()
 Parses a let statement.
 
StmtPtr parseAssign ()
 Parses a bare assignment statement (name = expr).
 
StmtPtr parseMkdir ()
 Parses a mkdir statement.
 
StmtPtr parseFile ()
 Parses a file statement.
 
StmtPtr parseRepeat ()
 Parses a repeat block.
 
StmtPtr parseIf ()
 Parses an if block.
 
StmtPtr parseCopy ()
 Parses a copy statement.
 
StmtPtr parseInclude ()
 Parses an include statement.
 
StmtPtr parseRun ()
 Parses a run statement.
 
StmtPtr parseStatement ()
 Dispatches to the appropriate statement parser based on the current token.
 

Detailed Description

Recursive-descent parser that produces an AST from a token stream.

Construct with a Lexer over the source text, then call parse() to obtain a Program. Throws ParseError on any syntax violation.

Individual statement parsers (parseAsk(), parseLet(), etc.) are public so they can be exercised directly in unit tests.