CMParser
Creates a reusable Microcosm parser with its own token storage. Each parse replaces the previous tokenization.
Languages
Parse Microcosm source and expressions into Catalyst syntax trees.
#include <mc/CMParser.h>Parsing builds a cvar AST and does not execute it. Token information belongs to the parser and may change on the next parse.
class CMParserCreates a reusable Microcosm parser with its own token storage. Each parse replaces the previous tokenization.
~CMParser();
void setFileId(uint16_t fileId);
Assigns the file identifier attached to parsed source locations.
void discardComments(bool flag);
Controls whether comments are omitted from the syntax tree; the default is true. Set false to retain comment nodes for source tools; the interpreter treats those nodes as no-ops.
Parses a complete Microcosm source string into a cvar syntax tree without executing it. Malformed source throws CParseError.
Reads and parses a Microcosm source file, returning its syntax tree. File-loading errors and source-location parse errors are reported to the caller.
Parses one expression without executing it. Returns the expression’s cvar syntax tree and rejects additional statements.
Tokens& tokens();
Borrows the token list from the most recent parse for tasks such as syntax highlighting. A later parse replaces its contents; the parser must outlive the reference.
Formats source text using the language’s formatter.