CCParser
Creates a reusable Cosmic parser with its own token storage. Each parse replaces the previous tokenization.
Languages
Parse Cosmic source and expressions into Catalyst syntax trees.
#include <mc/CCParser.h>parse() and parseFile() handle translation units; parseExpr() handles a single expression. The result is an AST represented by cvar and cfunc.
Cosmic’s whitespace rules and language additions apply. A parser API is not a promise that arbitrary standard C++ formatting is accepted.
class CCParserCreates a reusable Cosmic parser with its own token storage. Each parse replaces the previous tokenization.
~CCParser();
void setFileId(uint16_t fileId);
Assigns the file identifier attached to parsed source locations.
void setLineComments(bool flag);
Enables reading numeric source-line annotations from comments such as // 42 instead of assigning ordinary parsed line metadata. Disabled by default; this controls source-location reconstruction rather than general comment preservation.
Parses a complete Cosmic source string into a cvar syntax tree without executing it. Malformed source throws CParseError.
Reads and parses a Cosmic 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.