|
| node * | getSubPod () |
| | Retrieves the root node of the parsed sub-pod.
|
| |
|
const node * | getSubPod () const BY_CONST_FUNC(getSubPod()) srcSupplies &getSrcSupplies() |
| |
|
const srcSupplies & | getSrcSupplies () const BY_CONST_FUNC(getSrcSupplies()) me &addSupply(const srcSupply &new 1) |
| |
|
me & | addSupply (const tucontainable< srcSupply > &new1) |
| |
|
me & | relSupplies () |
| |
|
tokenDispatcher & | getDispatcher () |
| |
|
std::vector< ncnt > & | getIndents () |
| |
|
nbool | isInit () const |
| |
| template<typename T > |
| void | setScan () |
| | Sets the scanning mode for the lexer.
|
| |
|
void | rel () override |
| |
| 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 (parser &ps, YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, nbool &isBypass) override |
| | Handles scanning for the lexer, overriding the base tokenScanable 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 | onTokenLParan (nint tok) |
| | Handles the left parenthesis token.
|
| |
| nint | onTokenRParan (nint tok) |
| | Handles the right parenthesis token.
|
| |
| nint | onTokenComma (nint tok) |
| | Handles the comma token.
|
| |
| nbool | onTokenEndOfBraces () |
| | Handles the end of a braces block (e.g., }).
|
| |
| void | onTokenStartOfStrTemplateBrace () |
| | Handles the start of a string template brace (e.g., ${).
|
| |
| void | onTokenBeginStr (nchar token) |
| | Handles the start of a string literal.
|
| |
| nchar | getOpenStrToken () |
| | returns quote character which used to start current string sequence.
|
| |
| 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.
|
| |
| void | onSrcArea (const area &area) |
| | Callback for processing source area information from the lexer.
|
| |
|
node * | onGet (const std::string &name) |
| |
|
node * | onGet (const std::string &name, const narr &args) |
| |
|
node * | onGet (node &from, const std::string &name) |
| |
|
node * | onGet (node &from, node &it) |
| |
|
node * | onGet (const std::string &name, const std::string &name2) |
| |
|
node * | onCallAccess (node &it, const narr &args) |
| |
|
FBOExpr * | onUnaryMinus (const node &it) |
| |
|
FBOExpr * | onUnaryNot (const node &it) |
| |
|
FUOExpr * | onUnaryBitwiseNot (const node &it) |
| |
|
node * | onUnaryDoublePlus (node &it) |
| |
|
node * | onUnaryDoubleMinus (node &it) |
| |
|
FUOExpr * | onUnaryPostfixDoublePlus (const node &it) |
| |
|
FUOExpr * | onUnaryPostfixDoubleMinus (const node &it) |
| |
|
FBOExpr * | onAdd (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onSub (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onMul (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onDiv (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onMod (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onBitwiseAnd (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onBitwiseXor (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onBitwiseOr (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onLShift (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onRShift (const node &lhs, const node &rhs) |
| |
|
node * | onAssign (node &lhs, node &rhs) |
| |
|
node * | onAddAssign (node &lhs, node &rhs) |
| |
|
node * | onSubAssign (node &lhs, node &rhs) |
| |
|
node * | onMulAssign (node &lhs, node &rhs) |
| |
|
node * | onDivAssign (node &lhs, node &rhs) |
| |
|
node * | onModAssign (node &lhs, node &rhs) |
| |
|
FBOExpr * | onGt (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onGe (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onLt (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onLe (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onEq (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onNe (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onAnd (const node &lhs, const node &rhs) |
| |
|
FBOExpr * | onOr (const node &lhs, const node &rhs) |
| |
|
node * | onGetGeneric (const std::string &orgName, const args &typeParams) |
| |
|
node * | onGetElem (const node &arr, const node &idx) |
| |
|
node * | onGetArray (node &elemType) |
| |
|
obj * | onPod (const node &path) |
| |
|
obj * | onPod (const std::string &path) |
| |
|
obj * | onPod () |
| |
|
obj * | onSubPod (obj &subpod) |
| |
|
endExpr * | onEnd (const blockExpr &blk) |
| |
|
blockExpr * | onBlock (const node *stmt) |
| |
|
blockExpr * | onBlock (blockExpr *blk, const node *stmt) |
| |
|
blockExpr * | onBlock () |
| |
|
defBlock * | onDefBlock (node *stmt) |
| |
|
defBlock * | onDefBlock (defBlock *blk, node *stmt) |
| |
|
defBlock * | onDefBlock () |
| |
|
node * | onFor (const std::string &iterName, const node &expr, const blockExpr &blk) |
| |
|
node * | onWhile (const node &condition, const blockExpr &blk) |
| |
|
node * | onParanthesisAsTuple (narr &tuple) |
| |
|
args * | onTuple () |
| |
|
args * | onTuple (const node &elem) |
| |
|
args * | onTuple (args &as, const node &elem) |
| |
|
args * | onFuncCallTuple () |
| |
|
args * | onFuncCallTuple (const node &elem) |
| |
|
args * | onFuncCallTuple (args &as, const node &elem) |
| |
|
args * | onTypeNames (const node ¶m) |
| |
|
args * | onTypeNames (args ¶ms, const node ¶m) |
| |
|
template<typename T , typename Arg > |
| T * | onPrimitive (const Arg &arg) |
| |
|
template<typename T > |
| T * | onPrimitive () |
| |
|
node * | onDefProp (const modifier &mod, const std::string &name, const node &rhs) |
| |
|
node * | onDefProp (const std::string &name, const node &rhs) |
| |
|
node * | onDefProp (const node &rhs) |
| |
|
node * | onDefProp (const modifier &mod, const node &rhs) |
| |
|
node * | onDefAssign (const modifier &mod, const std::string &name, const node *rhs) |
| |
|
node * | onDefAssign (const defPropExpr *prop, const node *rhs) |
| |
|
node * | onDefAssign (const std::string &name, const node *rhs) |
| |
|
obj * | onDefOrigin (const std::string &name, defBlock &blk) |
| |
|
obj * | onDefOrigin (const std::string &name, const narr &args, defBlock &blk) |
| |
|
genericOrigin * | onDefObjGeneric (const std::string &name, const args &typeParams, defBlock &blk) |
| |
|
genericOrigin * | onDefObjGeneric (const std::string &name, const args &typeParams, const narr &args, defBlock &blk) |
| |
|
node * | onDefArray (const narr &items) |
| |
|
node * | onDefSeq (const node &start, const node &end) |
| |
|
void | onCompilationUnit (obj *subpod) |
| |
|
void | onCompilationUnit (obj *subpod, defBlock *blk) |
| |
|
func * | onFuncSignature (const modifier &mod, const getExpr &access, const node *retType) |
| |
|
func * | onFuncSignature (const getExpr &access, const node *retType) |
| |
|
func * | onFuncSignature (const modifier &mod, node &it, const node *retType) |
| |
|
func * | onFuncSignature (node &it, const node *retType) |
| |
|
func * | onAbstractFunc (func &f) |
| |
|
node * | onFunc (func &func, const blockExpr &blk) |
| |
|
defNestedFuncExpr * | onLambda (const narr ¶ms, const node &retType, const blockExpr &blk) |
| |
|
ctor * | onCtor (const modifier &mod, const narr &args, const blockExpr &blk) |
| |
|
ctor * | onCtor (const narr &args, const blockExpr &blk) |
| |
|
ctor * | onCtor (const modifier &mod, const blockExpr &blk) |
| |
|
ctor * | onCtor (const blockExpr &blk) |
| |
|
narr * | onParams () |
| |
|
narr * | onParams (const defPropExpr *elem) |
| |
|
narr * | onParams (narr &it, const defPropExpr *elem) |
| |
|
modifier * | onModifier (nbool isPublic, nbool isOverriden) |
| |
|
node * | onDeclStmt (const narr &dotnames) |
| |
|
retExpr * | onRet () |
| |
|
retExpr * | onRet (node &exp) |
| |
|
breakExpr * | onBreak () |
| |
|
nextExpr * | onNext () |
| |
|
evalExpr * | onFillFromOfFuncCall (const node &me, evalExpr &to) |
| |
|
evalExpr * | onEvalExpr (node &type, const narr &a) |
| |
|
evalExpr * | onEvalExpr (node &type, const args &a) |
| |
|
isExpr * | onIs (const node &me, const node &to) |
| |
|
asExpr * | onAs (const node &me, const node &as) |
| |
|
ifExpr * | onIf (const node &condition, const blockExpr &then) |
| |
|
ifExpr * | onIf (const node &condition, const blockExpr &then, const blockExpr &elseBlk) |
| |
|
ifExpr * | onIf (const node &condition, const blockExpr &then, const ifExpr &elseIf) |
| |
|
evalExpr * | onIn (const node &it, const node &container) |
| |
| void | onEndFunc () |
| | Callback invoked at the end of parsing a function definition.
|
| |
| void | onParseErr (const std::string &msg, const nchar *symbolName) |
| | Reports a parsing error.
|
| |
| nint | onScan (parser &ps, YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner) |
| | Default entry point for token scanning.
|
| |
| virtual nint | onScan (parser &ps, YYSTYPE *yylval, YYLTYPE *loc, yyscan_t yyscanner, nbool &isBypass)=0 |
| | Pure virtual method for concrete token scanning implementations.
|
| |
|
| tworker (const errReport &rpt) |
| |
|
errReport & | getReport () |
| |
|
const errReport & | getReport () const BY_CONST_FUNC(getReport()) me &setReport(errReport &rpt) |
| |
|
me & | setFlag (nint newFlag) |
| |
|
me & | addFlag (nint flag) |
| |
|
me & | delFlag (nint clear) |
| |
|
nbool | isFlag (nint flag) const |
| |
|
nint | getFlag () const |
| |
|
me & | setTask (const pod &root) |
| |
|
me & | setTask (const pod *it) BY_SIDE_FUNC(it |
| |
|
pod * | getTask () |
| |
|
const pod * | getTask () const BY_CONST_FUNC(getTask()) virtual void rel() |
| |
|
str | work () |
| |
|
const area & | getArea () const BY_CONST_FUNC(_getArea()) nbool isOk() const |
| |
|
nbool | operator== (const me &rhs) const |
| |
|
nbool | operator!= (const me &rhs) const |
| |
|
virtual const type & | getType () const =0 |
| |
|
nbool | isSub (const type &it) const |
| |
|
nbool | isSub (const type *it) const BY_SIDE_FUNC(isSub) |
| |
|
nbool | isSub (const me &it) const |
| |
|
nbool | isSub (const me *it) const BY_SIDE_FUNC(isSub) |
| |
|
nbool | isSuper (const type &it) const |
| |
|
nbool | isSuper (const type *it) const BY_SIDE_FUNC(isSuper) |
| |
|
nbool | isSuper (const me &it) const |
| |
|
nbool | isSuper (const me *it) const BY_SIDE_FUNC(isSuper) |
| |
|
template<typename T > |
| nint | isSub () const |
| |
|
template<typename T > |
| nint | isSuper () const |
| |
|
template<typename T > |
| T * | cast () |
| |
| template<typename T > |
| const T * | cast () const BY_CONST_FUNC(cast< T >()) virtual void *cast(const type &to) |
| | Safe cast to target type using type hierarchy information
|
| |
|
const void * | cast (const type &to) const BY_CONST_FUNC(cast(to)) void *cast(const type *it) BY_SIDE_FUNC(cast) |
| |
|
virtual me * | clone () const =0 |
| |
|
virtual me * | cloneDeep () const |
| |
|
virtual void | onCloneDeep (const me &from) |
| |
| nint | onScan (parser &ps, YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner) |
| | Default entry point for token scanning.
|
| |
Parser for byeol language source code
Entry point for the byeol parsing component, inheriting from worker. work() returns the parsed result as pod.
Similar Structure to Stela Parser
Since the stela language itself is part of the byeol language, its parser is also based on the byeol language parser. The stela parser is less complex compared to the byeol parser, so it's recommended to examine the stela parser code first before looking at the core module.
Scanner - Bison - Parser Structure
Uses flex and bison, naming flex as lowscanner and bison as lowparser. These low-level scanner and parser only exist inside the parser component and are not exposed externally. When parser::work() executes, it runs lowscanner, which tokenizes and passes tokens to lowparser. Lowparser matches rules and passes those events back to parser. Therefore, parser's functions starting with on are event handling functions that define how to create nodes and construct the AST.
lowparser.y Lifecycle Management
In each rule, calling parser::onXXXX() functions often creates new objects on the heap using the new keyword (not all functions do this). If these arguments are placed directly into tbicontainer, that's fine, but otherwise they must be bound with tstr beforehand to avoid memory leaks.
}
PS.onCompilationUnit(
pak.get());
}
Weak reference smart pointer with type-safe access
Definition tweak.hpp:16
This applies not only to onXXXX() functions but also to string tokens. See the following code:
if(!yylval->asStr) yylval->asStr = new std::string(); // Creates string object with new
....
return STRVAL;
}
// -- lowparser.y
...
| STRVAL { // When STRVAL comes from scanner
$$ = PS.onPrimitive<nStr>(*$1); // Pass it first. String is always immutable in this project
// so the object is always copied.
delete $1; // Since the object is copied, delete the original object.
Indentation rule
The byeol language applies the offside rule, making it very sensitive to indentation. Unlike typical languages, it must be able to count how many spaces exist immediately after a newline. Once indentation is determined and the code line's scope is confirmed, subsequent spaces should be ignored. Consider the following byeol language example:
Deferred execution utility similar to defer keyword in other languages
Definition end.hpp:36
Function definition in byeol language
Definition func.hpp:38
After parsing print("0 < val < 5"), when parsing the next line print("end of func"), the parser must count the leading spaces and compare with the space counts for each scope to determine which scope this code line belongs to. Looking at the example, we can intuitively see that print("end of func") has the same spacing as if val > 0, meaning it belongs directly inside the foo() body. This means at this point, both the scope inside if val > 0 and the scope inside if val < 5 are closed. So lowscanner must add 2 DEDENT tokens (signifying scope termination) before lowparser recognizes print("end of func").
tokenDispatcher
Flex uses a separately designated stream called yyin to get characters and define them as tokens. As shown in the example above, adding tokens during parsing means adding specific characters to this stream. Typically unput is used for this, but to flexibly handle multiple unputs or pushing to the front, lowscanner internally uses tokenDispatcher.
tokenScan
As explained earlier, detecting indentation is crucial. Accurate space counting is required, so a strategy pattern is applied, switching between normalScan and indentScan. When a newline is detected, it switches to indentScan to count spaces accurately and determine scope.