Merge branch 'main' into parser-dev
Signed-off-by: erick-alcachofa <erick@artichoke.dev>
This commit is contained in:
commit
e2fa44738f
@ -28,6 +28,7 @@ namespace arti::lang::ast {
|
||||
return std::make_unique<typename Node::element_type>();
|
||||
}
|
||||
|
||||
std::string toString(const AST &tree, std::size_t padding = 0);
|
||||
std::string toDot(const AST &tree);
|
||||
std::string toString(const AST &tree, std::string prefix = "");
|
||||
|
||||
} // namespace arti::lang::ast
|
||||
|
||||
@ -111,6 +111,6 @@ namespace arti::lang {
|
||||
};
|
||||
|
||||
std::string toString(const Token &value);
|
||||
std::string toString(const TokenV &value);
|
||||
std::string_view toString(const TokenV &value);
|
||||
|
||||
} // namespace arti::lang
|
||||
|
||||
1048
lib/src/Parser/AST/toDot.cpp
Normal file
1048
lib/src/Parser/AST/toDot.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1508
lib/src/Parser/AST/toString.cpp
Normal file
1508
lib/src/Parser/AST/toString.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,109 +7,109 @@ namespace arti::lang {
|
||||
std::string toString(const Token &value) {
|
||||
using enum TokenV;
|
||||
|
||||
std::string tokenStr = toString(value.value);
|
||||
std::string tokenStr{ toString(value.value) };
|
||||
|
||||
if (value.value == tkEOF) {
|
||||
return std::format("Token{{ {} }}", tokenStr);
|
||||
return "EOF";
|
||||
}
|
||||
|
||||
return std::format("Token{{ {}, {} }}", tokenStr, value.strValue);
|
||||
return std::format("{}", value.strValue);
|
||||
}
|
||||
|
||||
std::string toString(const TokenV &value) {
|
||||
std::string_view toString(const TokenV &value) {
|
||||
using enum TokenV;
|
||||
|
||||
switch (value) {
|
||||
case tkEOF: return "tkEOF";
|
||||
case tkString: return "tkString";
|
||||
case tkDecimal: return "tkDecimal";
|
||||
case tkInteger: return "tkInteger";
|
||||
case tkCharacter: return "tkCharacter";
|
||||
case tkIdentifier: return "tkIdentifier";
|
||||
case opDot: return "opDot";
|
||||
case opMod: return "opMod";
|
||||
case opPlus: return "opPlus";
|
||||
case opHyphen: return "opHyphen";
|
||||
case opSlash: return "opSlash";
|
||||
case opBang: return "opBang";
|
||||
case opStar: return "opStar";
|
||||
case opColon: return "opColon";
|
||||
case opComma: return "opComma";
|
||||
case opAssign: return "opAssign";
|
||||
case opAccess: return "opAccess";
|
||||
case opSemicolon: return "opSemicolon";
|
||||
case opCaret: return "opCaret";
|
||||
case opTilde: return "opTilde";
|
||||
case opEq: return "opEq";
|
||||
case opNeq: return "opNeq";
|
||||
case opLt: return "opLt";
|
||||
case opGt: return "opGt";
|
||||
case opLtEq: return "opLtEq";
|
||||
case opGtEq: return "opGtEq";
|
||||
case opLShift: return "opLShift";
|
||||
case opRShift: return "opRShift";
|
||||
case opBoolAnd: return "opBoolAnd";
|
||||
case opBoolOr: return "opBoolOr";
|
||||
case opAnd: return "opAnd";
|
||||
case opOr: return "opOr";
|
||||
case opLParen: return "opLParen";
|
||||
case opRParen: return "opRParen";
|
||||
case opLBracket: return "opLBracket";
|
||||
case opRBracket: return "opRBracket";
|
||||
case opLSquirly: return "opLSquirly";
|
||||
case opRSquirly: return "opRSquirly";
|
||||
case opArrow: return "opArrow";
|
||||
case opPlusAssign: return "opPlusAssign";
|
||||
case opHyphenAssign: return "opHyphenAssign";
|
||||
case opStarAssign: return "opStarAssign";
|
||||
case opSlashAssign: return "opSlashAssign";
|
||||
case opModAssign: return "opModAssign";
|
||||
case opAndAssign: return "opAndAssign";
|
||||
case opOrAssign: return "opOrAssign";
|
||||
case opLShiftAssign: return "opLShiftAssign";
|
||||
case opRShiftAssign: return "opRShiftAssign";
|
||||
case opBoolAndAssign: return "opBoolAndAssign";
|
||||
case opBoolOrAssign: return "opBoolORAssign";
|
||||
case opMut: return "opMut";
|
||||
case opOpt: return "opOpt";
|
||||
case opSliceSize: return "opSliceSize";
|
||||
case opPtrSlice: return "opPtrSlice";
|
||||
case opSlicePtr: return "opSlicePtr";
|
||||
case opReflect: return "opReflect";
|
||||
case opLabel: return "opLabel";
|
||||
case kwUnderscore: return "kwUnderscore";
|
||||
case kwOr: return "kwOr";
|
||||
case kwNot: return "kwNot";
|
||||
case kwAnd: return "kwAnd";
|
||||
case kwIf: return "kwIf";
|
||||
case kwElse: return "kwElse";
|
||||
case kwFn: return "kwFn";
|
||||
case kwEnum: return "kwEnum";
|
||||
case kwStruct: return "kwStruct";
|
||||
case kwDef: return "kwDef";
|
||||
case kwLet: return "kwLet";
|
||||
case kwFor: return "kwFor";
|
||||
case kwLoop: return "kwLoop";
|
||||
case kwBreak: return "kwBreak";
|
||||
case kwContinue: return "kwContinue";
|
||||
case kwDo: return "kwDo";
|
||||
case kwWhile: return "kwWhile";
|
||||
case kwMatch: return "kwMatch";
|
||||
case kwSwitch: return "kwSwitch";
|
||||
case kwReturn: return "kwReturn";
|
||||
case kwUnreachable: return "kwUnreachable";
|
||||
case kwTypename: return "kwTypename";
|
||||
case kwDefer: return "kwDefer";
|
||||
case kwErrDefer: return "kwErrDefer";
|
||||
case kwTrue: return "kwTrue";
|
||||
case kwFalse: return "kwFalse";
|
||||
case kwNull: return "kwNull";
|
||||
case kwThis: return "kwThis";
|
||||
case kwImport: return "kwImport";
|
||||
case kwExport: return "kwExport";
|
||||
case kwModule: return "kwModule";
|
||||
case kwUsing: return "kwUsing";
|
||||
default: return "<Undefined>";
|
||||
case tkEOF: return "EOF";
|
||||
case tkString: return "string";
|
||||
case tkDecimal: return "number";
|
||||
case tkInteger: return "integer";
|
||||
case tkCharacter: return "character";
|
||||
case tkIdentifier: return "identifier";
|
||||
case opDot: return "'.'";
|
||||
case opMod: return "'%'";
|
||||
case opPlus: return "'+'";
|
||||
case opHyphen: return "'-'";
|
||||
case opSlash: return "'/'";
|
||||
case opBang: return "'!'";
|
||||
case opStar: return "'*'";
|
||||
case opColon: return "':'";
|
||||
case opComma: return "','";
|
||||
case opAssign: return "'='";
|
||||
case opAccess: return "'::'";
|
||||
case opSemicolon: return "';'";
|
||||
case opCaret: return "'^'";
|
||||
case opTilde: return "'~'";
|
||||
case opEq: return "'=='";
|
||||
case opNeq: return "'!='";
|
||||
case opLt: return "'<'";
|
||||
case opGt: return "'>'";
|
||||
case opLtEq: return "'<='";
|
||||
case opGtEq: return "'>='";
|
||||
case opLShift: return "'<<'";
|
||||
case opRShift: return "'>>'";
|
||||
case opBoolAnd: return "'&&'";
|
||||
case opBoolOr: return "'||'";
|
||||
case opAnd: return "'&'";
|
||||
case opOr: return "'|'";
|
||||
case opLParen: return "'('";
|
||||
case opRParen: return "')'";
|
||||
case opLBracket: return "'['";
|
||||
case opRBracket: return "']'";
|
||||
case opLSquirly: return "'{'";
|
||||
case opRSquirly: return "'}'";
|
||||
case opArrow: return "'->'";
|
||||
case opPlusAssign: return "'+='";
|
||||
case opHyphenAssign: return "'-='";
|
||||
case opStarAssign: return "'*='";
|
||||
case opSlashAssign: return "'/='";
|
||||
case opModAssign: return "'%='";
|
||||
case opAndAssign: return "'&='";
|
||||
case opOrAssign: return "'|='";
|
||||
case opLShiftAssign: return "'<<='";
|
||||
case opRShiftAssign: return "'>>='";
|
||||
case opBoolAndAssign: return "'&&='";
|
||||
case opBoolOrAssign: return "'||='";
|
||||
case opMut: return "'$'";
|
||||
case opOpt: return "'?'";
|
||||
case opSliceSize: return "'.#'";
|
||||
case opPtrSlice: return "'.['";
|
||||
case opSlicePtr: return "'.*'";
|
||||
case opReflect: return "'.@'";
|
||||
case opLabel: return "':='";
|
||||
case kwUnderscore: return "'underscore'";
|
||||
case kwOr: return "'or'";
|
||||
case kwNot: return "'not'";
|
||||
case kwAnd: return "'and'";
|
||||
case kwIf: return "'if'";
|
||||
case kwElse: return "'else'";
|
||||
case kwFn: return "'fn'";
|
||||
case kwEnum: return "'enum'";
|
||||
case kwStruct: return "'struct'";
|
||||
case kwDef: return "'def'";
|
||||
case kwLet: return "'let'";
|
||||
case kwFor: return "'for'";
|
||||
case kwLoop: return "'loop'";
|
||||
case kwBreak: return "'break'";
|
||||
case kwContinue: return "'continue'";
|
||||
case kwDo: return "'do'";
|
||||
case kwWhile: return "'while'";
|
||||
case kwMatch: return "'match'";
|
||||
case kwSwitch: return "'switch'";
|
||||
case kwReturn: return "'return'";
|
||||
case kwUnreachable: return "'unreachable'";
|
||||
case kwTypename: return "'typename'";
|
||||
case kwDefer: return "'defer'";
|
||||
case kwErrDefer: return "'errdefer'";
|
||||
case kwTrue: return "'true'";
|
||||
case kwFalse: return "'false'";
|
||||
case kwNull: return "'null'";
|
||||
case kwThis: return "'this'";
|
||||
case kwImport: return "'import'";
|
||||
case kwExport: return "'export'";
|
||||
case kwModule: return "'module'";
|
||||
case kwUsing: return "'using'";
|
||||
default: return "<undefined>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user