github.com/corona10/go@v0.0.0-20180224231303-7a218942be57/src/cmd/compile/internal/syntax/tokens.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package syntax 6 7 type token uint 8 9 //go:generate stringer -type token -linecomment 10 11 const ( 12 _ token = iota 13 _EOF // EOF 14 15 // names and literals 16 _Name // name 17 _Literal // literal 18 19 // operators and operations 20 // _Operator is excluding '*' (_Star) 21 _Operator // op 22 _AssignOp // op= 23 _IncOp // opop 24 _Assign // = 25 _Define // := 26 _Arrow // <- 27 _Star // * 28 29 // delimiters 30 _Lparen // ( 31 _Lbrack // [ 32 _Lbrace // { 33 _Rparen // ) 34 _Rbrack // ] 35 _Rbrace // } 36 _Comma // , 37 _Semi // ; 38 _Colon // : 39 _Dot // . 40 _DotDotDot // ... 41 42 // keywords 43 _Break // break 44 _Case // case 45 _Chan // chan 46 _Const // const 47 _Continue // continue 48 _Default // default 49 _Defer // defer 50 _Else // else 51 _Fallthrough // fallthrough 52 _For // for 53 _Func // func 54 _Go // go 55 _Goto // goto 56 _If // if 57 _Import // import 58 _Interface // interface 59 _Map // map 60 _Package // package 61 _Range // range 62 _Return // return 63 _Select // select 64 _Struct // struct 65 _Switch // switch 66 _Type // type 67 _Var // var 68 69 // empty line comment to exclude it from .String 70 tokenCount // 71 ) 72 73 const ( 74 // for BranchStmt 75 Break = _Break 76 Continue = _Continue 77 Fallthrough = _Fallthrough 78 Goto = _Goto 79 80 // for CallStmt 81 Go = _Go 82 Defer = _Defer 83 ) 84 85 // Make sure we have at most 64 tokens so we can use them in a set. 86 const _ uint64 = 1 << (tokenCount - 1) 87 88 // contains reports whether tok is in tokset. 89 func contains(tokset uint64, tok token) bool { 90 return tokset&(1<<tok) != 0 91 } 92 93 type LitKind uint 94 95 const ( 96 IntLit LitKind = iota 97 FloatLit 98 ImagLit 99 RuneLit 100 StringLit 101 ) 102 103 type Operator uint 104 105 //go:generate stringer -type Operator -linecomment 106 107 const ( 108 _ Operator = iota 109 110 // Def is the : in := 111 Def // : 112 Not // ! 113 Recv // <- 114 115 // precOrOr 116 OrOr // || 117 118 // precAndAnd 119 AndAnd // && 120 121 // precCmp 122 Eql // == 123 Neq // != 124 Lss // < 125 Leq // <= 126 Gtr // > 127 Geq // >= 128 129 // precAdd 130 Add // + 131 Sub // - 132 Or // | 133 Xor // ^ 134 135 // precMul 136 Mul // * 137 Div // / 138 Rem // % 139 And // & 140 AndNot // &^ 141 Shl // << 142 Shr // >> 143 ) 144 145 // Operator precedences 146 const ( 147 _ = iota 148 precOrOr 149 precAndAnd 150 precCmp 151 precAdd 152 precMul 153 )