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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 if (compiledRule.generatesValue) | 593 if (compiledRule.generatesValue) |
594 ++valueCount; | 594 ++valueCount; |
595 compiledRules.add(compiledRule); | 595 compiledRules.add(compiledRule); |
596 } | 596 } |
597 } | 597 } |
598 return finish(compiledRules, valueCount, reducer); | 598 return finish(compiledRules, valueCount, reducer); |
599 } | 599 } |
600 | 600 |
601 String _formatMultiRule(String functor, List rules) { | 601 String _formatMultiRule(String functor, List rules) { |
602 var sb = new StringBuffer(functor); | 602 var sb = new StringBuffer(functor); |
603 sb.add('('); | 603 sb.write('('); |
604 var separator = ''; | 604 var separator = ''; |
605 for (var rule in rules) { | 605 for (var rule in rules) { |
606 sb.add(separator); | 606 sb.write(separator); |
607 sb.add(rule); | 607 sb.write(rule); |
608 separator = ','; | 608 separator = ','; |
609 } | 609 } |
610 sb.add(')'); | 610 sb.write(')'); |
611 return sb.toString(); | 611 return sb.toString(); |
612 } | 612 } |
613 | 613 |
614 class _SequenceRule extends _Rule { | 614 class _SequenceRule extends _Rule { |
615 // This rule matches the component rules in order. | 615 // This rule matches the component rules in order. |
616 final List<_Rule> _rules; | 616 final List<_Rule> _rules; |
617 final int _generatingSubRules; | 617 final int _generatingSubRules; |
618 final Function _reducer; | 618 final Function _reducer; |
619 bool _generatesValue; | 619 bool _generatesValue; |
620 _SequenceRule(List<_Rule> this._rules, | 620 _SequenceRule(List<_Rule> this._rules, |
(...skipping 228 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 |