| 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 // 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('Peg Parser'); | 5 #library('Peg Parser'); |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * The following functions are combinators for building Rules. | 8 * The following functions are combinators for building Rules. |
| 9 * | 9 * |
| 10 * A rule is one of the following | 10 * A rule is one of the following |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 Symbol s = new Symbol(name, this); | 241 Symbol s = new Symbol(name, this); |
| 242 _symbols[name] = s; | 242 _symbols[name] = s; |
| 243 return s; | 243 return s; |
| 244 } | 244 } |
| 245 | 245 |
| 246 /** | 246 /** |
| 247 * Parses the input string and returns the parsed AST, or throws an exception | 247 * Parses the input string and returns the parsed AST, or throws an exception |
| 248 * if the input can't be parsed. | 248 * if the input can't be parsed. |
| 249 */ | 249 */ |
| 250 parse(root, String text) { | 250 parse(root, String text) { |
| 251 for (var symbol in _symbols.getValues()) | 251 for (var symbol in _symbols.values) |
| 252 if (symbol._rule == null) | 252 if (symbol._rule == null) |
| 253 print('${symbol.name} is undefined'); | 253 print('${symbol.name} is undefined'); |
| 254 | 254 |
| 255 var state = new _ParserState(text, whitespace: whitespace); | 255 var state = new _ParserState(text, whitespace: whitespace); |
| 256 var match = _compile(root).match(state, 0); | 256 var match = _compile(root).match(state, 0); |
| 257 if (match == null) | 257 if (match == null) |
| 258 return diagnose(state); | 258 return diagnose(state); |
| 259 var pos = match[0]; | 259 var pos = match[0]; |
| 260 pos = _skip_whitespace(state, pos); | 260 pos = _skip_whitespace(state, pos); |
| 261 if (pos == state._end) | 261 if (pos == state._end) |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 add(s); | 849 add(s); |
| 850 add(t); | 850 add(t); |
| 851 add(u); | 851 add(u); |
| 852 add(v); | 852 add(v); |
| 853 add(w); | 853 add(w); |
| 854 add(x); | 854 add(x); |
| 855 add(y); | 855 add(y); |
| 856 add(z); | 856 add(z); |
| 857 return list; | 857 return list; |
| 858 } | 858 } |
| OLD | NEW |