добавил возможность опрделения типов
parent
cfdd475fc1
commit
51a96ccd5f
|
@ -72,6 +72,7 @@ LETTER_OR_DIGIT [a-zA-Z0-9_]
|
|||
"++" { return INC; }
|
||||
"--" { return DEC; }
|
||||
|
||||
"type" { return TYPE; }
|
||||
"go" { return GO; }
|
||||
"defer" { return DEFER; }
|
||||
"range" { return RANGE; }
|
||||
|
|
|
@ -25,7 +25,7 @@ void free_node(char *str) {
|
|||
%token VAR FUNC RETURN STRING_LITERAL FLOAT_LITERAL COMPLEX_LITERAL NUMBER PACKAGE IMPORT
|
||||
%token INC DEC PLUS_EQ MINUS_EQ MUL_EQ DIV_EQ MOD_EQ
|
||||
%token AMPERSAND_EQ PIPE_EQ XOR_EQ LSHIFT_EQ RSHIFT_EQ AND_NOT_EQ
|
||||
%token FOR BREAK CONTINUE ARROW IF ELSE RANGE DEFER GO
|
||||
%token FOR BREAK CONTINUE ARROW IF ELSE RANGE DEFER GO TYPE
|
||||
%token CHAN CONST CASE SWITCH
|
||||
%token PLUS MINUS MULT DIV MOD
|
||||
%token STRING
|
||||
|
@ -68,6 +68,8 @@ statement:
|
|||
{ printf("\033[1;33mSTATEMENT: variable multiple declaration\033[0m\n"); }
|
||||
| func_declaration
|
||||
{ printf("\033[1;33mSTATEMENT: function declaration\033[0m\n"); }
|
||||
| type_delcaration SEMICOLON
|
||||
{ printf("\033[1;33mSTATEMENT: type declaration\033[0m\n"); }
|
||||
| cicle
|
||||
{ printf("\033[1;33mSTATEMENT: cicle\033[0m\n"); }
|
||||
| condition
|
||||
|
@ -93,7 +95,7 @@ statements_list:
|
|||
;
|
||||
|
||||
identifiers_list:
|
||||
IDENTIFIER { }
|
||||
| IDENTIFIER { }
|
||||
| identifiers_list COMMA IDENTIFIER { }
|
||||
|
||||
math_expr_or_literals_list:
|
||||
|
@ -278,7 +280,7 @@ string_types:
|
|||
;
|
||||
|
||||
func_types:
|
||||
FUNC LPAREN RPAREN return_type
|
||||
FUNC LPAREN arg_list RPAREN return_type
|
||||
|
||||
type:
|
||||
int_types { }
|
||||
|
@ -372,6 +374,10 @@ var_declaration:
|
|||
| VAR IDENTIFIER type ASSIGN literal { { printf("\033[1;33mVAR DECL with literal init value: %s\n\033[0m", $2); } }
|
||||
;
|
||||
|
||||
// type decl
|
||||
type_delcaration:
|
||||
TYPE IDENTIFIER type { { printf("\033[1;33mTYPE DECL\n\033[0m"); } }
|
||||
|
||||
%%
|
||||
//
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ import (
|
|||
"log"
|
||||
)
|
||||
|
||||
func test(int, int) {
|
||||
|
||||
}
|
||||
|
||||
func ujas() (func() func() func() int, int, string) {
|
||||
return func() func() func() int {
|
||||
return func() func() int {
|
||||
|
|
|
@ -10,18 +10,20 @@ func server(a int) {
|
|||
|
||||
func iife(work int) {
|
||||
|
||||
func(){}();
|
||||
func(){fmt.Println(123);}();
|
||||
for i := 1; i < 3; i++ {
|
||||
func(){}();
|
||||
func(){fmt.Println(123);}();
|
||||
|
||||
go func(a, b string) {
|
||||
fmt.Println("Message:", a + b);
|
||||
}("Hello", ", world!");
|
||||
go func(a, b string) {
|
||||
fmt.Println("Message:", a + b);
|
||||
}("Hello", ", world!");
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
go log.Println("work failed:", err);
|
||||
}
|
||||
}();
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
go log.Println("work failed:", err);
|
||||
}
|
||||
}();
|
||||
}
|
||||
}
|
||||
|
||||
func ujas() (func() func() func() int, int, string) {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package main;
|
||||
import "fmt";
|
||||
|
||||
type mile uint;
|
||||
type BinaryOp func(int, int) int;
|
Loading…
Reference in New Issue