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
b6adb327
Commit
b6adb327
authored
Dec 28, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify some code that is using vectors
R=agl, agl1 CC=golang-dev
https://golang.org/cl/181080
parent
3c6bf095
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
parser.go
src/pkg/go/parser/parser.go
+37
-37
No files found.
src/pkg/go/parser/parser.go
View file @
b6adb327
...
@@ -170,9 +170,9 @@ func (p *parser) consumeCommentGroup() int {
...
@@ -170,9 +170,9 @@ func (p *parser) consumeCommentGroup() int {
}
}
// convert list
// convert list
group
:=
make
([]
*
ast
.
Comment
,
l
ist
.
Len
(
))
group
:=
make
([]
*
ast
.
Comment
,
l
en
(
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
list
{
group
[
i
]
=
list
.
At
(
i
)
.
(
*
ast
.
Comment
)
group
[
i
]
=
x
.
(
*
ast
.
Comment
)
}
}
// add comment group to the comments list
// add comment group to the comments list
...
@@ -321,9 +321,9 @@ func (p *parser) parseIdentList() []*ast.Ident {
...
@@ -321,9 +321,9 @@ func (p *parser) parseIdentList() []*ast.Ident {
}
}
// convert vector
// convert vector
idents
:=
make
([]
*
ast
.
Ident
,
l
ist
.
Len
(
))
idents
:=
make
([]
*
ast
.
Ident
,
l
en
(
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
list
{
idents
[
i
]
=
list
.
At
(
i
)
.
(
*
ast
.
Ident
)
idents
[
i
]
=
x
.
(
*
ast
.
Ident
)
}
}
return
idents
return
idents
...
@@ -331,9 +331,9 @@ func (p *parser) parseIdentList() []*ast.Ident {
...
@@ -331,9 +331,9 @@ func (p *parser) parseIdentList() []*ast.Ident {
func
makeExprList
(
list
*
vector
.
Vector
)
[]
ast
.
Expr
{
func
makeExprList
(
list
*
vector
.
Vector
)
[]
ast
.
Expr
{
exprs
:=
make
([]
ast
.
Expr
,
l
ist
.
Len
(
))
exprs
:=
make
([]
ast
.
Expr
,
l
en
(
*
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
*
list
{
exprs
[
i
]
=
list
.
At
(
i
)
.
(
ast
.
Expr
)
exprs
[
i
]
=
x
.
(
ast
.
Expr
)
}
}
return
exprs
return
exprs
}
}
...
@@ -421,11 +421,11 @@ func (p *parser) parseArrayType(ellipsisOk bool) ast.Expr {
...
@@ -421,11 +421,11 @@ func (p *parser) parseArrayType(ellipsisOk bool) ast.Expr {
func
(
p
*
parser
)
makeIdentList
(
list
*
vector
.
Vector
)
[]
*
ast
.
Ident
{
func
(
p
*
parser
)
makeIdentList
(
list
*
vector
.
Vector
)
[]
*
ast
.
Ident
{
idents
:=
make
([]
*
ast
.
Ident
,
l
ist
.
Len
(
))
idents
:=
make
([]
*
ast
.
Ident
,
l
en
(
*
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
*
list
{
ident
,
isIdent
:=
list
.
At
(
i
)
.
(
*
ast
.
Ident
)
ident
,
isIdent
:=
x
.
(
*
ast
.
Ident
)
if
!
isIdent
{
if
!
isIdent
{
pos
:=
list
.
At
(
i
)
.
(
ast
.
Expr
)
.
Pos
()
pos
:=
x
.
(
ast
.
Expr
)
.
Pos
()
p
.
errorExpected
(
pos
,
"identifier"
)
p
.
errorExpected
(
pos
,
"identifier"
)
idents
[
i
]
=
&
ast
.
Ident
{
pos
,
""
}
idents
[
i
]
=
&
ast
.
Ident
{
pos
,
""
}
}
}
...
@@ -471,7 +471,7 @@ func (p *parser) parseFieldDecl() *ast.Field {
...
@@ -471,7 +471,7 @@ func (p *parser) parseFieldDecl() *ast.Field {
idents
=
p
.
makeIdentList
(
&
list
)
idents
=
p
.
makeIdentList
(
&
list
)
}
else
{
}
else
{
// Type (anonymous field)
// Type (anonymous field)
if
l
ist
.
Len
(
)
==
1
{
if
l
en
(
list
)
==
1
{
// TODO(gri): check that this looks like a type
// TODO(gri): check that this looks like a type
typ
=
list
.
At
(
0
)
.
(
ast
.
Expr
)
typ
=
list
.
At
(
0
)
.
(
ast
.
Expr
)
}
else
{
}
else
{
...
@@ -500,9 +500,9 @@ func (p *parser) parseStructType() *ast.StructType {
...
@@ -500,9 +500,9 @@ func (p *parser) parseStructType() *ast.StructType {
rbrace
:=
p
.
expect
(
token
.
RBRACE
)
rbrace
:=
p
.
expect
(
token
.
RBRACE
)
// convert vector
// convert vector
fields
:=
make
([]
*
ast
.
Field
,
l
ist
.
Len
(
))
fields
:=
make
([]
*
ast
.
Field
,
l
en
(
list
))
for
i
:=
list
.
Len
()
-
1
;
i
>=
0
;
i
--
{
for
i
,
x
:=
range
list
{
fields
[
i
]
=
list
.
At
(
i
)
.
(
*
ast
.
Field
)
fields
[
i
]
=
x
.
(
*
ast
.
Field
)
}
}
return
&
ast
.
StructType
{
pos
,
lbrace
,
fields
,
rbrace
,
false
}
return
&
ast
.
StructType
{
pos
,
lbrace
,
fields
,
rbrace
,
false
}
...
@@ -597,15 +597,15 @@ func (p *parser) parseParameterList(ellipsisOk bool) []*ast.Field {
...
@@ -597,15 +597,15 @@ func (p *parser) parseParameterList(ellipsisOk bool) []*ast.Field {
}
else
{
}
else
{
// Type { "," Type } (anonymous parameters)
// Type { "," Type } (anonymous parameters)
// convert list of types into list of *Param
// convert list of types into list of *Param
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
*
list
{
list
.
Set
(
i
,
&
ast
.
Field
{
Type
:
list
.
At
(
i
)
.
(
ast
.
Expr
)})
list
.
Set
(
i
,
&
ast
.
Field
{
Type
:
x
.
(
ast
.
Expr
)})
}
}
}
}
// convert list
// convert list
params
:=
make
([]
*
ast
.
Field
,
l
ist
.
Len
(
))
params
:=
make
([]
*
ast
.
Field
,
l
en
(
*
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
*
list
{
params
[
i
]
=
list
.
At
(
i
)
.
(
*
ast
.
Field
)
params
[
i
]
=
x
.
(
*
ast
.
Field
)
}
}
return
params
return
params
...
@@ -710,9 +710,9 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
...
@@ -710,9 +710,9 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
rbrace
:=
p
.
expect
(
token
.
RBRACE
)
rbrace
:=
p
.
expect
(
token
.
RBRACE
)
// convert vector
// convert vector
methods
:=
make
([]
*
ast
.
Field
,
l
ist
.
Len
(
))
methods
:=
make
([]
*
ast
.
Field
,
l
en
(
list
))
for
i
:=
list
.
Len
()
-
1
;
i
>=
0
;
i
--
{
for
i
,
x
:=
range
list
{
methods
[
i
]
=
list
.
At
(
i
)
.
(
*
ast
.
Field
)
methods
[
i
]
=
x
.
(
*
ast
.
Field
)
}
}
return
&
ast
.
InterfaceType
{
pos
,
lbrace
,
methods
,
rbrace
,
false
}
return
&
ast
.
InterfaceType
{
pos
,
lbrace
,
methods
,
rbrace
,
false
}
...
@@ -796,9 +796,9 @@ func (p *parser) tryType() ast.Expr { return p.tryRawType(false) }
...
@@ -796,9 +796,9 @@ func (p *parser) tryType() ast.Expr { return p.tryRawType(false) }
// Blocks
// Blocks
func
makeStmtList
(
list
*
vector
.
Vector
)
[]
ast
.
Stmt
{
func
makeStmtList
(
list
*
vector
.
Vector
)
[]
ast
.
Stmt
{
stats
:=
make
([]
ast
.
Stmt
,
l
ist
.
Len
(
))
stats
:=
make
([]
ast
.
Stmt
,
l
en
(
*
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
*
list
{
stats
[
i
]
=
list
.
At
(
i
)
.
(
ast
.
Stmt
)
stats
[
i
]
=
x
.
(
ast
.
Stmt
)
}
}
return
stats
return
stats
}
}
...
@@ -1792,9 +1792,9 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen
...
@@ -1792,9 +1792,9 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen
}
}
// convert vector
// convert vector
specs
:=
make
([]
ast
.
Spec
,
l
ist
.
Len
(
))
specs
:=
make
([]
ast
.
Spec
,
l
en
(
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
list
{
specs
[
i
]
=
list
.
At
(
i
)
.
(
ast
.
Spec
)
specs
[
i
]
=
x
.
(
ast
.
Spec
)
}
}
return
&
ast
.
GenDecl
{
doc
,
pos
,
keyword
,
lparen
,
specs
,
rparen
}
return
&
ast
.
GenDecl
{
doc
,
pos
,
keyword
,
lparen
,
specs
,
rparen
}
...
@@ -1898,9 +1898,9 @@ func (p *parser) parseDeclList() []ast.Decl {
...
@@ -1898,9 +1898,9 @@ func (p *parser) parseDeclList() []ast.Decl {
}
}
// convert vector
// convert vector
decls
:=
make
([]
ast
.
Decl
,
l
ist
.
Len
(
))
decls
:=
make
([]
ast
.
Decl
,
l
en
(
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
list
{
decls
[
i
]
=
list
.
At
(
i
)
.
(
ast
.
Decl
)
decls
[
i
]
=
x
.
(
ast
.
Decl
)
}
}
return
decls
return
decls
...
@@ -1944,9 +1944,9 @@ func (p *parser) parseFile() *ast.File {
...
@@ -1944,9 +1944,9 @@ func (p *parser) parseFile() *ast.File {
}
}
// convert declaration list
// convert declaration list
decls
=
make
([]
ast
.
Decl
,
l
ist
.
Len
(
))
decls
=
make
([]
ast
.
Decl
,
l
en
(
list
))
for
i
:=
0
;
i
<
list
.
Len
();
i
++
{
for
i
,
x
:=
range
list
{
decls
[
i
]
=
list
.
At
(
i
)
.
(
ast
.
Decl
)
decls
[
i
]
=
x
.
(
ast
.
Decl
)
}
}
}
}
...
...
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