| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // TokenKinds is a type which describes the kinds of tokens which can be | 5 // TokenKinds is a type which describes the kinds of tokens which can be |
| 6 // encountered in a mojom file. | 6 // encountered in a mojom file. |
| 7 | 7 |
| 8 package lexer | 8 package lexer |
| 9 | 9 |
| 10 import ( | 10 import ( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 True | 60 True |
| 61 False | 61 False |
| 62 Default | 62 Default |
| 63 | 63 |
| 64 // Constants | 64 // Constants |
| 65 IntConstDec | 65 IntConstDec |
| 66 IntConstHex | 66 IntConstHex |
| 67 FloatConst | 67 FloatConst |
| 68 Ordinal | 68 Ordinal |
| 69 StringLiteral | 69 StringLiteral |
| 70 |
| 71 // Comments |
| 72 SingleLineComment |
| 73 MultiLineComment |
| 70 ) | 74 ) |
| 71 | 75 |
| 72 // This method is used to generate user-facing strings in compilation error | 76 // This method is used to generate user-facing strings in compilation error |
| 73 // messages. For example for LBrace we produce the string "'{'". Notice the | 77 // messages. For example for LBrace we produce the string "'{'". Notice the |
| 74 // single-quotes. This will be used for example in an error message that looks | 78 // single-quotes. This will be used for example in an error message that looks |
| 75 // like the following: | 79 // like the following: |
| 76 // Unexpected token at line 5, column 6: '###'. Expecting '{'. | 80 // Unexpected token at line 5, column 6: '###'. Expecting '{'. |
| 77 func (tokenKind TokenKind) String() string { | 81 func (tokenKind TokenKind) String() string { |
| 78 switch tokenKind { | 82 switch tokenKind { |
| 79 // Errors | 83 // Errors |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 snippetBuffer.WriteString("\x1b[32;1m") | 293 snippetBuffer.WriteString("\x1b[32;1m") |
| 290 } | 294 } |
| 291 snippetBuffer.WriteString(strings.Repeat("^", tokenSize)) | 295 snippetBuffer.WriteString(strings.Repeat("^", tokenSize)) |
| 292 if color { | 296 if color { |
| 293 // Reset all printing attributes. | 297 // Reset all printing attributes. |
| 294 snippetBuffer.WriteString("\x1b[0m") | 298 snippetBuffer.WriteString("\x1b[0m") |
| 295 } | 299 } |
| 296 snippet = snippetBuffer.String() | 300 snippet = snippetBuffer.String() |
| 297 return | 301 return |
| 298 } | 302 } |
| OLD | NEW |