mirror of
https://github.com/golang/go
synced 2024-11-18 19:54:44 -07:00
new grammar:
binary <- is send unary <- is recv -< is gone case a := <-ch: works in select case a = <-ch: works in select support for new cases is not yet in the compiler but all non-select code works second CL will update affected go source R=ken OCL=15414 CL=15414
This commit is contained in:
parent
4dfc7f0f14
commit
47919799b4
@ -25,11 +25,10 @@
|
||||
%token <sym> LNIL LTRUE LFALSE LIOTA
|
||||
|
||||
%token LOROR LANDAND LEQ LNE LLE LLT LGE LGT
|
||||
%token LLSH LRSH LINC LDEC LSEND LRECV
|
||||
%token LLSH LRSH LINC LDEC LCOMM
|
||||
%token LIGNORE
|
||||
|
||||
%type <sym> sym sym1 sym2 keyword laconst lname latype non_type_sym
|
||||
%type <lint> chandir
|
||||
%type <node> xdcl xdcl_list_r oxdcl_list
|
||||
%type <node> common_dcl Acommon_dcl Bcommon_dcl
|
||||
%type <node> oarg_type_list arg_type_list_r arg_type
|
||||
@ -55,10 +54,11 @@
|
||||
%type <type> fntype fnlitdcl Afntype Bfntype fullAtype
|
||||
%type <type> type Atype Btype indcl new_type fullBtype
|
||||
%type <type> structtype interfacetype convtype
|
||||
%type <type> Achantype Bchantype
|
||||
|
||||
%left LOROR
|
||||
%left LANDAND
|
||||
%left LSEND LRECV
|
||||
%left LCOMM
|
||||
%left LEQ LNE LLE LGE LLT LGT
|
||||
%left '+' '-' '|' '^'
|
||||
%left '*' '/' '%' '&' LLSH LRSH
|
||||
@ -412,6 +412,24 @@ complex_stmt:
|
||||
poptodcl();
|
||||
$$ = nod(OXCASE, $2, N);
|
||||
}
|
||||
| LCASE name '=' expr ':'
|
||||
{
|
||||
// will be converted to OCASE
|
||||
// right will point to next case
|
||||
// done in casebody()
|
||||
poptodcl();
|
||||
$$ = nod(OAS, $2, $4);
|
||||
$$ = nod(OXCASE, $$, N);
|
||||
}
|
||||
| LCASE name LCOLAS expr ':'
|
||||
{
|
||||
// will be converted to OCASE
|
||||
// right will point to next case
|
||||
// done in casebody()
|
||||
poptodcl();
|
||||
$$ = nod(OAS, colas($2, $4), $4);
|
||||
$$ = nod(OXCASE, $$, N);
|
||||
}
|
||||
| LDEFAULT ':'
|
||||
{
|
||||
poptodcl();
|
||||
@ -644,14 +662,10 @@ expr:
|
||||
{
|
||||
$$ = nod(ORSH, $1, $3);
|
||||
}
|
||||
| expr LSEND expr
|
||||
| expr LCOMM expr
|
||||
{
|
||||
$$ = nod(OSEND, $1, $3);
|
||||
}
|
||||
| expr LRECV expr
|
||||
{
|
||||
$$ = nod(ORECV, $1, $3);
|
||||
}
|
||||
|
||||
uexpr:
|
||||
pexpr
|
||||
@ -684,7 +698,7 @@ uexpr:
|
||||
{
|
||||
$$ = nod(OCOM, $2, N);
|
||||
}
|
||||
| LRECV uexpr
|
||||
| LCOMM uexpr
|
||||
{
|
||||
$$ = nod(ORECV, $2, N);
|
||||
}
|
||||
@ -931,11 +945,17 @@ Atype:
|
||||
{
|
||||
$$ = aindex($2, $4);
|
||||
}
|
||||
| LCHAN chandir fullAtype
|
||||
| LCOMM LCHAN fullAtype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $3;
|
||||
$$->chan = $2;
|
||||
$$->chan = Crecv;
|
||||
}
|
||||
| LCHAN LCOMM Atype // not full Atype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $3;
|
||||
$$->chan = Csend;
|
||||
}
|
||||
| LMAP '[' type ']' fullAtype
|
||||
{
|
||||
@ -951,20 +971,35 @@ Atype:
|
||||
$$ = ptrto($2);
|
||||
}
|
||||
|
||||
Achantype:
|
||||
LCHAN fullAtype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $2;
|
||||
$$->chan = Cboth;
|
||||
}
|
||||
|
||||
fullAtype:
|
||||
Atype
|
||||
| Afntype
|
||||
| Achantype
|
||||
|
||||
Btype:
|
||||
'[' oexpr ']' fullBtype
|
||||
{
|
||||
$$ = aindex($2, $4);
|
||||
}
|
||||
| LCHAN chandir fullBtype
|
||||
| LCOMM LCHAN fullBtype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $3;
|
||||
$$->chan = $2;
|
||||
$$->chan = Crecv;
|
||||
}
|
||||
| LCHAN LCOMM Btype // not full Btype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $3;
|
||||
$$->chan = Csend;
|
||||
}
|
||||
| LMAP '[' type ']' fullBtype
|
||||
{
|
||||
@ -985,9 +1020,18 @@ Btype:
|
||||
$$ = forwdcl($2);
|
||||
}
|
||||
|
||||
Bchantype:
|
||||
LCHAN fullBtype
|
||||
{
|
||||
$$ = typ(TCHAN);
|
||||
$$->type = $2;
|
||||
$$->chan = Cboth;
|
||||
}
|
||||
|
||||
fullBtype:
|
||||
Btype
|
||||
| Bfntype
|
||||
| Bchantype
|
||||
|
||||
structtype:
|
||||
LSTRUCT '{' structdcl_list_r osemi '}'
|
||||
@ -1010,19 +1054,6 @@ interfacetype:
|
||||
$$ = dostruct(N, TINTER);
|
||||
}
|
||||
|
||||
chandir:
|
||||
{
|
||||
$$ = Cboth;
|
||||
}
|
||||
| LRECV
|
||||
{
|
||||
$$ = Crecv;
|
||||
}
|
||||
| LSEND
|
||||
{
|
||||
$$ = Csend;
|
||||
}
|
||||
|
||||
keyval:
|
||||
expr ':' expr
|
||||
{
|
||||
|
@ -485,10 +485,6 @@ l0:
|
||||
c = LDEC;
|
||||
goto lx;
|
||||
}
|
||||
if(c1 == '<') {
|
||||
c = LSEND;
|
||||
goto lx;
|
||||
}
|
||||
if(c1 == '=') {
|
||||
c = OSUB;
|
||||
goto asop;
|
||||
@ -529,7 +525,7 @@ l0:
|
||||
goto lx;
|
||||
}
|
||||
if(c1 == '-') {
|
||||
c = LRECV;
|
||||
c = LCOMM;
|
||||
goto lx;
|
||||
}
|
||||
c = LLT;
|
||||
|
Loading…
Reference in New Issue
Block a user