Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(941)

Unified Diff: dart/frog/leg/scanner/keyword.dart

Issue 8805008: Various scanner fixes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased and update language.status Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/frog/leg/scanner/characters.dart ('k') | dart/frog/leg/scanner/scanner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/scanner/keyword.dart
diff --git a/dart/frog/leg/scanner/keyword.dart b/dart/frog/leg/scanner/keyword.dart
index 74e6f357e8b07b6264bee1ed0c3d6eac39afb7f7..ab9324edf489726bd108bb5c6b20d364524ca623 100644
--- a/dart/frog/leg/scanner/keyword.dart
+++ b/dart/frog/leg/scanner/keyword.dart
@@ -161,11 +161,16 @@ class KeywordState {
assert(length != 0);
int chunk = 0;
int chunkStart = -1;
+ bool isLeaf = false;
for (int i = offset; i < offset + length; i++) {
+ if (strings[i].length == start) {
+ isLeaf = true;
+ }
if (strings[i].length > start) {
int c = strings[i].charCodeAt(start);
if (chunk != c) {
if (chunkStart != -1) {
+ assert(result[chunk - $a] === null);
result[chunk - $a] = computeKeywordStateTable(start + 1, strings,
chunkStart,
i - chunkStart);
@@ -176,6 +181,7 @@ class KeywordState {
}
}
if (chunkStart != -1) {
+ assert(result[chunk - $a] === null);
result[chunk - $a] =
computeKeywordStateTable(start + 1, strings, chunkStart,
offset + length - chunkStart);
@@ -183,7 +189,11 @@ class KeywordState {
assert(length == 1);
return new LeafKeywordState(strings[offset]);
}
- return new ArrayKeywordState(result);
+ if (isLeaf) {
+ return new ArrayKeywordState(result, strings[offset]);
+ } else {
+ return new ArrayKeywordState(result, null);
+ }
}
}
@@ -192,24 +202,27 @@ class KeywordState {
*/
class ArrayKeywordState extends KeywordState {
final List<KeywordState> table;
+ final Keyword keyword;
- ArrayKeywordState(List<KeywordState> this.table);
+ ArrayKeywordState(List<KeywordState> this.table, String syntax)
+ : keyword = (syntax === null) ? null : Keyword.keywords[syntax];
bool isLeaf() => false;
KeywordState next(int c) => table[c - $a];
- Keyword get keyword() {
- throw "should not be called";
- }
-
String toString() {
StringBuffer sb = new StringBuffer();
sb.add("[");
+ if (keyword !== null) {
+ sb.add("*");
+ sb.add(keyword);
+ sb.add(" ");
+ }
List<KeywordState> foo = table;
for (int i = 0; i < foo.length; i++) {
if (foo[i] != null) {
- sb.add("${i + $a}: ${foo[i]}; ");
+ sb.add("${new String.fromCharCodes([i + $a])}: ${foo[i]}; ");
}
}
sb.add("]");
@@ -221,7 +234,7 @@ class ArrayKeywordState extends KeywordState {
* A state that has no outgoing transitions.
*/
class LeafKeywordState extends KeywordState {
- Keyword keyword;
+ final Keyword keyword;
LeafKeywordState(String syntax) : keyword = Keyword.keywords[syntax];
« no previous file with comments | « dart/frog/leg/scanner/characters.dart ('k') | dart/frog/leg/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698