Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
42ae5270
Commit
42ae5270
authored
Oct 31, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- handle field tags in pretty printer
R=r OCL=18264 CL=18264
parent
00dc6e96
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
+30
-19
usr/gri/pretty/parser.go
usr/gri/pretty/parser.go
+14
-14
usr/gri/pretty/printer.go
usr/gri/pretty/printer.go
+1
-1
usr/gri/pretty/selftest0.go
usr/gri/pretty/selftest0.go
+11
-0
usr/gri/pretty/selftest1.go
usr/gri/pretty/selftest1.go
+0
-0
usr/gri/pretty/test.sh
usr/gri/pretty/test.sh
+4
-4
No files found.
usr/gri/pretty/parser.go
View file @
42ae5270
...
...
@@ -326,7 +326,7 @@ func (P *Parser) ParseVarDeclList(list *AST.List, ellipsis_ok bool) {
// parse a list of types
i0
:=
list
.
len
();
for
{
list
.
Add
(
P
.
ParseVarDecl
(
i0
>
0
));
list
.
Add
(
P
.
ParseVarDecl
(
ellipsis_ok
/* param list */
&&
i0
>
0
));
if
P
.
tok
==
Scanner
.
COMMA
{
P
.
Next
();
}
else
{
...
...
@@ -340,7 +340,7 @@ func (P *Parser) ParseVarDeclList(list *AST.List, ellipsis_ok bool) {
P
.
Next
();
}
if
i0
>
0
&&
typ
==
nil
{
if
ellipsis_ok
/* param list */
&&
i0
>
0
&&
typ
==
nil
{
// not the first parameter section; we must have a type
P
.
Error
(
P
.
pos
,
"type expected"
);
typ
=
AST
.
BadType
;
...
...
@@ -365,18 +365,10 @@ func (P *Parser) ParseVarDeclList(list *AST.List, ellipsis_ok bool) {
}
else
{
// all list entries are types
// convert all type entries into type expressions
if
i0
>
0
{
panic
(
"internal parser error"
);
}
for
i
,
n
:=
0
,
list
.
len
();
i
<
n
;
i
++
{
for
i
,
n
:=
i0
,
list
.
len
();
i
<
n
;
i
++
{
t
:=
list
.
at
(
i
)
.
(
*
AST
.
Type
);
list
.
set
(
i
,
AST
.
NewTypeExpr
(
t
));
}
if
P
.
tok
==
Scanner
.
COMMA
{
panic
(
"internal parser error"
);
}
}
P
.
Ecart
();
...
...
@@ -514,6 +506,8 @@ func (P *Parser) ParseMapType() *AST.Type {
}
func
(
P
*
Parser
)
ParseOperand
()
*
AST
.
Expr
func
(
P
*
Parser
)
ParseStructType
()
*
AST
.
Type
{
P
.
Trace
(
"StructType"
);
...
...
@@ -522,10 +516,16 @@ func (P *Parser) ParseStructType() *AST.Type {
if
P
.
tok
==
Scanner
.
LBRACE
{
P
.
Next
();
t
.
list
=
AST
.
NewList
();
for
P
.
tok
==
Scanner
.
IDENT
{
for
P
.
tok
!=
Scanner
.
RBRACE
&&
P
.
tok
!=
Scanner
.
EOF
{
P
.
ParseVarDeclList
(
t
.
list
,
false
);
if
P
.
tok
!=
Scanner
.
RBRACE
{
P
.
Expect
(
Scanner
.
SEMICOLON
);
if
P
.
tok
==
Scanner
.
STRING
{
// ParseOperand takes care of string concatenation
t
.
list
.
Add
(
P
.
ParseOperand
());
}
if
P
.
tok
==
Scanner
.
SEMICOLON
{
P
.
Next
();
}
else
{
break
;
}
}
P
.
OptSemicolon
();
...
...
usr/gri/pretty/printer.go
View file @
42ae5270
...
...
@@ -139,7 +139,7 @@ func (P *Printer) Fields(list *AST.List) {
for
i
,
n
:=
0
,
list
.
len
();
i
<
n
;
i
++
{
x
:=
list
.
at
(
i
)
.
(
*
AST
.
Expr
);
if
i
>
0
{
if
prev
==
Scanner
.
TYPE
{
if
prev
==
Scanner
.
TYPE
&&
x
.
tok
!=
Scanner
.
STRING
||
prev
==
Scanner
.
STRING
{
P
.
semi
,
P
.
newl
=
true
,
1
;
}
else
if
prev
==
x
.
tok
{
P
.
String
(
0
,
", "
);
...
...
usr/gri/pretty/selftest0.go
0 → 100644
View file @
42ae5270
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
type
Proto
struct
{
a
int
"a tag"
;
b
,
c
,
d
*
Proto
"bcd"
"tag"
;
*
Proto
"proto tag"
}
usr/gri/pretty/selftest.go
→
usr/gri/pretty/selftest
1
.go
View file @
42ae5270
File moved
usr/gri/pretty/test.sh
View file @
42ae5270
...
...
@@ -21,7 +21,7 @@ count() {
apply1
()
{
#echo $1 $2
case
`
basename
$F
`
in
selftest.go
|
func3.go
|
bug014.go
|
bug029.go
|
bug032.go
|
bug050.go
|
\
selftest
1
.go
|
func3.go
|
bug014.go
|
bug029.go
|
bug032.go
|
bug050.go
|
\
bug068.go
|
bug088.go
|
bug083.go
|
bug106.go
)
;;
# skip - files contain syntax errors
*
)
$1
$2
;
count
;;
esac
...
...
@@ -120,11 +120,11 @@ runtests() {
}
# run selftest always
./pretty
-t
selftest.go
>
$TMP1
# run selftest
1
always
./pretty
-t
selftest
1
.go
>
$TMP1
if
[
$?
!=
0
]
;
then
cat
$TMP1
echo
"Error (selftest
): pretty -t selftest
.go"
echo
"Error (selftest
1): pretty -t selftest1
.go"
exit
1
fi
count
...
...
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