OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 3 |
4 /** | 4 /** |
5 * A simple recursive descent parser for CSS. | 5 * A simple recursive descent parser for CSS. |
6 */ | 6 */ |
7 class Parser { | 7 class Parser { |
8 Tokenizer tokenizer; | 8 Tokenizer tokenizer; |
9 | 9 |
10 var _fs; // If non-null filesystem to read files. | 10 var _fs; // If non-null filesystem to read files. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 var message; | 129 var message; |
130 try { | 130 try { |
131 message = 'expected $expected, but found $tok'; | 131 message = 'expected $expected, but found $tok'; |
132 } catch (e) { | 132 } catch (e) { |
133 message = 'parsing error expected $expected'; | 133 message = 'parsing error expected $expected'; |
134 } | 134 } |
135 _error(message, tok.span); | 135 _error(message, tok.span); |
136 } | 136 } |
137 | 137 |
138 void _error(String message, [SourceSpan location=null]) { | 138 void _error(String message, [SourceSpan location=null]) { |
139 if (location === null) { | 139 if (location == null) { |
140 location = _peekToken.span; | 140 location = _peekToken.span; |
141 } | 141 } |
142 | 142 |
143 if (_erroMsgRedirector == null) { | 143 if (_erroMsgRedirector == null) { |
144 world.fatal(message, location); // syntax errors are fatal for now | 144 world.fatal(message, location); // syntax errors are fatal for now |
145 } else { | 145 } else { |
146 String text = ""; | 146 String text = ""; |
147 if (location != null) { | 147 if (location != null) { |
148 text = location.toMessageString(""); | 148 text = location.toMessageString(""); |
149 } | 149 } |
150 _erroMsgRedirector.displayError("CSS error: \r${text}\r${message}"); | 150 _erroMsgRedirector.displayError("CSS error: \r${text}\r${message}"); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void _warning(String message, [SourceSpan location=null]) { | 154 void _warning(String message, [SourceSpan location=null]) { |
155 if (location === null) { | 155 if (location == null) { |
156 location = _peekToken.span; | 156 location = _peekToken.span; |
157 } | 157 } |
158 | 158 |
159 world.warning(message, location); | 159 world.warning(message, location); |
160 } | 160 } |
161 | 161 |
162 SourceSpan _makeSpan(int start) { | 162 SourceSpan _makeSpan(int start) { |
163 return new SourceSpan(source, start, _previousToken.end); | 163 return new SourceSpan(source, start, _previousToken.end); |
164 } | 164 } |
165 | 165 |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1008 |
1009 return result; | 1009 return result; |
1010 } | 1010 } |
1011 } | 1011 } |
1012 | 1012 |
1013 /** Not a hex number. */ | 1013 /** Not a hex number. */ |
1014 class HexNumberException implements Exception { | 1014 class HexNumberException implements Exception { |
1015 HexNumberException(); | 1015 HexNumberException(); |
1016 } | 1016 } |
1017 | 1017 |
OLD | NEW |