github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/mapper/exprmapper/expression/gocc/token/token.go (about) 1 // Code generated by gocc; DO NOT EDIT. 2 3 package token 4 5 import ( 6 "fmt" 7 ) 8 9 type Token struct { 10 Type 11 Lit []byte 12 Pos 13 } 14 15 type Type int 16 17 const ( 18 INVALID Type = iota 19 EOF 20 ) 21 22 type Pos struct { 23 Offset int 24 Line int 25 Column int 26 } 27 28 func (p Pos) String() string { 29 return fmt.Sprintf("Pos(offset=%d, line=%d, column=%d)", p.Offset, p.Line, p.Column) 30 } 31 32 type TokenMap struct { 33 typeMap []string 34 idMap map[string]Type 35 } 36 37 func (m TokenMap) Id(tok Type) string { 38 if int(tok) < len(m.typeMap) { 39 return m.typeMap[tok] 40 } 41 return "unknown" 42 } 43 44 func (m TokenMap) Type(tok string) Type { 45 if typ, exist := m.idMap[tok]; exist { 46 return typ 47 } 48 return INVALID 49 } 50 51 func (m TokenMap) TokenString(tok *Token) string { 52 //TODO: refactor to print pos & token string properly 53 return fmt.Sprintf("%s(%d,%s)", m.Id(tok.Type), tok.Type, tok.Lit) 54 } 55 56 func (m TokenMap) StringType(typ Type) string { 57 return fmt.Sprintf("%s(%d)", m.Id(typ), typ) 58 } 59 60 var TokMap = TokenMap{ 61 typeMap: []string{ 62 "INVALID", 63 "$", 64 "||", 65 "&&", 66 "(", 67 ")", 68 "==", 69 "!=", 70 "<", 71 "<=", 72 ">", 73 ">=", 74 "+", 75 "-", 76 "*", 77 "/", 78 "%", 79 "function_name", 80 "()", 81 ",", 82 "?", 83 ":", 84 "doublequotes_string", 85 "singlequote_string", 86 "number", 87 "argument", 88 "true", 89 "false", 90 "float", 91 "nil", 92 "null", 93 }, 94 95 idMap: map[string]Type{ 96 "INVALID": 0, 97 "$": 1, 98 "||": 2, 99 "&&": 3, 100 "(": 4, 101 ")": 5, 102 "==": 6, 103 "!=": 7, 104 "<": 8, 105 "<=": 9, 106 ">": 10, 107 ">=": 11, 108 "+": 12, 109 "-": 13, 110 "*": 14, 111 "/": 15, 112 "%": 16, 113 "function_name": 17, 114 "()": 18, 115 ",": 19, 116 "?": 20, 117 ":": 21, 118 "doublequotes_string": 22, 119 "singlequote_string": 23, 120 "number": 24, 121 "argument": 25, 122 "true": 26, 123 "false": 27, 124 "float": 28, 125 "nil": 29, 126 "null": 30, 127 }, 128 }