modernc.org/cc@v1.0.1/trigraphs.go (about) 1 // Code generated by golex. DO NOT EDIT. 2 3 // Copyright 2016 The CC Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Based on [0], 6.4. 8 // 9 10 // Implements translation phases 1 and 2 of [0], 5.1.1.2. 11 12 package cc // import "modernc.org/cc" 13 14 import ( 15 "fmt" 16 ) 17 18 const ( 19 _ = iota 20 scTRIGRAPHS 21 ) 22 23 func (t *trigraphsReader) scan() (r int) { 24 c := t.Enter() 25 26 yystate0: 27 yyrule := -1 28 _ = yyrule 29 c = t.Rule0() 30 31 switch yyt := t.sc; yyt { 32 default: 33 panic(fmt.Errorf(`invalid start condition %d`, yyt)) 34 case 0: // start condition: INITIAL 35 goto yystart1 36 case 1: // start condition: TRIGRAPHS 37 goto yystart5 38 } 39 40 goto yystate0 // silence unused label error 41 goto yyAction // silence unused label error 42 yyAction: 43 switch yyrule { 44 case 1: 45 goto yyrule1 46 case 2: 47 goto yyrule2 48 case 3: 49 goto yyrule3 50 case 4: 51 goto yyrule4 52 case 5: 53 goto yyrule5 54 case 6: 55 goto yyrule6 56 case 7: 57 goto yyrule7 58 case 8: 59 goto yyrule8 60 case 9: 61 goto yyrule9 62 case 10: 63 goto yyrule10 64 case 11: 65 goto yyrule11 66 } 67 goto yystate1 // silence unused label error 68 yystate1: 69 c = t.Next() 70 yystart1: 71 switch { 72 default: 73 goto yyabort 74 case c == '\\': 75 goto yystate3 76 case c == '\r': 77 goto yystate2 78 } 79 80 yystate2: 81 c = t.Next() 82 yyrule = 10 83 t.Mark() 84 goto yyrule10 85 86 yystate3: 87 c = t.Next() 88 switch { 89 default: 90 goto yyabort 91 case c == '\n': 92 goto yystate2 93 case c == '\r': 94 goto yystate4 95 } 96 97 yystate4: 98 c = t.Next() 99 switch { 100 default: 101 goto yyabort 102 case c == '\n': 103 goto yystate2 104 } 105 106 goto yystate5 // silence unused label error 107 yystate5: 108 c = t.Next() 109 yystart5: 110 switch { 111 default: 112 goto yyabort 113 case c == '?': 114 goto yystate6 115 case c == '\\': 116 goto yystate3 117 case c == '\r': 118 goto yystate2 119 } 120 121 yystate6: 122 c = t.Next() 123 switch { 124 default: 125 goto yyabort 126 case c == '?': 127 goto yystate7 128 } 129 130 yystate7: 131 c = t.Next() 132 switch { 133 default: 134 goto yyabort 135 case c == '!': 136 goto yystate8 137 case c == '(': 138 goto yystate10 139 case c == ')': 140 goto yystate11 141 case c == '-': 142 goto yystate12 143 case c == '/': 144 goto yystate13 145 case c == '<': 146 goto yystate16 147 case c == '=': 148 goto yystate17 149 case c == '>': 150 goto yystate18 151 case c == '\'': 152 goto yystate9 153 } 154 155 yystate8: 156 c = t.Next() 157 yyrule = 1 158 t.Mark() 159 goto yyrule1 160 161 yystate9: 162 c = t.Next() 163 yyrule = 2 164 t.Mark() 165 goto yyrule2 166 167 yystate10: 168 c = t.Next() 169 yyrule = 3 170 t.Mark() 171 goto yyrule3 172 173 yystate11: 174 c = t.Next() 175 yyrule = 4 176 t.Mark() 177 goto yyrule4 178 179 yystate12: 180 c = t.Next() 181 yyrule = 5 182 t.Mark() 183 goto yyrule5 184 185 yystate13: 186 c = t.Next() 187 yyrule = 6 188 t.Mark() 189 switch { 190 default: 191 goto yyrule6 192 case c == '\n': 193 goto yystate14 194 case c == '\r': 195 goto yystate15 196 } 197 198 yystate14: 199 c = t.Next() 200 yyrule = 11 201 t.Mark() 202 goto yyrule11 203 204 yystate15: 205 c = t.Next() 206 switch { 207 default: 208 goto yyabort 209 case c == '\n': 210 goto yystate14 211 } 212 213 yystate16: 214 c = t.Next() 215 yyrule = 7 216 t.Mark() 217 goto yyrule7 218 219 yystate17: 220 c = t.Next() 221 yyrule = 8 222 t.Mark() 223 goto yyrule8 224 225 yystate18: 226 c = t.Next() 227 yyrule = 9 228 t.Mark() 229 goto yyrule9 230 231 yyrule1: // "??!" 232 { 233 return '|' 234 } 235 yyrule2: // "??'" 236 { 237 return '^' 238 } 239 yyrule3: // "??(" 240 { 241 return '[' 242 } 243 yyrule4: // "??)" 244 { 245 return ']' 246 } 247 yyrule5: // "??-" 248 { 249 return '~' 250 } 251 yyrule6: // "??/" 252 { 253 return '\\' 254 } 255 yyrule7: // "??<" 256 { 257 return '{' 258 } 259 yyrule8: // "??=" 260 { 261 return '#' 262 } 263 yyrule9: // "??>" 264 { 265 return '}' 266 } 267 yyrule10: // \\\r?\n|\r 268 yyrule11: // "??/"\r?\n 269 270 goto yystate0 271 panic("unreachable") 272 273 goto yyabort // silence unused label error 274 275 yyabort: // no lexem recognized 276 if c, ok := t.Abort(); ok { 277 return c 278 } 279 280 goto yyAction 281 }