Commit 738c58ca authored by Robert Griesemer's avatar Robert Griesemer

improved handling of expression lists

R=rsc
DELTA=189  (118 added, 9 deleted, 62 changed)
OCL=35816
CL=35821
parent 4f7aa318
This diff is collapsed.
...@@ -308,6 +308,50 @@ func _() { ...@@ -308,6 +308,50 @@ func _() {
} }
func _() {
var Universe = Scope {
Names: map[string]*Ident {
// basic types
"bool": nil,
"byte": nil,
"int8": nil,
"int16": nil,
"int32": nil,
"int64": nil,
"uint8": nil,
"uint16": nil,
"uint32": nil,
"uint64": nil,
"float32": nil,
"float64": nil,
"string": nil,
// convenience types
"int": nil,
"uint": nil,
"uintptr": nil,
"float": nil,
// constants
"false": nil,
"true": nil,
"iota": nil,
"nil": nil,
// functions
"cap": nil,
"len": nil,
"new": nil,
"make": nil,
"panic": nil,
"panicln": nil,
"print": nil,
"println": nil,
}
}
}
// formatting of consecutive single-line functions // formatting of consecutive single-line functions
func _() {} func _() {}
func _() {} func _() {}
......
...@@ -174,10 +174,13 @@ func _() { ...@@ -174,10 +174,13 @@ func _() {
f, ff, fff, ffff int = 0, 1, 2, 3; // comment f, ff, fff, ffff int = 0, 1, 2, 3; // comment
) )
// respect original line breaks // respect original line breaks
var _ = []T{T{0x20, "Telugu"}};
var _ = []T{ var _ = []T{
// respect original line breaks T{0x20, "Telugu"},
T{0x20, "Telugu"}}; };
var _ = []T{
// respect original line breaks
T{0x20, "Telugu"},
};
} }
func _() { func _() {
...@@ -305,6 +308,50 @@ func _() { ...@@ -305,6 +308,50 @@ func _() {
} }
func _() {
var Universe = Scope{
Names: map[string]*Ident{
// basic types
"bool": nil,
"byte": nil,
"int8": nil,
"int16": nil,
"int32": nil,
"int64": nil,
"uint8": nil,
"uint16": nil,
"uint32": nil,
"uint64": nil,
"float32": nil,
"float64": nil,
"string": nil,
// convenience types
"int": nil,
"uint": nil,
"uintptr": nil,
"float": nil,
// constants
"false": nil,
"true": nil,
"iota": nil,
"nil": nil,
// functions
"cap": nil,
"len": nil,
"new": nil,
"make": nil,
"panic": nil,
"panicln": nil,
"print": nil,
"println": nil,
},
};
}
// formatting of consecutive single-line functions // formatting of consecutive single-line functions
func _() {} func _() {}
func _() {} func _() {}
......
...@@ -172,8 +172,7 @@ func (p *parser) charClass() { ...@@ -172,8 +172,7 @@ func (p *parser) charClass() {
func addState(s []state, inst instr, match []int) { func addState(s []state, inst instr, match []int) {
// handle comments correctly in multi-line expressions // handle comments correctly in multi-line expressions
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
if s[i].inst.index() == index && if s[i].inst.index() == index && // same instruction
// same instruction
s[i].match[0] < pos { // earlier match already going; leftmost wins s[i].match[0] < pos { // earlier match already going; leftmost wins
return s; return s;
} }
......
...@@ -172,8 +172,7 @@ func (p *parser) charClass() { ...@@ -172,8 +172,7 @@ func (p *parser) charClass() {
func addState(s []state, inst instr, match []int) { func addState(s []state, inst instr, match []int) {
// handle comments correctly in multi-line expressions // handle comments correctly in multi-line expressions
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
if s[i].inst.index() == index && if s[i].inst.index() == index && // same instruction
// same instruction
s[i].match[0] < pos { // earlier match already going; leftmost wins s[i].match[0] < pos { // earlier match already going; leftmost wins
return s; return s;
} }
......
...@@ -63,19 +63,22 @@ var writerTests = []*writerTest{ ...@@ -63,19 +63,22 @@ var writerTests = []*writerTest{
// tar -b 1 -c -f- /tmp/16gig.txt | dd bs=512 count=8 > writer-big.tar // tar -b 1 -c -f- /tmp/16gig.txt | dd bs=512 count=8 > writer-big.tar
&writerTest{ &writerTest{
file: "testdata/writer-big.tar", file: "testdata/writer-big.tar",
entries: []*writerTestEntry{&writerTestEntry{header: &Header{ entries: []*writerTestEntry{
Name: "tmp/16gig.txt", &writerTestEntry{
Mode: 0640, header: &Header{
Uid: 73025, Name: "tmp/16gig.txt",
Gid: 5000, Mode: 0640,
Size: 16<<30, Uid: 73025,
Mtime: 1254699560, Gid: 5000,
Typeflag: '0', Size: 16<<30,
Uname: "dsymonds", Mtime: 1254699560,
Gname: "eng", Typeflag: '0',
} Uname: "dsymonds",
// no contents Gname: "eng",
}}, },
// no contents
},
},
}, },
} }
...@@ -181,9 +184,7 @@ var facts = map[int]string{ ...@@ -181,9 +184,7 @@ var facts = map[int]string{
func usage() { func usage() {
fmt.Fprintf(os.Stderr, fmt.Fprintf(os.Stderr,
// TODO(gri): the 2nd string of this string list should not be indented
// TODO(gri): the 2nd string of this string list should not be indented
"usage: godoc package [name ...]\n" "usage: godoc package [name ...]\n"
" godoc -http=:6060\n"); " godoc -http=:6060\n");
flag.PrintDefaults(); flag.PrintDefaults();
......
...@@ -35,7 +35,8 @@ func _() { ...@@ -35,7 +35,8 @@ func _() {
switch expr {} // no semicolon and parens printed switch expr {} // no semicolon and parens printed
switch x := expr; { switch x := expr; {
default: default:
use(x); use(
x);
} }
switch x := expr; expr { switch x := expr; expr {
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment