11#ifndef _METAC_PARSER_C_
22#define _METAC_PARSER_C_
33
4- #define TYPE_EXP
4+ // #define TYPE_EXP
55#include "metac_identifier_table.c"
66
77#include "../os/os.c"
@@ -665,7 +665,7 @@ metac_token_t* MetaCParser_PeekToken_(metac_parser_t* self, int32_t p, uint32_t
665665 {
666666 Debug_Logf (g_DebugServer , "Parser" ,"%s = MetaCParser_PeekToken(offset=%d, line=%d)" , MetaCTokenEnum_toChars (result -> TokenType ), p , line );
667667 }
668-
668+
669669 return result ;
670670}
671671
@@ -988,7 +988,11 @@ decl_type_t* MetaCParser_ParseTypeDecl(metac_parser_t* self, metac_decl_t* paren
988988 decl_type_array_t * typeArray = AllocNewDecl (decl_type_array , & result );
989989 if (!MetaCParser_PeekMatch (self , tok_rBracket , 1 ))
990990 {
991+ #ifdef OLD_PARSER
992+ typeArray -> Dim = MetaCParser_ParseExpr (self , expr_flags_none , 0 );
993+ #else
991994 typeArray -> Dim = MetaCParser_ParseExpr2 (self , expr_flags_none );
995+ #endif
992996 MetaCParser_Match (self , tok_rBracket );
993997 }
994998 else
@@ -1249,7 +1253,11 @@ decl_type_t* MetaCParser_ParseTypeDecl(metac_parser_t* self, metac_decl_t* paren
12491253 else
12501254 {
12511255 MetaCParser_Match (self , tok_assign );
1256+ #ifdef OLD_PARSER
1257+ member -> Value = MetaCParser_ParseExpr (self , expr_flags_enum , 0 );
1258+ #else
12521259 member -> Value = MetaCParser_ParseExpr2 (self , expr_flags_enum );
1260+ #endif
12531261 assert (member -> Value -> Hash != 0 );
12541262 hash = CRC32C_VALUE (hash , member -> Value -> Hash );
12551263 }
@@ -1943,7 +1951,11 @@ metac_decl_t* MetaCParser_ParseDecl(metac_parser_t* self, metac_decl_t* parent)
19431951 if (MetaCParser_PeekMatch (self , tok_assign , 1 ))
19441952 {
19451953 MetaCParser_Match (self , tok_assign );
1954+ #ifdef OLD_PARSER
1955+ varDecl -> VarInitExpr = MetaCParser_ParseExpr (self , expr_flags_none , 0 );
1956+ #else
19461957 varDecl -> VarInitExpr = MetaCParser_ParseExpr2 (self , expr_flags_none );
1958+ #endif
19471959 }
19481960 }
19491961 }
@@ -2059,7 +2071,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
20592071 }
20602072 MetaCParser_Match (self , tok_lParen );
20612073 if_stmt -> IfCond =
2074+ #ifdef OLD_PARSER
2075+ MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2076+ #else
20622077 MetaCParser_ParseExpr2 (self , expr_flags_none );
2078+ #endif
20632079 hash = CRC32C_VALUE (hash , if_stmt -> IfCond -> Hash );
20642080 MetaCParser_Match (self , tok_rParen );
20652081 if_stmt -> IfBody = MetaCParser_ParseStmt (self , (metac_stmt_t * )result , 0 );
@@ -2081,15 +2097,16 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
20812097 else if (tokenType == tok_at )
20822098 {
20832099 peek2 = MetaCParser_PeekToken (self , 2 );
2084- if (peek2 -> TokenType == tok_identifier && peek2 -> IdentifierKey == 0x3809a6 )
2100+ if (peek2 -> TokenType == tok_identifier && peek2 -> IdentifierKey == run_key )
20852101 {
20862102 stmt_run_t * run_stmt = AllocNewStmt (stmt_run , & result );
20872103 MetaCParser_Match (self , tok_at );
20882104 MetaCParser_Match (self , tok_identifier );
20892105 run_stmt -> RunBody =
20902106 MetaCParser_ParseStmt (self , cast (metac_stmt_t * )run_stmt , 0 );
2091- hash = 0x3809a6 ;
2107+ hash = run_key ;
20922108 hash = CRC32C_VALUE (hash , run_stmt -> Hash );
2109+ result -> Hash = hash ;
20932110 }
20942111 }
20952112 else if (tokenType == tok_kw_while )
@@ -2098,7 +2115,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
20982115 MetaCParser_Match (self , tok_kw_while );
20992116 MetaCParser_Match (self , tok_lParen );
21002117 while_stmt -> WhileExp =
2118+ #ifdef OLD_PARSER
2119+ MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2120+ #else
21012121 MetaCParser_ParseExpr2 (self , expr_flags_none );
2122+ #endif
21022123 hash = CRC32C_VALUE (hash , while_stmt -> WhileExp -> Hash );
21032124 MetaCParser_Match (self , tok_rParen );
21042125 while_stmt -> WhileBody =
@@ -2126,7 +2147,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
21262147 }
21272148 else
21282149 {
2150+ #ifdef OLD_PARSER
2151+ for_ -> ForInit = (metac_node_t )MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2152+ #else
21292153 for_ -> ForInit = (metac_node_t )MetaCParser_ParseExpr2 (self , expr_flags_none );
2154+ #endif
21302155 MetaCParser_Match (self , tok_semicolon );
21312156 }
21322157
@@ -2139,7 +2164,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
21392164 }
21402165 if (!MetaCParser_PeekMatch (self , tok_semicolon , 1 ))
21412166 {
2167+ #ifdef OLD_PARSER
2168+ for_ -> ForCond = MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2169+ #else
21422170 for_ -> ForCond = MetaCParser_ParseExpr2 (self , expr_flags_none );
2171+ #endif
21432172 hash = CRC32C_VALUE (hash , for_ -> ForCond -> Hash );
21442173 }
21452174 else
@@ -2150,7 +2179,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
21502179
21512180 if (!MetaCParser_PeekMatch (self , tok_rParen , 1 ))
21522181 {
2182+ #ifdef OLD_PARSER
2183+ for_ -> ForPostLoop = MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2184+ #else
21532185 for_ -> ForPostLoop = MetaCParser_ParseExpr2 (self , expr_flags_none );
2186+ #endif
21542187 hash = CRC32C_VALUE (hash , for_ -> ForPostLoop -> Hash );
21552188 }
21562189 else
@@ -2169,7 +2202,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
21692202 MetaCParser_Match (self , tok_kw_switch );
21702203 MetaCParser_Match (self , tok_lParen );
21712204 switch_ -> SwitchExp =
2205+ #ifdef OLD_PARSER
2206+ MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2207+ #else
21722208 MetaCParser_ParseExpr2 (self , expr_flags_none );
2209+ #endif
21732210 hash = CRC32C_VALUE (hash , switch_ -> SwitchExp -> Hash );
21742211 MetaCParser_Match (self , tok_rParen );
21752212 if (!MetaCParser_PeekMatch (self , tok_lBrace , 0 ))
@@ -2355,7 +2392,11 @@ metac_stmt_t* MetaCParser_ParseStmt(metac_parser_t* self,
23552392 if (!result || result == emptyPointer )
23562393LparseAsExpr :
23572394 {
2395+ #ifdef OLD_PARSER
2396+ metac_expr_t * exp = MetaCParser_ParseExpr (self , expr_flags_none , 0 );
2397+ #else
23582398 metac_expr_t * exp = MetaCParser_ParseExpr2 (self , expr_flags_none );
2399+ #endif
23592400 stmt_expr_t * expStmt = AllocNewStmt (stmt_expr , & result );
23602401 expStmt -> Expr = exp ;
23612402 result -> Hash = exp -> Hash ;
0 commit comments