Parser for stela configuration language. More...
#include <stelaParser.hpp>
Public Member Functions | |
| tstr< stela > | parse (const std::string &codes) |
| Parses the given string of stela code. | |
| tstr< stela > | parse (const nchar *codes) |
| Parses the given C-style string of stela code. | |
| tstr< stela > | parseFromFile (const std::string &path) |
| Parses stela code from the specified file path. | |
| tstr< stela > | parseFromFile (const nchar *path) |
| Parses stela code from the specified C-style file path. | |
| stelaTokenDispatcher & | getDispatcher () |
| std::vector< ncnt > & | getIndents () |
| nbool | isInit () const |
| template<typename T > | |
| void | setScan () |
| Sets the scanning mode for the lexer. | |
| void | rel () |
| int | pushState (int newState) |
| Pushes a new Flex scanner state onto the state stack. | |
| int | popState () |
| Pops a Flex scanner state from the state stack. | |
| nint | onScan (stelaParser &ps, ZZSTYPE *val, ZZLTYPE *loc, zzscan_t scanner, nbool &isBypass) override |
| Handles scanning for the lexer, overriding the base stelaTokenScanable behavior. | |
| nint | onTokenEndOfFile () |
| Handles the end-of-file token. | |
| nint | onTokenColon (nint tok) |
| Handles the colon token. | |
| nint | onTokenNewLine (nint tok) |
| Handles the newline token. | |
| nint | onTokenComma (nint tok) |
| Handles the comma token. | |
| nint | onIndent (ncnt col, nint tok) |
| Handles an increase in indentation. | |
| nint | onDedent (ncnt col, nint tok) |
| Handles a decrease in indentation. | |
| nint | onIgnoreIndent (nint tok) |
| Handles ignoring indentation (e.g., for inline blocks). | |
| nchar | onScanUnexpected (const nchar *token) |
| Handles an unexpected token encountered during scanning. | |
| stela * | onDefBlock (stela *stmt) |
| stela * | onDefBlock (stela *blk, stela *stmt) |
| stela * | onDefBlock () |
| template<typename T > | |
| stela * | onPrimitive (const T &arg) |
| Creates a valStela object from a primitive value. | |
| verStela * | onVer (const std::string &version) |
| stela * | onDefProp (const std::string &name, stela &rhs) |
| stela * | onDefAssign (const std::string &name, stela *rhs) |
| stela * | onDefOrigin (const std::string &name, stela &blk) |
| stela * | onDefArray (const stela &elem) |
| stela * | onDefArray (stela &as, const stela &elem) |
| stela * | onCompilationUnit (stela *blk) |
| void | onParseErr (const std::string &msg, const nchar *symbolName) |
| Handles a parse error, reporting the message and the symbol where the error occurred. | |
| void | report (const std::string &msg) |
| Reports a message, typically an error or warning, encountered during parsing. | |
| nint | onScan (stelaParser &ps, ZZSTYPE *val, ZZLTYPE *loc, zzscan_t scanner) |
| Default entry point for token scanning. | |
| virtual nint | onScan (stelaParser &ps, ZZSTYPE *yylval, ZZLTYPE *loc, zzscan_t yyscanner, nbool &isBypass)=0 |
| Pure virtual method for concrete token scanning implementations. | |
Public Member Functions inherited from by::stelaTokenScanable | |
| nint | onScan (stelaParser &ps, ZZSTYPE *val, ZZLTYPE *loc, zzscan_t scanner) |
| Default entry point for token scanning. | |
Parser for stela configuration language.
Entry point for the Stela parsing component. Specify scripts through parse() or parseFromFile(), and the parsed result is returned in Stela structure.
Since the stela language itself is a specialized language of byeol, the parser is also based on the byeol language parser. Since it's a less complex language than byeol, it's recommended to examine this parser code before looking at the core module.
Uses flex and bison, with flex named lowscanner and bison named lowparser. These low-level scanner and parser exist only within the parser component and are never exposed externally. When stelaParser::parse() executes, it runs lowscanner. lowscanner tokenizes and passes tokens to lowparser. When lowparser matches rules on received tokens, it passes events back to stelaParser. Therefore, stelaParser's functions starting with on are event handling functions that define how to create nodes and build the AST.
Like the byeol language, stela applies the offside rule, making it very sensitive to indentation. Unlike typical languages, it must count whitespace after newlines. Once indentation is confirmed and determines which scope the code line belongs to, whitespace should be ignored afterward.
Handles a decrease in indentation.
| col | The column count of the new indentation level. |
| tok | The token ID that triggered the dedentation. |
Handles ignoring indentation (e.g., for inline blocks).
| tok | The token ID. |
Handles an increase in indentation.
| col | The column count of the new indentation level. |
| tok | The token ID that triggered the indentation. |
Handles a parse error, reporting the message and the symbol where the error occurred.
| msg | The error message. |
| symbolName | The name of the symbol causing the error. |
| nint by::stelaTokenScanable::onScan | ( | stelaParser & | ps, |
| ZZSTYPE * | val, | ||
| ZZLTYPE * | loc, | ||
| zzscan_t | scanner ) |
Default entry point for token scanning.
This non-virtual method acts as a wrapper that internally dispatches to the pure virtual onScan method, which must be implemented by concrete scanner strategies.
| ps | The stelaParser instance. |
| val | The YYSTYPE value pointer for the token. |
| loc | The YYLTYPE location pointer for the token. |
| scanner | The Flex scanner instance. |
|
overridevirtual |
Handles scanning for the lexer, overriding the base stelaTokenScanable behavior.
| ps | The stelaParser instance. |
| val | The YYSTYPE value pointer for the token. |
| loc | The YYLTYPE location pointer for the token. |
| scanner | The Flex scanner instance. |
| isBypass | Flag indicating if indentation bypass is active. |
Implements by::stelaTokenScanable.
|
virtual |
Pure virtual method for concrete token scanning implementations.
| ps | The stelaParser instance. |
| yylval | The YYSTYPE value pointer for the token. |
| loc | The YYLTYPE location pointer for the token. |
| yyscanner | The Flex scanner instance. |
| isBypass | Flag indicating if indentation bypass is active. |
Implements by::stelaTokenScanable.
Handles an unexpected token encountered during scanning.
| token | The unexpected token string. |
Handles the colon token.
| tok | The token ID of the colon. |
Handles the comma token.
| tok | The token ID of the comma. |
| nint by::stelaParser::onTokenEndOfFile | ( | ) |
Handles the end-of-file token.
Handles the newline token.
| tok | The token ID of the newline. |
Parses the given C-style string of stela code.
| codes | The stela code as a C-style string. |
Parses the given string of stela code.
| codes | The stela code as a string. |
Parses stela code from the specified C-style file path.
| path | The path to the file containing stela code. |
Parses stela code from the specified file path.
| path | The path to the file containing stela code. |
| int by::stelaParser::popState | ( | ) |
Pops a Flex scanner state from the state stack.
Pushes a new Flex scanner state onto the state stack.
| newState | The new state to push. |
Reports a message, typically an error or warning, encountered during parsing.
| msg | The message to report. |
Sets the scanning mode for the lexer.
| T | The type of the scanner strategy (e.g., normalScan, indentScan). |