summaryrefslogtreecommitdiff
path: root/src/pkg/go/token/token.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-11-04 17:02:05 -0800
committerRobert Griesemer <gri@golang.org>2009-11-04 17:02:05 -0800
commitab9508ab448c9e5014a6f5adee01f8250d2dc3c0 (patch)
treebeb972b0f08ca1e2d4cfb4552440543c8375329e /src/pkg/go/token/token.go
parent69cefc1e3b58604b44499301dcc4202c327a6e4c (diff)
downloadgolang-ab9508ab448c9e5014a6f5adee01f8250d2dc3c0.tar.gz
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
Diffstat (limited to 'src/pkg/go/token/token.go')
-rw-r--r--src/pkg/go/token/token.go266
1 files changed, 133 insertions, 133 deletions
diff --git a/src/pkg/go/token/token.go b/src/pkg/go/token/token.go
index 1ea6c46e9..b3191c22c 100644
--- a/src/pkg/go/token/token.go
+++ b/src/pkg/go/token/token.go
@@ -20,27 +20,27 @@ type Token int
// The list of tokens.
const (
// Special tokens
- ILLEGAL Token = iota;
+ ILLEGAL Token = iota;
EOF;
COMMENT;
literal_beg;
// Identifiers and basic type literals
// (these tokens stand for classes of literals)
- IDENT; // main
- INT; // 12345
- FLOAT; // 123.45
- CHAR; // 'a'
- STRING; // "abc"
+ IDENT; // main
+ INT; // 12345
+ FLOAT; // 123.45
+ CHAR; // 'a'
+ STRING; // "abc"
literal_end;
operator_beg;
// Operators and delimiters
- ADD; // +
- SUB; // -
- MUL; // *
- QUO; // /
- REM; // %
+ ADD; // +
+ SUB; // -
+ MUL; // *
+ QUO; // /
+ REM; // %
AND; // &
OR; // |
@@ -62,17 +62,17 @@ const (
SHR_ASSIGN; // >>=
AND_NOT_ASSIGN; // &^=
- LAND; // &&
- LOR; // ||
- ARROW; // <-
- INC; // ++
- DEC; // --
+ LAND; // &&
+ LOR; // ||
+ ARROW; // <-
+ INC; // ++
+ DEC; // --
- EQL; // ==
- LSS; // <
- GTR; // >
- ASSIGN; // =
- NOT; // !
+ EQL; // ==
+ LSS; // <
+ GTR; // >
+ ASSIGN; // =
+ NOT; // !
NEQ; // !=
LEQ; // <=
@@ -80,11 +80,11 @@ const (
DEFINE; // :=
ELLIPSIS; // ...
- LPAREN; // (
- LBRACK; // [
- LBRACE; // {
- COMMA; // ,
- PERIOD; // .
+ LPAREN; // (
+ LBRACK; // [
+ LBRACE; // {
+ COMMA; // ,
+ PERIOD; // .
RPAREN; // )
RBRACK; // ]
@@ -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",
}
@@ -252,9 +252,9 @@ func (tok Token) String() string {
// selector, indexing, and other operator and delimiter tokens.
//
const (
- LowestPrec = 0; // non-operators
- UnaryPrec = 7;
- HighestPrec = 8;
+ LowestPrec = 0; // non-operators
+ UnaryPrec = 7;
+ HighestPrec = 8;
)
@@ -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;
}
@@ -331,10 +331,10 @@ func (tok Token) IsKeyword() bool {
// A Position is valid if the line number is > 0.
//
type Position struct {
- Filename string; // filename, if any
- Offset int; // byte offset, starting at 0
- Line int; // line number, starting at 1
- Column int; // column number, starting at 1 (character count)
+ Filename string; // filename, if any
+ Offset int; // byte offset, starting at 0
+ Line int; // line number, starting at 1
+ Column int; // column number, starting at 1 (character count)
}
@@ -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;
}