// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a class TagStack { List _stack; TagStack(var elem) : _stack = [] { _stack.add(elem); } void push(var elem) { _stack.add(elem); } ASTNode pop() { return _stack.removeLast(); } top() { return _stack.last; } } // TODO(terry): Cleanup returning errors from CSS to common World error // handler. class ErrorMsgRedirector { void displayError(String msg) { if (world.printHandler != null) { world.printHandler(msg); } else { print("Unhandler Error: ${msg}"); } world.errors++; } } /** * A simple recursive descent parser for HTML. */ class Parser { Tokenizer tokenizer; var _fs; // If non-null filesystem to read files. final SourceFile source; Token _previousToken; Token _peekToken; PrintHandler printHandler; Parser(this.source, [int start = 0, this._fs = null]) { tokenizer = new Tokenizer(source, true, start); _peekToken = tokenizer.next(); _previousToken = null; } // Main entry point for parsing an entire HTML file. List