| 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 /** | 5 /** |
| 6 * Translates a string of characters into a YAML serialization tree. | 6 * Translates a string of characters into a YAML serialization tree. |
| 7 * | 7 * |
| 8 * This parser is designed to closely follow the spec. All productions in the | 8 * This parser is designed to closely follow the spec. All productions in the |
| 9 * spec are numbered, and the corresponding methods in the parser have the same | 9 * spec are numbered, and the corresponding methods in the parser have the same |
| 10 * numbers. This is certainly not the most efficient way of parsing YAML, but it | 10 * numbers. This is certainly not the most efficient way of parsing YAML, but it |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 908 |
| 909 // 108 | 909 // 108 |
| 910 bool ns_doubleChar() => !isSpace(peek()) && truth(nb_doubleChar()); | 910 bool ns_doubleChar() => !isSpace(peek()) && truth(nb_doubleChar()); |
| 911 | 911 |
| 912 // 109 | 912 // 109 |
| 913 _Node c_doubleQuoted(int indent, int ctx) => context('string', () { | 913 _Node c_doubleQuoted(int indent, int ctx) => context('string', () { |
| 914 return transaction(() { | 914 return transaction(() { |
| 915 if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null; | 915 if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null; |
| 916 var contents = nb_doubleText(indent, ctx); | 916 var contents = nb_doubleText(indent, ctx); |
| 917 if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null; | 917 if (!truth(c_indicator(C_DOUBLE_QUOTE))) return null; |
| 918 return new _ScalarNode("!", contents); | 918 return new _ScalarNode("!", content: contents); |
| 919 }); | 919 }); |
| 920 }); | 920 }); |
| 921 | 921 |
| 922 // 110 | 922 // 110 |
| 923 String nb_doubleText(int indent, int ctx) => captureString(() { | 923 String nb_doubleText(int indent, int ctx) => captureString(() { |
| 924 switch (ctx) { | 924 switch (ctx) { |
| 925 case FLOW_OUT: | 925 case FLOW_OUT: |
| 926 case FLOW_IN: | 926 case FLOW_IN: |
| 927 nb_doubleMultiLine(indent); | 927 nb_doubleMultiLine(indent); |
| 928 break; | 928 break; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 | 996 |
| 997 // 119 | 997 // 119 |
| 998 bool ns_singleChar() => !isSpace(peek()) && truth(nb_singleChar()); | 998 bool ns_singleChar() => !isSpace(peek()) && truth(nb_singleChar()); |
| 999 | 999 |
| 1000 // 120 | 1000 // 120 |
| 1001 _Node c_singleQuoted(int indent, int ctx) => context('string', () { | 1001 _Node c_singleQuoted(int indent, int ctx) => context('string', () { |
| 1002 return transaction(() { | 1002 return transaction(() { |
| 1003 if (!truth(c_indicator(C_SINGLE_QUOTE))) return null; | 1003 if (!truth(c_indicator(C_SINGLE_QUOTE))) return null; |
| 1004 var contents = nb_singleText(indent, ctx); | 1004 var contents = nb_singleText(indent, ctx); |
| 1005 if (!truth(c_indicator(C_SINGLE_QUOTE))) return null; | 1005 if (!truth(c_indicator(C_SINGLE_QUOTE))) return null; |
| 1006 return new _ScalarNode("!", contents); | 1006 return new _ScalarNode("!", content: contents); |
| 1007 }); | 1007 }); |
| 1008 }); | 1008 }); |
| 1009 | 1009 |
| 1010 // 121 | 1010 // 121 |
| 1011 String nb_singleText(int indent, int ctx) => captureString(() { | 1011 String nb_singleText(int indent, int ctx) => captureString(() { |
| 1012 switch (ctx) { | 1012 switch (ctx) { |
| 1013 case FLOW_OUT: | 1013 case FLOW_OUT: |
| 1014 case FLOW_IN: | 1014 case FLOW_IN: |
| 1015 nb_singleMultiLine(indent); | 1015 nb_singleMultiLine(indent); |
| 1016 break; | 1016 break; |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 // 170 | 1528 // 170 |
| 1529 _Node c_l_literal(int indent) => transaction(() { | 1529 _Node c_l_literal(int indent) => transaction(() { |
| 1530 if (!truth(c_indicator(C_LITERAL))) return null; | 1530 if (!truth(c_indicator(C_LITERAL))) return null; |
| 1531 var header = c_b_blockHeader(); | 1531 var header = c_b_blockHeader(); |
| 1532 if (!truth(header)) return null; | 1532 if (!truth(header)) return null; |
| 1533 | 1533 |
| 1534 var additionalIndent = blockScalarAdditionalIndentation(header, indent); | 1534 var additionalIndent = blockScalarAdditionalIndentation(header, indent); |
| 1535 var content = l_literalContent(indent + additionalIndent, header.chomping); | 1535 var content = l_literalContent(indent + additionalIndent, header.chomping); |
| 1536 if (!truth(content)) return null; | 1536 if (!truth(content)) return null; |
| 1537 | 1537 |
| 1538 return new _ScalarNode("!", content); | 1538 return new _ScalarNode("!", content: content); |
| 1539 }); | 1539 }); |
| 1540 | 1540 |
| 1541 // 171 | 1541 // 171 |
| 1542 bool l_nb_literalText(int indent) => transaction(() { | 1542 bool l_nb_literalText(int indent) => transaction(() { |
| 1543 zeroOrMore(() => captureAs("\n", () => l_empty(indent, BLOCK_IN))); | 1543 zeroOrMore(() => captureAs("\n", () => l_empty(indent, BLOCK_IN))); |
| 1544 if (!truth(captureAs("", () => s_indent(indent)))) return false; | 1544 if (!truth(captureAs("", () => s_indent(indent)))) return false; |
| 1545 return truth(oneOrMore(() => consume(isNonBreak))); | 1545 return truth(oneOrMore(() => consume(isNonBreak))); |
| 1546 }); | 1546 }); |
| 1547 | 1547 |
| 1548 // 172 | 1548 // 172 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1565 // 174 | 1565 // 174 |
| 1566 _Node c_l_folded(int indent) => transaction(() { | 1566 _Node c_l_folded(int indent) => transaction(() { |
| 1567 if (!truth(c_indicator(C_FOLDED))) return null; | 1567 if (!truth(c_indicator(C_FOLDED))) return null; |
| 1568 var header = c_b_blockHeader(); | 1568 var header = c_b_blockHeader(); |
| 1569 if (!truth(header)) return null; | 1569 if (!truth(header)) return null; |
| 1570 | 1570 |
| 1571 var additionalIndent = blockScalarAdditionalIndentation(header, indent); | 1571 var additionalIndent = blockScalarAdditionalIndentation(header, indent); |
| 1572 var content = l_foldedContent(indent + additionalIndent, header.chomping); | 1572 var content = l_foldedContent(indent + additionalIndent, header.chomping); |
| 1573 if (!truth(content)) return null; | 1573 if (!truth(content)) return null; |
| 1574 | 1574 |
| 1575 return new _ScalarNode("!", content); | 1575 return new _ScalarNode("!", content: content); |
| 1576 }); | 1576 }); |
| 1577 | 1577 |
| 1578 // 175 | 1578 // 175 |
| 1579 bool s_nb_foldedText(int indent) => transaction(() { | 1579 bool s_nb_foldedText(int indent) => transaction(() { |
| 1580 if (!truth(captureAs('', () => s_indent(indent)))) return false; | 1580 if (!truth(captureAs('', () => s_indent(indent)))) return false; |
| 1581 if (!truth(consume(isNonSpace))) return false; | 1581 if (!truth(consume(isNonSpace))) return false; |
| 1582 zeroOrMore(() => consume(isNonBreak)); | 1582 zeroOrMore(() => consume(isNonBreak)); |
| 1583 return true; | 1583 return true; |
| 1584 }); | 1584 }); |
| 1585 | 1585 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 var pair = contents[i]; | 1990 var pair = contents[i]; |
| 1991 if (pair.first.contains(pos)) return pair.last; | 1991 if (pair.first.contains(pos)) return pair.last; |
| 1992 } | 1992 } |
| 1993 return null; | 1993 return null; |
| 1994 } | 1994 } |
| 1995 | 1995 |
| 1996 /** Associates [value] with [range]. */ | 1996 /** Associates [value] with [range]. */ |
| 1997 operator[]=(_Range range, E value) => | 1997 operator[]=(_Range range, E value) => |
| 1998 contents.add(new _Pair<_Range, E>(range, value)); | 1998 contents.add(new _Pair<_Range, E>(range, value)); |
| 1999 } | 1999 } |
| OLD | NEW |