diff --git a/src/zscript/ast.cpp b/src/zscript/ast.cpp index 1cd25e561..497ac7479 100644 --- a/src/zscript/ast.cpp +++ b/src/zscript/ast.cpp @@ -537,6 +537,10 @@ static void PrintExprConstant(FLispString &out, ZCC_TreeNode *node) { out.AddFloat(enode->DoubleVal); } + else if (enode->Type == TypeName) + { + out.AddName(ENamedName(enode->IntVal)); + } else if (enode->Type->IsKindOf(RUNTIME_CLASS(PInt))) { out.AddInt(enode->IntVal, static_cast(enode->Type)->Unsigned); diff --git a/src/zscript/zcc-parse.lemon b/src/zscript/zcc-parse.lemon index cbdea0f4f..2e192cf36 100644 --- a/src/zscript/zcc-parse.lemon +++ b/src/zscript/zcc-parse.lemon @@ -1141,6 +1141,14 @@ constant(X) ::= FLOATCONST(A). floatconst->DoubleVal = A.Float; X = floatconst; } +constant(X) ::= NAMECONST(A). +{ + NEW_AST_NODE(ExprConstant, floatconst, A); + floatconst->Operation = PEX_ConstValue; + floatconst->Type = TypeName; + floatconst->IntVal = A.Int; + X = floatconst; +} /************ Statements ************/ diff --git a/src/zscript/zcc_parser.cpp b/src/zscript/zcc_parser.cpp index a178cb980..766f28c2a 100644 --- a/src/zscript/zcc_parser.cpp +++ b/src/zscript/zcc_parser.cpp @@ -139,6 +139,7 @@ static void InitTokenMap() TOKENDEF (TK_Identifier, ZCC_IDENTIFIER); TOKENDEF (TK_StringConst, ZCC_STRCONST); + TOKENDEF (TK_NameConst, ZCC_NAMECONST); TOKENDEF (TK_IntConst, ZCC_INTCONST); TOKENDEF (TK_UIntConst, ZCC_UINTCONST); TOKENDEF (TK_FloatConst, ZCC_FLOATCONST); @@ -193,6 +194,11 @@ static void DoParse(const char *filename) value.String = state.Strings.Alloc(sc.String, sc.StringLen); tokentype = ZCC_STRCONST; } + else if (sc.TokenType == TK_NameConst) + { + value.Int = sc.Name; + tokentype = ZCC_NAMECONST; + } else if (sc.TokenType == TK_IntConst) { value.Int = sc.Number;