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 part of scanner; | 5 part of scanner; |
6 | 6 |
7 class ScannerTask extends CompilerTask { | 7 class ScannerTask extends CompilerTask { |
8 ScannerTask(Compiler compiler) : super(compiler); | 8 ScannerTask(Compiler compiler) : super(compiler); |
9 String get name => 'Scanner'; | 9 String get name => 'Scanner'; |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 } | 21 } |
22 | 22 |
23 void scan(CompilationUnitElement compilationUnit) { | 23 void scan(CompilationUnitElement compilationUnit) { |
24 measure(() { | 24 measure(() { |
25 scanElements(compilationUnit); | 25 scanElements(compilationUnit); |
26 }); | 26 }); |
27 } | 27 } |
28 | 28 |
29 void scanElements(CompilationUnitElement compilationUnit) { | 29 void scanElements(CompilationUnitElement compilationUnit) { |
30 Script script = compilationUnit.script; | 30 Script script = compilationUnit.script; |
31 Token tokens = new StringScanner(script.text, | 31 Token tokens = new Scanner(script.file, |
32 includeComments: compiler.preserveComments).tokenize(); | 32 includeComments: compiler.preserveComments).tokenize(); |
33 if (compiler.preserveComments) { | 33 if (compiler.preserveComments) { |
34 tokens = compiler.processAndStripComments(tokens); | 34 tokens = compiler.processAndStripComments(tokens); |
35 } | 35 } |
36 compiler.dietParser.dietParse(compilationUnit, tokens); | 36 compiler.dietParser.dietParse(compilationUnit, tokens); |
37 } | 37 } |
38 | 38 |
39 /** | |
40 * Returns the tokens for the [source]. | |
41 * | |
42 * The [StringScanner] implementation works on strings that end with a '0' | |
43 * value ('\x00'). If [source] does not with '0', the string is copied before | |
ngeoffray
2013/10/18 10:19:37
not *end* with
lukas
2013/10/24 16:48:36
Done.
| |
44 * scanning. | |
45 */ | |
39 Token tokenize(String source) { | 46 Token tokenize(String source) { |
40 return measure(() { | 47 return measure(() { |
41 return new StringScanner(source, includeComments: false).tokenize(); | 48 return new StringScanner.fromString(source, includeComments: false) |
49 .tokenize(); | |
42 }); | 50 }); |
43 } | 51 } |
44 } | 52 } |
45 | 53 |
46 class DietParserTask extends CompilerTask { | 54 class DietParserTask extends CompilerTask { |
47 DietParserTask(Compiler compiler) : super(compiler); | 55 DietParserTask(Compiler compiler) : super(compiler); |
48 final String name = 'Diet Parser'; | 56 final String name = 'Diet Parser'; |
49 | 57 |
50 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | 58 dietParse(CompilationUnitElement compilationUnit, Token tokens) { |
51 measure(() { | 59 measure(() { |
52 Function idGenerator = compiler.getNextFreeClassId; | 60 Function idGenerator = compiler.getNextFreeClassId; |
53 ElementListener listener = | 61 ElementListener listener = |
54 new ElementListener(compiler, compilationUnit, idGenerator); | 62 new ElementListener(compiler, compilationUnit, idGenerator); |
55 PartialParser parser = new PartialParser(listener); | 63 PartialParser parser = new PartialParser(listener); |
56 parser.parseUnit(tokens); | 64 parser.parseUnit(tokens); |
57 }); | 65 }); |
58 } | 66 } |
59 } | 67 } |
OLD | NEW |