From b344635c8d8845eacc5093da26193af8c15d83b5 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 22 Apr 2021 21:16:37 -0700 Subject: [PATCH] new type declaration style --- wraith.y | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wraith.y b/wraith.y index ffc2fe0..2ae05aa 100644 --- a/wraith.y +++ b/wraith.y @@ -166,13 +166,13 @@ Expression : PrimaryExpression | BinaryExpression ; -VariableDeclaration : Type Identifier +VariableDeclaration : Identifier COLON Type { - $$ = MakeDeclarationNode($1, $2); + $$ = MakeDeclarationNode($3, $1); } - | Identifier Identifier + | Identifier COLON Identifier { - $$ = MakeDeclarationNode(MakeCustomTypeNode($1), $2); + $$ = MakeDeclarationNode(MakeCustomTypeNode($3), $1); } AssignmentStatement : VariableDeclaration EQUAL Expression @@ -265,24 +265,24 @@ Body : LEFT_BRACE Statements RIGHT_BRACE PopStackFrame(stack); } -FunctionSignature : Type Identifier LEFT_PAREN SignatureArguments RIGHT_PAREN +FunctionSignature : Identifier LEFT_PAREN SignatureArguments RIGHT_PAREN COLON Type { Node **declarations; uint32_t declarationCount; declarations = GetNodes(stack, &declarationCount); - $$ = MakeFunctionSignatureNode($2, $1, MakeFunctionSignatureArgumentsNode(declarations, declarationCount), MakeFunctionModifiersNode(NULL, 0)); + $$ = MakeFunctionSignatureNode($1, $6, MakeFunctionSignatureArgumentsNode(declarations, declarationCount), MakeFunctionModifiersNode(NULL, 0)); PopStackFrame(stack); } - | STATIC Type Identifier LEFT_PAREN SignatureArguments RIGHT_PAREN + | STATIC Identifier LEFT_PAREN SignatureArguments RIGHT_PAREN COLON Type { Node **declarations; uint32_t declarationCount; Node *modifier = MakeStaticNode(); declarations = GetNodes(stack, &declarationCount); - $$ = MakeFunctionSignatureNode($3, $2, MakeFunctionSignatureArgumentsNode(declarations, declarationCount), MakeFunctionModifiersNode(&modifier, 1)); + $$ = MakeFunctionSignatureNode($2, $7, MakeFunctionSignatureArgumentsNode(declarations, declarationCount), MakeFunctionModifiersNode(&modifier, 1)); PopStackFrame(stack); }