func calls added

master2
serr 2025-05-18 17:19:38 +03:00
parent 6b921474dd
commit 3fbd10ea34
2 changed files with 15 additions and 1 deletions

View File

@ -59,6 +59,8 @@ program:
statement:
| func_call SEMICOLON
{ printf("\033[1;33mSTATEMENT: func_call\033[0m\n"); }
| var_declaration SEMICOLON
{ printf("\033[1;33mSTATEMENT: variable declaration\033[0m\n"); }
| var_multiple_short_declaration SEMICOLON
@ -95,6 +97,9 @@ math_expr_or_literals_list:
| math_expr { }
| math_expr_or_literals_list COMMA math_expr
math_expr_or_literals_list_or_empty:
| math_expr_or_literals_list
//
// condition
@ -279,7 +284,11 @@ import_list:
;
//
// functions decl
// functions
func_call:
IDENTIFIER LPAREN math_expr_or_literals_list_or_empty RPAREN
arg_declaration:
IDENTIFIER type
{ printf("\033[1;35mARG: %s\n\033[0m", $1); }

View File

@ -1,10 +1,12 @@
package main;
func test() {
a := 1; // декларация одной переменной (число)
a := "test"; // декларация одной переменной (строка)
a, b := 1, 2; // декларация нескольких переменных (целые литералы)
a, b := b, a; // swap
a, b := "hello", "sailor"; // декларация нескольких переменных (строковые литералы)
a, b, c, d := "hello", 2, 3.123, true; // декларация нескольких переменных (всякое)
@ -12,5 +14,8 @@ func test() {
for k, l := 0, 10; k < l; k, l = k+1, l-1 {
}
}
func main() {
test();
}