| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('classify'); | 5 library classify; |
| 6 | 6 |
| 7 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); | 7 import '../../../lib/compiler/implementation/scanner/scannerlib.dart'; |
| 8 // TODO(rnystrom): Use "package:" URL (#4968). | 8 // TODO(rnystrom): Use "package:" URL (#4968). |
| 9 #import('markdown.dart', prefix: 'md'); | 9 import 'markdown.dart' as md; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Kinds of tokens that we care to highlight differently. The values of the | 12 * Kinds of tokens that we care to highlight differently. The values of the |
| 13 * fields here will be used as CSS class names for the generated spans. | 13 * fields here will be used as CSS class names for the generated spans. |
| 14 */ | 14 */ |
| 15 class Classification { | 15 class Classification { |
| 16 static const NONE = null; | 16 static const NONE = null; |
| 17 static const ERROR = "e"; | 17 static const ERROR = "e"; |
| 18 static const COMMENT = "c"; | 18 static const COMMENT = "c"; |
| 19 static const IDENTIFIER = "i"; | 19 static const IDENTIFIER = "i"; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 case GT_TOKEN: | 177 case GT_TOKEN: |
| 178 case LT_EQ_TOKEN: | 178 case LT_EQ_TOKEN: |
| 179 case GT_EQ_TOKEN: | 179 case GT_EQ_TOKEN: |
| 180 case INDEX_TOKEN: | 180 case INDEX_TOKEN: |
| 181 case INDEX_EQ_TOKEN: | 181 case INDEX_EQ_TOKEN: |
| 182 return Classification.OPERATOR; | 182 return Classification.OPERATOR; |
| 183 | 183 |
| 184 // Color keyword token. Most are colored as keywords. | 184 // Color keyword token. Most are colored as keywords. |
| 185 case HASH_TOKEN: | 185 case HASH_TOKEN: |
| 186 case KEYWORD_TOKEN: | 186 case KEYWORD_TOKEN: |
| 187 if (token.stringValue === 'void') { | 187 if (token.stringValue == 'void') { |
| 188 // Color "void" as a type. | 188 // Color "void" as a type. |
| 189 return Classification.TYPE_IDENTIFIER; | 189 return Classification.TYPE_IDENTIFIER; |
| 190 } | 190 } |
| 191 if (token.stringValue === 'this' || token.stringValue === 'super') { | 191 if (token.stringValue == 'this' || token.stringValue == 'super') { |
| 192 // Color "this" and "super" as identifiers. | 192 // Color "this" and "super" as identifiers. |
| 193 return Classification.SPECIAL_IDENTIFIER; | 193 return Classification.SPECIAL_IDENTIFIER; |
| 194 } | 194 } |
| 195 return Classification.KEYWORD; | 195 return Classification.KEYWORD; |
| 196 | 196 |
| 197 case EOF_TOKEN: | 197 case EOF_TOKEN: |
| 198 return Classification.NONE; | 198 return Classification.NONE; |
| 199 | 199 |
| 200 default: | 200 default: |
| 201 return Classification.NONE; | 201 return Classification.NONE; |
| 202 } | 202 } |
| 203 } | 203 } |
| OLD | NEW |