Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
4beac998
Commit
4beac998
authored
May 23, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplifying grammar: delete LBASETYPE and LACONST.
take 2 R=ken OCL=29304 CL=29306
parent
ca2fe5d8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
66 deletions
+39
-66
align.c
src/cmd/gc/align.c
+1
-1
dcl.c
src/cmd/gc/dcl.c
+12
-4
export.c
src/cmd/gc/export.c
+5
-6
go.y
src/cmd/gc/go.y
+3
-32
lex.c
src/cmd/gc/lex.c
+18
-23
No files found.
src/cmd/gc/align.c
View file @
4beac998
...
...
@@ -213,7 +213,7 @@ typeinit(int lex)
int
i
,
etype
,
sameas
;
Type
*
t
;
Sym
*
s
;
if
(
widthptr
==
0
)
fatal
(
"typeinit before betypeinit"
);
...
...
src/cmd/gc/dcl.c
View file @
4beac998
...
...
@@ -1056,7 +1056,7 @@ addconst(Node *n, Node *e, int ctxt)
redeclare
(
"constant"
,
s
);
s
->
oconst
=
e
;
s
->
lexical
=
L
ACONST
;
s
->
lexical
=
L
NAME
;
d
=
dcl
();
d
->
dsym
=
s
;
...
...
@@ -1136,6 +1136,14 @@ oldname(Sym *s)
Node
*
n
;
Node
*
c
;
if
(
s
->
oconst
)
{
n
=
nod
(
OLITERAL
,
N
,
N
);
n
->
sym
=
s
;
n
->
val
=
s
->
oconst
->
val
;
n
->
type
=
s
->
oconst
->
type
;
return
n
;
}
n
=
s
->
oname
;
if
(
n
==
N
)
{
n
=
nod
(
ONONAME
,
N
,
N
);
...
...
@@ -1205,11 +1213,11 @@ nametoanondcl(Node *na)
for
(
l
=&
na
;
(
n
=*
l
)
->
op
==
OLIST
;
l
=&
n
->
left
)
n
->
right
=
nametoanondcl
(
n
->
right
);
if
(
n
->
sym
->
lexical
!=
LATYPE
&&
n
->
sym
->
lexical
!=
LBASETYPE
)
{
t
=
n
->
sym
->
otype
;
if
(
t
==
T
)
{
yyerror
(
"%s is not a type"
,
n
->
sym
->
name
);
t
=
typ
(
TINT32
);
}
else
t
=
oldtype
(
n
->
sym
);
}
n
=
nod
(
ODCLFIELD
,
N
,
N
);
n
->
type
=
t
;
*
l
=
n
;
...
...
src/cmd/gc/export.c
View file @
4beac998
...
...
@@ -190,7 +190,6 @@ dumpsym(Sym *s)
yyerror
(
"package export symbol: %S"
,
s
);
break
;
case
LATYPE
:
case
LBASETYPE
:
// TODO(rsc): sort methods by name
for
(
f
=
s
->
otype
->
method
;
f
!=
T
;
f
=
f
->
down
)
dumpprereq
(
f
);
...
...
@@ -201,10 +200,10 @@ dumpsym(Sym *s)
f
->
type
->
type
->
type
,
f
->
sym
,
f
->
type
);
break
;
case
LNAME
:
dumpexportvar
(
s
);
break
;
case
LACONST
:
dumpexportconst
(
s
);
if
(
s
->
oconst
)
dumpexportconst
(
s
)
;
else
dumpexportvar
(
s
);
break
;
}
}
...
...
@@ -344,7 +343,7 @@ importconst(Node *ss, Type *t, Node *n)
return
;
convlit
(
n
,
t
);
s
=
importsym
(
ss
,
L
ACONST
);
s
=
importsym
(
ss
,
L
NAME
);
if
(
s
->
oconst
!=
N
)
{
// TODO: check if already the same.
return
;
...
...
src/cmd/gc/go.y
View file @
4beac998
...
...
@@ -14,7 +14,7 @@
}
%
token
<
val
>
LLITERAL
%
token
<
lint
>
LASOP
%
token
<
sym
>
LNAME
L
BASETYPE
LATYPE
LPACK
LACONST
%
token
<
sym
>
LNAME
L
ATYPE
LPACK
%
token
<
sym
>
LPACKAGE
LIMPORT
LDEFER
LCLOSE
LCLOSED
%
token
<
sym
>
LMAP
LCHAN
LINTERFACE
LFUNC
LSTRUCT
%
token
<
sym
>
LCOLAS
LFALL
LRETURN
LDDD
...
...
@@ -42,7 +42,7 @@
* names like Bstmt, Bvardcl, etc. can'
t
.
*/
%
type
<
sym
>
sym
sym1
sym2
sym3
keyword
l
aconst
l
name
latype
lpackatype
%
type
<
sym
>
sym
sym1
sym2
sym3
keyword
lname
latype
lpackatype
%
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_chunk
arg_chunk_list_r
arg_type_list
...
...
@@ -913,13 +913,6 @@ pexpr:
{
$$
=
nodbool
(
0
);
}
|
laconst
{
$$
=
nod
(
OLITERAL
,
N
,
N
);
$$->
sym
=
$
1
;
$$->
val
=
$
1
->
oconst
->
val
;
$$->
type
=
$
1
->
oconst
->
type
;
}
|
LIOTA
{
$$
=
nodintconst
(
iota
);
...
...
@@ -1023,14 +1016,6 @@ lpack:
}
*/
laconst:
LACONST
| lpack '
.
' LACONST
{
$$ = $3;
context = nil;
}
lname:
LNAME
| lpack '
.
' LNAME
...
...
@@ -1082,7 +1067,6 @@ onew_name:
sym:
LATYPE
| LNAME
| LACONST
| LPACK
sym1:
...
...
@@ -1112,7 +1096,6 @@ sym3:
| LPRINTN
| LNEW
| LMAKE
| LBASETYPE
/*
* keywords that we can
...
...
@@ -2129,20 +2112,8 @@ lpack:
YYERROR;
}
laconst:
LATYPE
{
yyerror("%s is type, not var", $1->name);
YYERROR;
}
latype:
LACONST
{
yyerror("%s is const, not type", $1->name);
YYERROR;
}
| LPACK
LPACK
{
yyerror("%s is package, not type", $1->name);
YYERROR;
...
...
src/cmd/gc/lex.c
View file @
4beac998
...
...
@@ -64,7 +64,7 @@ main(int argc, char *argv[])
fatal
(
"betypeinit failed"
);
lexinit
();
typeinit
(
L
BASE
TYPE
);
typeinit
(
L
A
TYPE
);
lineno
=
1
;
block
=
1
;
...
...
@@ -775,8 +775,6 @@ talph:
DBG
(
"lex: %S %s
\n
"
,
s
,
lexname
(
s
->
lexical
));
yylval
.
sym
=
s
;
if
(
s
->
lexical
==
LBASETYPE
)
return
LATYPE
;
return
s
->
lexical
;
tnum:
...
...
@@ -1111,25 +1109,25 @@ static struct
/* name lexical etype
*/
/* basic types */
"int8"
,
L
BASE
TYPE
,
TINT8
,
"int16"
,
L
BASE
TYPE
,
TINT16
,
"int32"
,
L
BASE
TYPE
,
TINT32
,
"int64"
,
L
BASE
TYPE
,
TINT64
,
"int8"
,
L
A
TYPE
,
TINT8
,
"int16"
,
L
A
TYPE
,
TINT16
,
"int32"
,
L
A
TYPE
,
TINT32
,
"int64"
,
L
A
TYPE
,
TINT64
,
"uint8"
,
L
BASE
TYPE
,
TUINT8
,
"uint16"
,
L
BASE
TYPE
,
TUINT16
,
"uint32"
,
L
BASE
TYPE
,
TUINT32
,
"uint64"
,
L
BASE
TYPE
,
TUINT64
,
"uint8"
,
L
A
TYPE
,
TUINT8
,
"uint16"
,
L
A
TYPE
,
TUINT16
,
"uint32"
,
L
A
TYPE
,
TUINT32
,
"uint64"
,
L
A
TYPE
,
TUINT64
,
"float32"
,
L
BASE
TYPE
,
TFLOAT32
,
"float64"
,
L
BASE
TYPE
,
TFLOAT64
,
"float80"
,
L
BASE
TYPE
,
TFLOAT80
,
"float32"
,
L
A
TYPE
,
TFLOAT32
,
"float64"
,
L
A
TYPE
,
TFLOAT64
,
"float80"
,
L
A
TYPE
,
TFLOAT80
,
"bool"
,
L
BASE
TYPE
,
TBOOL
,
"byte"
,
L
BASE
TYPE
,
TUINT8
,
"string"
,
L
BASE
TYPE
,
TSTRING
,
"bool"
,
L
A
TYPE
,
TBOOL
,
"byte"
,
L
A
TYPE
,
TUINT8
,
"string"
,
L
A
TYPE
,
TSTRING
,
"any"
,
L
BASE
TYPE
,
TANY
,
"any"
,
L
A
TYPE
,
TANY
,
"break"
,
LBREAK
,
Txxx
,
"case"
,
LCASE
,
Txxx
,
...
...
@@ -1197,10 +1195,10 @@ lexinit(void)
s
->
lexical
=
lex
;
s
->
package
=
package
;
if
(
lex
!=
LBASETYPE
)
etype
=
syms
[
i
].
etype
;
if
(
etype
==
Txxx
)
continue
;
etype
=
syms
[
i
].
etype
;
if
(
etype
<
0
||
etype
>=
nelem
(
types
))
fatal
(
"lexinit: %s bad etype"
,
s
->
name
);
...
...
@@ -1234,9 +1232,6 @@ struct
{
LANDAND
,
"ANDAND"
,
LASOP
,
"ASOP"
,
LACONST
,
"ACONST"
,
LATYPE
,
"ATYPE"
,
LBASETYPE
,
"BASETYPE"
,
LBREAK
,
"BREAK"
,
LCASE
,
"CASE"
,
LCHAN
,
"CHAN"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment