X-Git-Url: https://git.bts.cx/sun.git/blobdiff_plain/dd54d29e3b6bb46b9c7233a14aa8e8db34340d87..b4bfa0d90e747a0f6f3080246823471423a30951:/runtime/src/sun/compiler/sun.y diff --git a/runtime/src/sun/compiler/sun.y b/runtime/src/sun/compiler/sun.y index 2464ffa..c6acef0 100644 --- a/runtime/src/sun/compiler/sun.y +++ b/runtime/src/sun/compiler/sun.y @@ -114,7 +114,7 @@ statements_or_definitions ;*/ function_definition - : IDENTIFIER IDENTIFIER '(' optional_parameter_definitions ')' '{' optional_statements '}' { + : type IDENTIFIER '(' optional_parameter_definitions ')' '{' optional_statements '}' { $$ = sltNodeMakeFunctionDefinition($1, $2, $4, $7); } ; @@ -136,7 +136,7 @@ parameter_definitions ; parameter_definition - : IDENTIFIER IDENTIFIER { + : type IDENTIFIER { $$ = sltNodeMakeFunctionParameterDefinition($1, $2); } ; @@ -163,14 +163,23 @@ type_member_definition ;*/ variable_definition - : IDENTIFIER IDENTIFIER { + : type IDENTIFIER { $$ = sltNodeMakeVariableDefinition($1, $2, NULL); } - | IDENTIFIER IDENTIFIER '=' expression { + | type IDENTIFIER '=' expression { $$ = sltNodeMakeVariableDefinition($1, $2, $4); } ; +type + : IDENTIFIER { + $$ = $1;//sltNodeMakeTypeDefinition($1, 1); + } + | '[' type ':' INT ']' { + $$ = $2;//sltNodeMakeTypeDefinition($1, $2); + } + ; + optional_statements : /* nothing */ { $$ = NULL; @@ -414,7 +423,7 @@ postfix_expression $$ = sltNodeMakeFunctionCall($1, $3); } | postfix_expression '.' IDENTIFIER { - $$ = sltNodeMakeTypeAccess($1, $3); + $$ = sltNodeMakeMemberAccess($1, $3); } /*| postfix_expression postfix_unary_operator { $$ = sltNodeMakeUnaryOperation($1, $2);