pretty: pretty.6
$(L) -o pretty pretty.6
-test: all
+test: pretty
pretty *.go
- # pretty $(GOROOT)/test/fixedbugs/*.go # some files legally don't compile
+ pretty $(GOROOT)/test/fixedbugs/*.go # some files legally don't compile
pretty $(GOROOT)/test/sieve.go
pretty $(GOROOT)/src/pkg/*.go
pretty $(GOROOT)/src/lib/flag.go
pretty $(GOROOT)/src/lib/math/*.go
pretty $(GOROOT)/src/lib/container/*.go
pretty $(GOROOT)/src/syscall/*.go
- pretty base.go decls.go
- pretty -token_chan base.go decls.go
echo "PASSED"
install: pretty
}
-func (P *Parser) ParseIdentList() {
+func (P *Parser) ParseIdentList() int {
P.Trace("IdentList");
P.ParseIdent();
+ n := 1;
for P.tok == Scanner.COMMA {
P.Next();
P.ParseIdent();
+ n++;
}
P.Ecart();
+ return n;
}
if ident == nil {
ident = P.ParseIdent();
}
+ if P.tok == Scanner.PERIOD {
+ P.Next();
+ ident = P.ParseIdent();
+ }
P.Ecart();
return ident;
P.ParseExpression();
}
P.Expect(Scanner.RBRACK);
+ P.ParseType();
P.Ecart();
}
}
-func (P *Parser) ParseVarDeclList() {
+func (P *Parser) ParseVarDeclList() int {
P.Trace("VarDeclList");
- P.ParseIdentList();
+ n := P.ParseIdentList();
P.ParseVarType();
P.Ecart();
+ return n;
}
-func (P *Parser) ParseParameterList() {
+func (P *Parser) ParseParameterList() int {
P.Trace("ParameterList");
- P.ParseVarDeclList();
+ n := P.ParseVarDeclList();
for P.tok == Scanner.COMMA {
P.Next();
- P.ParseVarDeclList();
+ n += P.ParseVarDeclList();
}
P.Ecart();
+ return n;
}
-func (P *Parser) ParseParameters() {
+func (P *Parser) ParseParameters() int {
P.Trace("Parameters");
+ n := 0;
P.Expect(Scanner.LPAREN);
if P.tok != Scanner.RPAREN {
- P.ParseParameterList();
+ n = P.ParseParameterList();
}
P.Expect(Scanner.RPAREN);
P.Ecart();
+ return n;
}
if P.tok == Scanner.LPAREN {
// one or more named results
- // TODO: here we allow empty returns - should proably fix this
+ // TODO: here we allow empty returns - should probably fix this
P.ParseParameters();
} else {
P.OpenScope();
P.level--;
- p0 := 0;
if P.tok == Scanner.LPAREN {
recv_pos := P.pos;
- P.ParseParameters();
- //p0 = sig.entries.len;
- if p0 != 1 {
- print("p0 = ", p0, "\n");
+ n := P.ParseParameters();
+ if n != 1 {
P.Error(recv_pos, "must have exactly one receiver");
panic("UNIMPLEMENTED (ParseNamedSignature)");
// TODO do something useful here
P.ParseParameters();
- //r0 := sig.entries.len;
P.ParseResult();
P.level++;
P.CloseScope();
P.Trace("FunctionType");
typ := P.ParseSignature();
-
+
P.Ecart();
}
P.Trace("FunctionLit");
P.Expect(Scanner.FUNC);
- P.ParseFunctionType();
+ P.ParseSignature(); // replace this with ParseFunctionType() and it won't work - 6g bug?
P.ParseBlock();
P.Ecart();
P.Expect(Scanner.LPAREN);
if P.tok != Scanner.RPAREN {
- P.ParseExpressionList();
+ // first arguments could be a type if the call is to "new"
+ if P.tok != Scanner.IDENT && P.TryType() {
+ if P.tok == Scanner.COMMA {
+ P.Next();
+ if P.tok != Scanner.RPAREN {
+ P.ParseExpressionList();
+ }
+ }
+ } else {
+ P.ParseExpressionList();
+ }
}
P.Expect(Scanner.RPAREN);
}
-func (P *Parser) ParseIfStat() *AST.IfStat {
+func (P *Parser) ParseIfStat() {
P.Trace("IfStat");
P.Expect(Scanner.IF);
P.CloseScope();
P.Ecart();
- return nil;
}
func (P *Parser) ParseVarSpec(exported bool) {
P.Trace("VarSpec");
- list := P.ParseIdentList();
+ P.ParseIdentList();
if P.tok == Scanner.ASSIGN {
P.Next();
P.ParseExpressionList();