LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package expressions | 5 package expressions |
6 | 6 |
7 type T struct { | 7 type T struct { |
8 x, y, z int | 8 x, y, z int |
9 } | 9 } |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 _ = a - ^b; | 47 _ = a - ^b; |
48 _ = a / *p; | 48 _ = a / *p; |
49 _ = a + b*c; | 49 _ = a + b*c; |
50 _ = 1 + b*c; | 50 _ = 1 + b*c; |
51 _ = a + 2*c; | 51 _ = a + 2*c; |
52 _ = a + c*2; | 52 _ = a + c*2; |
53 _ = 1 + 2*3; | 53 _ = 1 + 2*3; |
54 _ = s[1 : 2*3]; | 54 _ = s[1 : 2*3]; |
55 _ = s[a : b-c]; | 55 _ = s[a : b-c]; |
56 _ = s[0:]; | 56 _ = s[0:]; |
| 57 _ = s[a+b]; |
57 _ = s[a+b :]; | 58 _ = s[a+b :]; |
| 59 _ = a[a<<b+1]; |
| 60 _ = a[a<<b+1 :]; |
58 _ = s[a+b : len(s)]; | 61 _ = s[a+b : len(s)]; |
59 _ = s[len(s) : -a]; | 62 _ = s[len(s) : -a]; |
60 _ = s[a : len(s)+1]; | 63 _ = s[a : len(s)+1]; |
61 _ = s[a : len(s)+1]+s; | 64 _ = s[a : len(s)+1]+s; |
62 | 65 |
63 // spaces around operators with equal or lower precedence than compariso
ns | 66 // spaces around operators with equal or lower precedence than compariso
ns |
64 _ = a == b; | 67 _ = a == b; |
65 _ = a != b; | 68 _ = a != b; |
66 _ = a > b; | 69 _ = a > b; |
67 _ = a >= b; | 70 _ = a >= b; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 328 |
326 func addState(s []state, inst instr, match []int) { | 329 func addState(s []state, inst instr, match []int) { |
327 // handle comments correctly in multi-line expressions | 330 // handle comments correctly in multi-line expressions |
328 for i := 0; i < l; i++ { | 331 for i := 0; i < l; i++ { |
329 if s[i].inst.index() == index && // same instruction | 332 if s[i].inst.index() == index && // same instruction |
330 s[i].match[0] < pos { // earlier match already going;
leftmost wins | 333 s[i].match[0] < pos { // earlier match already going;
leftmost wins |
331 return s | 334 return s |
332 } | 335 } |
333 } | 336 } |
334 } | 337 } |
LEFT | RIGHT |