]> Cypherpunks repositories - gostls13.git/commitdiff
- added experimental flag '-def': will print (not parse!)
authorRobert Griesemer <gri@golang.org>
Mon, 2 Feb 2009 19:51:07 +0000 (11:51 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 2 Feb 2009 19:51:07 +0000 (11:51 -0800)
'def' instead of 'func', 'const', or 'type'

R=r
OCL=24092
CL=24094

usr/gri/pretty/printer.go

index 1168c9c82c47dfbb4745bb3a36692af5951fe1be..002a91a2d507b6d4fc398041553f718fb24d5947 100644 (file)
@@ -18,6 +18,7 @@ import (
 
 var (
        debug = flag.Bool("debug", false, "print debugging information");
+       def = flag.Bool("def", false, "print 'def' instead of 'const', 'type', 'func' - experimental");
 
        // layout control
        tabwidth = flag.Int("tabwidth", 8, "tab width");
@@ -803,7 +804,11 @@ func (P *Printer) Stat(s *AST.Stat) {
 
 func (P *Printer) Declaration(d *AST.Decl, parenthesized bool) {
        if !parenthesized {
-               P.Token(d.Pos, d.Tok);
+               if !*def || d.Tok == Scanner.IMPORT || d.Tok == Scanner.VAR {
+                       P.Token(d.Pos, d.Tok);
+               } else {
+                       P.String(d.Pos, "def");
+               }
                P.separator = blank;
        }