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

Side by Side Diff: utils/template/parser.dart

Issue 10399010: Fixed breakage in template utility now that statics aren't inherited. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated readme Created 8 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/template/codegen.dart ('k') | utils/template/tokenizer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 3
4 class TagStack { 4 class TagStack {
5 List<ASTNode> _stack; 5 List<ASTNode> _stack;
6 6
7 TagStack(var elem) : _stack = [] { 7 TagStack(var elem) : _stack = [] {
8 _stack.add(elem); 8 _stack.add(elem);
9 } 9 }
10 10
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 SourceFile.IN_MEMORY_FILE, cssSource.text), start); 406 SourceFile.IN_MEMORY_FILE, cssSource.text), start);
407 407
408 css.Stylesheet stylesheet = parser.parse(false, new ErrorMsgRedirector()); 408 css.Stylesheet stylesheet = parser.parse(false, new ErrorMsgRedirector());
409 409
410 var lastParsedChar = parser.tokenizer.startIndex; 410 var lastParsedChar = parser.tokenizer.startIndex;
411 411
412 lastCSSIndexParsed = lastParsedChar; 412 lastCSSIndexParsed = lastParsedChar;
413 413
414 return stylesheet; 414 return stylesheet;
415 } catch (final cssParseException) { 415 } catch (final cssParseException) {
416 // TODO(terry): Need SourceSpan from CSS parser to pass onto _error. 416 // TODO(terry): Need SourceSpan from CSS parser to pass onto _error.
417 _error("Unexcepted CSS error: ${cssParseException.toString()}"); 417 _error("Unexcepted CSS error: ${cssParseException.toString()}");
418 } 418 }
419 } 419 }
420 420
421 /* TODO(terry): Assume template { }, single close curley as a text node 421 /* TODO(terry): Assume template { }, single close curley as a text node
422 * inside of the template would need to be escaped maybe \} 422 * inside of the template would need to be escaped maybe \}
423 */ 423 */
424 processHTML(TemplateElement root) { 424 processHTML(TemplateElement root) {
425 assert(root.isFragment); 425 assert(root.isFragment);
426 TagStack stack = new TagStack(root); 426 TagStack stack = new TagStack(root);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 case "with": 528 case "with":
529 case "if": 529 case "if":
530 case "else": 530 case "else":
531 break; 531 break;
532 default: 532 default:
533 _error('Unknown command \${#${commandName}}'); 533 _error('Unknown command \${#${commandName}}');
534 } 534 }
535 var elem = stack.pop(); 535 var elem = stack.pop();
536 if (elem is TemplateEachCommand && 536 if (elem is TemplateEachCommand &&
537 commandName.name == "each") { 537 commandName.name == "each") {
538 538
539 } else if (elem is TemplateWithCommand && 539 } else if (elem is TemplateWithCommand &&
540 commandName.name == "with") { 540 commandName.name == "with") {
541 541
542 } /*else if (elem is TemplateIfCommand && commandName == "if") { 542 } /*else if (elem is TemplateIfCommand && commandName == "if") {
543 543
544 } 544 }
545 */else { 545 */else {
546 String expectedCmd; 546 String expectedCmd;
547 if (elem is TemplateEachCommand) { 547 if (elem is TemplateEachCommand) {
548 expectedCmd = "\${/each}"; 548 expectedCmd = "\${/each}";
549 } /* TODO(terry): else other commands as well */ 549 } /* TODO(terry): else other commands as well */
550 _error('mismatched command expected ${expectedCmd} got...'); 550 _error('mismatched command expected ${expectedCmd} got...');
551 return; 551 return;
552 } 552 }
553 _eat(TokenKind.RBRACE); 553 _eat(TokenKind.RBRACE);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 642 }
643 643
644 return attrs; 644 return attrs;
645 } 645 }
646 646
647 identifier() { 647 identifier() {
648 var tok = _next(); 648 var tok = _next();
649 if (!TokenKind.isIdentifier(tok.kind)) { 649 if (!TokenKind.isIdentifier(tok.kind)) {
650 _error('expected identifier, but found $tok', tok.span); 650 _error('expected identifier, but found $tok', tok.span);
651 } 651 }
652 652
653 return new Identifier(tok.text, _makeSpan(tok.start)); 653 return new Identifier(tok.text, _makeSpan(tok.start));
654 } 654 }
655 655
656 List<ASTNode> processTextNodes() { 656 List<ASTNode> processTextNodes() {
657 // May contain TemplateText and TemplateExpression. 657 // May contain TemplateText and TemplateExpression.
658 List<ASTNode> nodes = []; 658 List<ASTNode> nodes = [];
659 659
660 int start = _peekToken.start; 660 int start = _peekToken.start;
661 bool inExpression = false; 661 bool inExpression = false;
662 StringBuffer stringValue = new StringBuffer(); 662 StringBuffer stringValue = new StringBuffer();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 711 }
712 712
713 if (stringValue.length > 0) { 713 if (stringValue.length > 0) {
714 nodes.add(new TemplateText(stringValue.toString(), _makeSpan(start))); 714 nodes.add(new TemplateText(stringValue.toString(), _makeSpan(start)));
715 } 715 }
716 716
717 return nodes; 717 return nodes;
718 } 718 }
719 719
720 } 720 }
OLDNEW
« no previous file with comments | « utils/template/codegen.dart ('k') | utils/template/tokenizer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698