import может быть пустой и его может вообще не быть

master
serr 2025-05-13 18:58:28 +03:00
parent 19307045b3
commit 39410a12a3
3 changed files with 9 additions and 3 deletions

View File

@ -76,7 +76,6 @@ math_expr:
| IDENTIFIER { printf("IDENTIFIER: %s\n", $1); } | IDENTIFIER { printf("IDENTIFIER: %s\n", $1); }
; ;
/* Остальные правила остаются без изменений */
int_types: int_types:
UINT { } UINT { }
| UINT8 { } | UINT8 { }
@ -112,7 +111,8 @@ package_declaration:
; ;
import_declaration: import_declaration:
IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } import { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } | IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } LPAREN RPAREN { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); }
| IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } import { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); }
| IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } LPAREN import_list RPAREN { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); } | IMPORT { printf("\033[1;36mHELLO, IMPORT BLOCK\n\033[0m"); } LPAREN import_list RPAREN { printf("\033[1;36mBY, IMPORT BLOCK\n\n\033[0m"); }
; ;
@ -126,6 +126,7 @@ import_list:
; ;
// //
// functions decl
arg_declaration: arg_declaration:
IDENTIFIER type IDENTIFIER type
{ printf("\033[1;35mARG: %s\n\033[0m", $1); } { printf("\033[1;35mARG: %s\n\033[0m", $1); }
@ -146,7 +147,9 @@ func_declaration:
LPAREN arg_list RPAREN return_type block LPAREN arg_list RPAREN return_type block
{ printf("\033[1;35mBY, FUNC: %s\n\n\033[0m", $2); } { printf("\033[1;35mBY, FUNC: %s\n\n\033[0m", $2); }
; ;
//
// vars decl
var_declaration: var_declaration:
IDENTIFIER SHORT_DECLARATION math_expr { printf("\033[1;33mSHORT DECL with math expr: %s\n\033[0m", $1); } IDENTIFIER SHORT_DECLARATION math_expr { printf("\033[1;33mSHORT DECL with math expr: %s\n\033[0m", $1); }
| IDENTIFIER SHORT_DECLARATION literal { printf("\033[1;33mSHORT DECL with literal: %s\n\033[0m", $1); } | IDENTIFIER SHORT_DECLARATION literal { printf("\033[1;33mSHORT DECL with literal: %s\n\033[0m", $1); }
@ -156,6 +159,7 @@ var_declaration:
; ;
%% %%
//
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc > 1) { if (argc > 1) {

View File

@ -17,7 +17,8 @@ func test(a int, b string) {
func main() { func main() {
var a int; var b int;
var a int = 2;
a = 2+2*2-(1+10); a = 2+2*2-(1+10);
a = a + 1; a = a + 1;
a = a; a = a;

View File

@ -1,3 +1,4 @@
package main;
func test_func(a string, b int, c uint16) int { func test_func(a string, b int, c uint16) int {
var x int = 42; var x int = 42;