Skip to content

Commit

Permalink
allow "&" instead of "out" in function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Oct 7, 2023
1 parent a3b5f04 commit eea573a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/common/scripting/frontend/zcc-parse.lemon
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,26 @@ func_param(X) ::= func_param_flags(A) type(B) IDENTIFIER(C) EQ expr(D).
X = parm;
}

func_param(X) ::= func_param_flags(A) type(B) AND IDENTIFIER(C).
{
NEW_AST_NODE(FuncParamDecl,parm,A.SourceLoc ? A.SourceLoc : B->SourceLoc);
parm->Type = B;
parm->Name = C.Name();
parm->Flags = A.Int | ZCC_Out;
parm->Default = nullptr;
X = parm;
}

func_param(X) ::= func_param_flags(A) type(B) AND IDENTIFIER(C) EQ expr(D).
{
NEW_AST_NODE(FuncParamDecl,parm,A.SourceLoc ? A.SourceLoc : B->SourceLoc);
parm->Type = B;
parm->Name = C.Name();
parm->Flags = A.Int | ZCC_Out;
parm->Default = D;
X = parm;
}

func_param_flags(X) ::= . { X.Int = 0; X.SourceLoc = 0; }
func_param_flags(X) ::= func_param_flags(A) IN(T). { X.Int = A.Int | ZCC_In; X.SourceLoc = T.SourceLoc; }
func_param_flags(X) ::= func_param_flags(A) OUT(T). { X.Int = A.Int | ZCC_Out; X.SourceLoc = T.SourceLoc; }
Expand Down

0 comments on commit eea573a

Please sign in to comment.