From 67caf3303b7edbd9e8859a88b8d9d4fff74944e3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 23 Jul 2013 19:59:47 -0500 Subject: [PATCH] Add the array size to ZCC_VarName --- src/zscript/ast.cpp | 1 + src/zscript/zcc-parse.lemon | 4 +++- src/zscript/zcc_parser.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/zscript/ast.cpp b/src/zscript/ast.cpp index bc1afd312..7908a50c5 100644 --- a/src/zscript/ast.cpp +++ b/src/zscript/ast.cpp @@ -373,6 +373,7 @@ static void PrintVarName(FLispString &out, ZCC_TreeNode *node) ZCC_VarName *vnode = (ZCC_VarName *)node; out.Open("var-name"); out.AddName(vnode->Name); + PrintNodes(out, vnode->ArraySize); out.Close(); } diff --git a/src/zscript/zcc-parse.lemon b/src/zscript/zcc-parse.lemon index 92eb4d25e..c41b3671e 100644 --- a/src/zscript/zcc-parse.lemon +++ b/src/zscript/zcc-parse.lemon @@ -611,12 +611,14 @@ variable_name(X) ::= IDENTIFIER(A). { NEW_AST_NODE(VarName,var); var->Name = ENamedName(A.Int); + var->ArraySize = NULL; X = var; } -variable_name(X) ::= IDENTIFIER(A) array_size. +variable_name(X) ::= IDENTIFIER(A) array_size(B). { NEW_AST_NODE(VarName,var); var->Name = ENamedName(A.Int); + var->ArraySize = B; X = var; } diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 8d3f9bab9..a1f093482 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -307,6 +307,7 @@ struct ZCC_StateLine : ZCC_StatePart struct ZCC_VarName : ZCC_TreeNode { ENamedName Name; + ZCC_Expression *ArraySize; // NULL if not an array }; struct ZCC_Type : ZCC_TreeNode