OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 yaml.parser; | |
6 | |
7 import 'package:source_span/source_span.dart'; | 5 import 'package:source_span/source_span.dart'; |
8 import 'package:string_scanner/string_scanner.dart'; | 6 import 'package:string_scanner/string_scanner.dart'; |
9 | 7 |
10 import 'event.dart'; | 8 import 'event.dart'; |
11 import 'scanner.dart'; | 9 import 'scanner.dart'; |
12 import 'style.dart'; | 10 import 'style.dart'; |
13 import 'token.dart'; | 11 import 'token.dart'; |
14 import 'utils.dart'; | 12 import 'utils.dart'; |
15 import 'yaml_document.dart'; | 13 import 'yaml_document.dart'; |
16 import 'yaml_exception.dart'; | 14 import 'yaml_exception.dart'; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 660 } |
663 | 661 |
664 /// Generate an empty scalar event. | 662 /// Generate an empty scalar event. |
665 Event _processEmptyScalar(SourceLocation location) => | 663 Event _processEmptyScalar(SourceLocation location) => |
666 new ScalarEvent(location.pointSpan(), '', ScalarStyle.PLAIN); | 664 new ScalarEvent(location.pointSpan(), '', ScalarStyle.PLAIN); |
667 | 665 |
668 /// Parses directives. | 666 /// Parses directives. |
669 Pair<VersionDirective, List<TagDirective>> _processDirectives() { | 667 Pair<VersionDirective, List<TagDirective>> _processDirectives() { |
670 var token = _scanner.peek(); | 668 var token = _scanner.peek(); |
671 | 669 |
672 var versionDirective; | 670 VersionDirective versionDirective; |
673 var tagDirectives = <TagDirective>[]; | 671 var tagDirectives = <TagDirective>[]; |
674 while (token.type == TokenType.VERSION_DIRECTIVE || | 672 while (token.type == TokenType.VERSION_DIRECTIVE || |
675 token.type == TokenType.TAG_DIRECTIVE) { | 673 token.type == TokenType.TAG_DIRECTIVE) { |
676 if (token is VersionDirectiveToken) { | 674 if (token is VersionDirectiveToken) { |
677 if (versionDirective != null) { | 675 if (versionDirective != null) { |
678 throw new YamlException("Duplicate %YAML directive.", token.span); | 676 throw new YamlException("Duplicate %YAML directive.", token.span); |
679 } | 677 } |
680 | 678 |
681 if (token.major != 1 || token.minor == 0) { | 679 if (token.major != 1 || token.minor == 0) { |
682 throw new YamlException( | 680 throw new YamlException( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 805 |
808 /// Expect nothing. | 806 /// Expect nothing. |
809 static const END = const _State("END"); | 807 static const END = const _State("END"); |
810 | 808 |
811 final String name; | 809 final String name; |
812 | 810 |
813 const _State(this.name); | 811 const _State(this.name); |
814 | 812 |
815 String toString() => name; | 813 String toString() => name; |
816 } | 814 } |
OLD | NEW |