OLD | NEW |
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 /// Tools for loading and parsing platform-configuration files. | 5 /// Tools for loading and parsing platform-configuration files. |
6 library plaform_configuration; | 6 library plaform_configuration; |
7 | 7 |
8 import "dart:async"; | 8 import "dart:async"; |
9 import "package:charcode/ascii.dart"; | 9 import "package:charcode/ascii.dart"; |
10 import "../compiler_new.dart" as api; | 10 import "../compiler_new.dart" as api; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 if (endOfHeader == -1) { | 68 if (endOfHeader == -1) { |
69 error("'[' must be matched by ']' on the same line.", startOfLine); | 69 error("'[' must be matched by ']' on the same line.", startOfLine); |
70 } | 70 } |
71 if (endOfHeader == startOfLine + 1) { | 71 if (endOfHeader == startOfLine + 1) { |
72 error("Empty header name", startOfLine + 1); | 72 error("Empty header name", startOfLine + 1); |
73 } | 73 } |
74 if (endOfHeader != endOfLine - 1) { | 74 if (endOfHeader != endOfLine - 1) { |
75 error("Section heading lines must end with ']'", endOfHeader + 1); | 75 error("Section heading lines must end with ']'", endOfHeader + 1); |
76 } | 76 } |
77 int startOfSectionName = startOfLine + 1; | 77 int startOfSectionName = startOfLine + 1; |
78 String sectionName = new String.fromCharCodes( | 78 String sectionName = |
79 source, startOfSectionName, endOfHeader).trim(); | 79 new String.fromCharCodes(source, startOfSectionName, endOfHeader) |
| 80 .trim(); |
80 currentSection = new Map<String, String>(); | 81 currentSection = new Map<String, String>(); |
81 if (result.containsKey(sectionName)) { | 82 if (result.containsKey(sectionName)) { |
82 error("Duplicate section name '$sectionName'", startOfSectionName); | 83 error("Duplicate section name '$sectionName'", startOfSectionName); |
83 } | 84 } |
84 if (allowedSections != null && !allowedSections.contains(sectionName)) { | 85 if (allowedSections != null && !allowedSections.contains(sectionName)) { |
85 error("Unrecognized section name '$sectionName'", startOfSectionName); | 86 error("Unrecognized section name '$sectionName'", startOfSectionName); |
86 } | 87 } |
87 result[sectionName] = currentSection; | 88 result[sectionName] = currentSection; |
88 } else { | 89 } else { |
89 // Property line | 90 // Property line |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return provider.readFromUri(location).then((contents) { | 134 return provider.readFromUri(location).then((contents) { |
134 if (contents is String) { | 135 if (contents is String) { |
135 contents = contents.codeUnits; | 136 contents = contents.codeUnits; |
136 } | 137 } |
137 return libraryMappings( | 138 return libraryMappings( |
138 parseIni(contents, | 139 parseIni(contents, |
139 allowedSections: allowedSections, sourceUri: location), | 140 allowedSections: allowedSections, sourceUri: location), |
140 location); | 141 location); |
141 }); | 142 }); |
142 } | 143 } |
OLD | NEW |