Commit 2ce57ec1 authored by Robert Griesemer's avatar Robert Griesemer

gofmt-ify src/pkg/go (excluding printer directory due to pending CL,

and parser.go and scanner_test.go which have minor formatting issues)

R=rsc
http://go/go-review/1016042
parent 26c3f6c1
......@@ -331,29 +331,51 @@ func (x *KeyValueExpr) Pos() token.Position {
// exprNode() ensures that only expression/type nodes can be
// assigned to an ExprNode.
func (x *BadExpr) exprNode() {}
func (x *Ident) exprNode() {}
func (x *Ellipsis) exprNode() {}
func (x *BasicLit) exprNode() {}
func (x *StringList) exprNode() {}
func (x *FuncLit) exprNode() {}
func (x *CompositeLit) exprNode() {}
func (x *ParenExpr) exprNode() {}
func (x *SelectorExpr) exprNode() {}
func (x *IndexExpr) exprNode() {}
func (x *TypeAssertExpr) exprNode() {}
func (x *CallExpr) exprNode() {}
func (x *StarExpr) exprNode() {}
func (x *UnaryExpr) exprNode() {}
func (x *BinaryExpr) exprNode() {}
func (x *KeyValueExpr) exprNode() {}
func (x *ArrayType) exprNode() {}
func (x *StructType) exprNode() {}
func (x *FuncType) exprNode() {}
func (x *InterfaceType) exprNode() {}
func (x *MapType) exprNode() {}
func (x *ChanType) exprNode() {}
func (x *BadExpr) exprNode() {
}
func (x *Ident) exprNode() {
}
func (x *Ellipsis) exprNode() {
}
func (x *BasicLit) exprNode() {
}
func (x *StringList) exprNode() {
}
func (x *FuncLit) exprNode() {
}
func (x *CompositeLit) exprNode() {
}
func (x *ParenExpr) exprNode() {
}
func (x *SelectorExpr) exprNode() {
}
func (x *IndexExpr) exprNode() {
}
func (x *TypeAssertExpr) exprNode() {
}
func (x *CallExpr) exprNode() {
}
func (x *StarExpr) exprNode() {
}
func (x *UnaryExpr) exprNode() {
}
func (x *BinaryExpr) exprNode() {
}
func (x *KeyValueExpr) exprNode() {
}
func (x *ArrayType) exprNode() {
}
func (x *StructType) exprNode() {
}
func (x *FuncType) exprNode() {
}
func (x *InterfaceType) exprNode() {
}
func (x *MapType) exprNode() {
}
func (x *ChanType) exprNode() {
}
// IsExported returns whether name is an exported Go symbol
......@@ -564,27 +586,48 @@ func (s *AssignStmt) Pos() token.Position {
// stmtNode() ensures that only statement nodes can be
// assigned to a StmtNode.
//
func (s *BadStmt) stmtNode() {}
func (s *DeclStmt) stmtNode() {}
func (s *EmptyStmt) stmtNode() {}
func (s *LabeledStmt) stmtNode() {}
func (s *ExprStmt) stmtNode() {}
func (s *IncDecStmt) stmtNode() {}
func (s *AssignStmt) stmtNode() {}
func (s *GoStmt) stmtNode() {}
func (s *DeferStmt) stmtNode() {}
func (s *ReturnStmt) stmtNode() {}
func (s *BranchStmt) stmtNode() {}
func (s *BlockStmt) stmtNode() {}
func (s *IfStmt) stmtNode() {}
func (s *CaseClause) stmtNode() {}
func (s *SwitchStmt) stmtNode() {}
func (s *TypeCaseClause) stmtNode() {}
func (s *TypeSwitchStmt) stmtNode() {}
func (s *CommClause) stmtNode() {}
func (s *SelectStmt) stmtNode() {}
func (s *ForStmt) stmtNode() {}
func (s *RangeStmt) stmtNode() {}
func (s *BadStmt) stmtNode() {
}
func (s *DeclStmt) stmtNode() {
}
func (s *EmptyStmt) stmtNode() {
}
func (s *LabeledStmt) stmtNode() {
}
func (s *ExprStmt) stmtNode() {
}
func (s *IncDecStmt) stmtNode() {
}
func (s *AssignStmt) stmtNode() {
}
func (s *GoStmt) stmtNode() {
}
func (s *DeferStmt) stmtNode() {
}
func (s *ReturnStmt) stmtNode() {
}
func (s *BranchStmt) stmtNode() {
}
func (s *BlockStmt) stmtNode() {
}
func (s *IfStmt) stmtNode() {
}
func (s *CaseClause) stmtNode() {
}
func (s *SwitchStmt) stmtNode() {
}
func (s *TypeCaseClause) stmtNode() {
}
func (s *TypeSwitchStmt) stmtNode() {
}
func (s *CommClause) stmtNode() {
}
func (s *SelectStmt) stmtNode() {
}
func (s *ForStmt) stmtNode() {
}
func (s *RangeStmt) stmtNode() {
}
// ----------------------------------------------------------------------------
......@@ -648,9 +691,12 @@ func (s *TypeSpec) Pos() token.Position {
// specNode() ensures that only spec nodes can be
// assigned to a Spec.
//
func (s *ImportSpec) specNode() {}
func (s *ValueSpec) specNode() {}
func (s *TypeSpec) specNode() {}
func (s *ImportSpec) specNode() {
}
func (s *ValueSpec) specNode() {
}
func (s *TypeSpec) specNode() {
}
// A declaration is represented by one of the following declaration nodes.
......@@ -704,9 +750,12 @@ func (d *FuncDecl) Pos() token.Position {
// declNode() ensures that only declaration nodes can be
// assigned to a DeclNode.
//
func (d *BadDecl) declNode() {}
func (d *GenDecl) declNode() {}
func (d *FuncDecl) declNode() {}
func (d *BadDecl) declNode() {
}
func (d *GenDecl) declNode() {
}
func (d *FuncDecl) declNode() {
}
// ----------------------------------------------------------------------------
......
......@@ -12,7 +12,7 @@ package ast
//
type Scope struct {
Outer *Scope;
Names map[string]*Ident
Names map[string]*Ident;
}
......
......@@ -31,8 +31,8 @@ func CommentText(comment *ast.CommentGroup) string {
// Remove comment markers.
// The parser has given us exactly the comment text.
switch n := len(c); {
case n >= 4 && c[0:2] == "/*" && c[n-2:n] == "*/":
c = c[2:n-2];
case n >= 4 && c[0:2] == "/*" && c[n-2 : n] == "*/":
c = c[2 : n-2];
case n >= 2 && c[0:2] == "//":
c = c[2:n];
// Remove leading space after //, if there is one.
......@@ -51,7 +51,7 @@ func CommentText(comment *ast.CommentGroup) string {
for m > 0 && (l[m-1] == ' ' || l[m-1] == '\n' || l[m-1] == '\t' || l[m-1] == '\r') {
m--;
}
l = l[0 : m];
l = l[0:m];
// Add to list.
n := len(lines);
......@@ -76,7 +76,7 @@ func CommentText(comment *ast.CommentGroup) string {
n++;
}
}
lines = lines[0 : n];
lines = lines[0:n];
// Add final "" entry to get trailing newline from Join.
// The original loop always leaves room for one more.
......@@ -115,7 +115,7 @@ func split(text []byte) [][]byte {
}
}
if last < len(text) {
out[n] = text[last : len(text)];
out[n] = text[last:len(text)];
}
return out;
......@@ -133,7 +133,7 @@ func commentEscape(w io.Writer, s []byte) {
last := 0;
for i := 0; i < len(s)-1; i++ {
if s[i] == s[i+1] && (s[i] == '`' || s[i] == '\'') {
template.HtmlEscape(w, s[last : i]);
template.HtmlEscape(w, s[last:i]);
last = i+2;
switch s[i] {
case '`':
......@@ -144,7 +144,7 @@ func commentEscape(w io.Writer, s []byte) {
i++; // loop will add one more
}
}
template.HtmlEscape(w, s[last : len(s)]);
template.HtmlEscape(w, s[last:len(s)]);
}
......@@ -166,7 +166,7 @@ func indentLen(s []byte) int {
func isBlank(s []byte) bool {
return len(s) == 0 || (len(s) == 1 && s[0] == '\n')
return len(s) == 0 || (len(s) == 1 && s[0] == '\n');
}
......@@ -175,7 +175,7 @@ func commonPrefix(a, b []byte) []byte {
for i < len(a) && i < len(b) && a[i] == b[i] {
i++;
}
return a[0 : i];
return a[0:i];
}
......@@ -196,7 +196,7 @@ func unindent(block [][]byte) {
// remove
for i, line := range block {
if !isBlank(line) {
block[i] = line[n : len(line)];
block[i] = line[n:len(line)];
}
}
}
......@@ -260,7 +260,7 @@ func ToHtml(w io.Writer, s []byte) {
for j > i && isBlank(lines[j-1]) {
j--;
}
block := lines[i : j];
block := lines[i:j];
i = j;
unindent(block);
......@@ -288,4 +288,3 @@ func ToHtml(w io.Writer, s []byte) {
inpara = false;
}
}
......@@ -131,103 +131,103 @@ const (
// At the moment we have no array literal syntax that lets us describe
// the index for each element - use a map for now to make sure they are
// in sync.
var tokens = map [Token] string {
ILLEGAL : "ILLEGAL",
EOF : "EOF",
COMMENT : "COMMENT",
IDENT : "IDENT",
INT : "INT",
FLOAT : "FLOAT",
CHAR : "CHAR",
STRING : "STRING",
ADD : "+",
SUB : "-",
MUL : "*",
QUO : "/",
REM : "%",
AND : "&",
OR : "|",
XOR : "^",
SHL : "<<",
SHR : ">>",
AND_NOT : "&^",
ADD_ASSIGN : "+=",
SUB_ASSIGN : "-=",
MUL_ASSIGN : "*=",
QUO_ASSIGN : "/=",
REM_ASSIGN : "%=",
AND_ASSIGN : "&=",
OR_ASSIGN : "|=",
XOR_ASSIGN : "^=",
SHL_ASSIGN : "<<=",
SHR_ASSIGN : ">>=",
AND_NOT_ASSIGN : "&^=",
LAND : "&&",
LOR : "||",
ARROW : "<-",
INC : "++",
DEC : "--",
EQL : "==",
LSS : "<",
GTR : ">",
ASSIGN : "=",
NOT : "!",
NEQ : "!=",
LEQ : "<=",
GEQ : ">=",
DEFINE : ":=",
ELLIPSIS : "...",
LPAREN : "(",
LBRACK : "[",
LBRACE : "{",
COMMA : ",",
PERIOD : ".",
RPAREN : ")",
RBRACK : "]",
RBRACE : "}",
SEMICOLON : ";",
COLON : ":",
BREAK : "break",
CASE : "case",
CHAN : "chan",
CONST : "const",
CONTINUE : "continue",
DEFAULT : "default",
DEFER : "defer",
ELSE : "else",
FALLTHROUGH : "fallthrough",
FOR : "for",
FUNC : "func",
GO : "go",
GOTO : "goto",
IF : "if",
IMPORT : "import",
INTERFACE : "interface",
MAP : "map",
PACKAGE : "package",
RANGE : "range",
RETURN : "return",
SELECT : "select",
STRUCT : "struct",
SWITCH : "switch",
TYPE : "type",
VAR : "var",
var tokens = map[Token]string{
ILLEGAL: "ILLEGAL",
EOF: "EOF",
COMMENT: "COMMENT",
IDENT: "IDENT",
INT: "INT",
FLOAT: "FLOAT",
CHAR: "CHAR",
STRING: "STRING",
ADD: "+",
SUB: "-",
MUL: "*",
QUO: "/",
REM: "%",
AND: "&",
OR: "|",
XOR: "^",
SHL: "<<",
SHR: ">>",
AND_NOT: "&^",
ADD_ASSIGN: "+=",
SUB_ASSIGN: "-=",
MUL_ASSIGN: "*=",
QUO_ASSIGN: "/=",
REM_ASSIGN: "%=",
AND_ASSIGN: "&=",
OR_ASSIGN: "|=",
XOR_ASSIGN: "^=",
SHL_ASSIGN: "<<=",
SHR_ASSIGN: ">>=",
AND_NOT_ASSIGN: "&^=",
LAND: "&&",
LOR: "||",
ARROW: "<-",
INC: "++",
DEC: "--",
EQL: "==",
LSS: "<",
GTR: ">",
ASSIGN: "=",
NOT: "!",
NEQ: "!=",
LEQ: "<=",
GEQ: ">=",
DEFINE: ":=",
ELLIPSIS: "...",
LPAREN: "(",
LBRACK: "[",
LBRACE: "{",
COMMA: ",",
PERIOD: ".",
RPAREN: ")",
RBRACK: "]",
RBRACE: "}",
SEMICOLON: ";",
COLON: ":",
BREAK: "break",
CASE: "case",
CHAN: "chan",
CONST: "const",
CONTINUE: "continue",
DEFAULT: "default",
DEFER: "defer",
ELSE: "else",
FALLTHROUGH: "fallthrough",
FOR: "for",
FUNC: "func",
GO: "go",
GOTO: "goto",
IF: "if",
IMPORT: "import",
INTERFACE: "interface",
MAP: "map",
PACKAGE: "package",
RANGE: "range",
RETURN: "return",
SELECT: "select",
STRUCT: "struct",
SWITCH: "switch",
TYPE: "type",
VAR: "var",
}
......@@ -281,10 +281,10 @@ func (op Token) Precedence() int {
}
var keywords map [string] Token;
var keywords map[string]Token
func init() {
keywords = make(map [string] Token);
keywords = make(map[string]Token);
for i := keyword_beg + 1; i < keyword_end; i++ {
keywords[tokens[i]] = i;
}
......@@ -348,7 +348,7 @@ func (pos *Position) Pos() Position {
// IsValid returns true if the position is valid.
func (pos *Position) IsValid() bool {
return pos.Line > 0
return pos.Line > 0;
}
......
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