| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  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) | 
|  262       return match[1]; |  262       return match[1]; | 
|  263     // TODO: Make this complain about expecting end of file. |  263     // TODO: Make this complain about expecting end of file. | 
|  264     return diagnose(state); |  264     return diagnose(state); | 
|  265   } |  265   } | 
|  266  |  266  | 
|  267   diagnose(state) { |  267   diagnose(state) { | 
|  268     var message = 'unexpected error'; |  268     var message = 'unexpected error'; | 
|  269     if (!state.max_rule.isEmpty()) { |  269     if (!state.max_rule.isEmpty) { | 
|  270       var s = new Set(); |  270       var s = new Set(); | 
|  271       for (var rule in state.max_rule) |  271       for (var rule in state.max_rule) | 
|  272         s.add(rule.description()); |  272         s.add(rule.description()); | 
|  273       var tokens = new List<String>.from(s); |  273       var tokens = new List<String>.from(s); | 
|  274       tokens.sort((a, b) => |  274       tokens.sort((a, b) => | 
|  275                   a.startsWith("'") == b.startsWith("'") |  275                   a.startsWith("'") == b.startsWith("'") | 
|  276                       ? a.compareTo(b) |  276                       ? a.compareTo(b) | 
|  277                       : a.startsWith("'") ? +1 : -1); |  277                       : a.startsWith("'") ? +1 : -1); | 
|  278       var expected = Strings.join(tokens, ' or '); |  278       var expected = Strings.join(tokens, ' or '); | 
|  279       var found = state.max_pos == state._end ? 'end of file' |  279       var found = state.max_pos == state._end ? 'end of file' | 
| (...skipping 569 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 |