| Index: dart/lib/compiler/implementation/scanner/listener.dart
|
| diff --git a/dart/lib/compiler/implementation/scanner/listener.dart b/dart/lib/compiler/implementation/scanner/listener.dart
|
| index 3dac17a006e2470891ce2a0fe67f36d981615dc0..da74a9c70226cbfc6b9aad571c0db2899cab3d42 100644
|
| --- a/dart/lib/compiler/implementation/scanner/listener.dart
|
| +++ b/dart/lib/compiler/implementation/scanner/listener.dart
|
| @@ -47,12 +47,6 @@ class Listener {
|
| Token endToken) {
|
| }
|
|
|
| - void beginCombinators(Token token) {
|
| - }
|
| -
|
| - void endCombinators(int count) {
|
| - }
|
| -
|
| void beginDoWhileStatement(Token token) {
|
| }
|
|
|
| @@ -60,12 +54,6 @@ class Listener {
|
| Token endToken) {
|
| }
|
|
|
| - void beginExport(Token token) {
|
| - }
|
| -
|
| - void endExport(Token exportKeyword, Token semicolon) {
|
| - }
|
| -
|
| void beginExpressionStatement(Token token) {
|
| }
|
|
|
| @@ -149,30 +137,12 @@ class Listener {
|
| void endFunctionTypeAlias(Token typedefKeyword, Token endToken) {
|
| }
|
|
|
| - void beginHide(Token hideKeyword) {
|
| - }
|
| -
|
| - void endHide(Token hideKeyword) {
|
| - }
|
| -
|
| - void beginIdentifierList(Token token) {
|
| - }
|
| -
|
| - void endIdentifierList(int count) {
|
| - }
|
| -
|
| void beginIfStatement(Token token) {
|
| }
|
|
|
| void endIfStatement(Token ifToken, Token elseToken) {
|
| }
|
|
|
| - void beginImport(Token importKeyword) {
|
| - }
|
| -
|
| - void endImport(Token importKeyword, Token asKeyword, Token semicolon) {
|
| - }
|
| -
|
| void beginInitializedIdentifier(Token token) {
|
| }
|
|
|
| @@ -210,12 +180,6 @@ class Listener {
|
| void endLabeledStatement(int labelCount) {
|
| }
|
|
|
| - void beginLibraryName(Token token) {
|
| - }
|
| -
|
| - void endLibraryName(Token libraryKeyword, Token semicolon) {
|
| - }
|
| -
|
| void beginLiteralMapEntry(Token token) {
|
| }
|
|
|
| @@ -269,12 +233,6 @@ class Listener {
|
| void endSend(Token token) {
|
| }
|
|
|
| - void beginShow(Token showKeyword) {
|
| - }
|
| -
|
| - void endShow(Token showKeyword) {
|
| - }
|
| -
|
| void beginSwitchStatement(Token token) {
|
| }
|
|
|
| @@ -611,75 +569,29 @@ class ElementListener extends Listener {
|
| return node;
|
| }
|
|
|
| - bool allowLibraryTags() {
|
| - // Library tags are only allowed in the library file itself, not
|
| - // in sourced files.
|
| + bool allowScriptTags() {
|
| + // Script tags are only allowed in the library file itself, not in
|
| + // sourced files.
|
| LibraryElement library = compilationUnitElement.getLibrary();
|
| - return compilationUnitElement.localMembers.isEmpty()
|
| - && library.entryCompilationUnit == compilationUnitElement;
|
| - }
|
| -
|
| - void endLibraryName(Token libraryKeyword, Token semicolon) {
|
| - Expression name = popNode();
|
| - addLibraryTag(new LibraryName(libraryKeyword, name));
|
| - }
|
| -
|
| - void endImport(Token importKeyword, Token asKeyword, Token semicolon) {
|
| - NodeList combinators = popNode();
|
| - Identifier prefix;
|
| - if (asKeyword !== null) {
|
| - prefix = popNode();
|
| - }
|
| - LiteralString uri = popLiteralString();
|
| - addLibraryTag(new Import(importKeyword, uri, prefix, combinators));
|
| - }
|
| -
|
| - void endExport(Token exportKeyword, Token semicolon) {
|
| - NodeList combinators = popNode();
|
| - LiteralString uri = popNode();
|
| - addLibraryTag(new Export(exportKeyword, uri, combinators));
|
| - }
|
| -
|
| - void endCombinators(int count) {
|
| - if (0 == count) {
|
| - pushNode(null);
|
| - } else {
|
| - pushNode(makeNodeList(count, null, null, " "));
|
| - }
|
| - }
|
| -
|
| - void endHide(Token hideKeyword) {
|
| - recoverableError('hide is not implemented', token: hideKeyword);
|
| - // TODO(ahe): Do not ignore.
|
| - }
|
| -
|
| - void endShow(Token showKeyword) {
|
| - recoverableError('show is not implemented', token: showKeyword);
|
| - // TODO(ahe): Do not ignore.
|
| - }
|
| -
|
| - void endIdentifierList(int count) {
|
| - pushNode(makeNodeList(count, null, null, " "));
|
| + return library.entryCompilationUnit == compilationUnitElement;
|
| }
|
|
|
| void endScriptTag(bool hasPrefix, Token beginToken, Token endToken) {
|
| - LiteralString prefix = null;
|
| + StringNode prefix = null;
|
| Identifier argumentName = null;
|
| if (hasPrefix) {
|
| prefix = popLiteralString();
|
| argumentName = popNode();
|
| }
|
| - LiteralString firstArgument = popLiteralString();
|
| + StringNode firstArgument = popLiteralString();
|
| Identifier tag = popNode();
|
| + if (!allowScriptTags()) {
|
| + // Only allow script tags in the entry compilation unit.
|
| + listener.cancel("script tags not allowed here", node: tag);
|
| + }
|
| ScriptTag scriptTag = new ScriptTag(tag, firstArgument, argumentName,
|
| prefix, beginToken, endToken);
|
| - if (const SourceString('import') == tag.source ||
|
| - const SourceString('source') == tag.source ||
|
| - const SourceString('library') == tag.source) {
|
| - addScriptTag(scriptTag);
|
| - } else {
|
| - recoverableError('unknown tag: ${tag.source.slowToString()}', node: tag);
|
| - }
|
| + addScriptTag(scriptTag);
|
| }
|
|
|
| void endMetadata(Token beginToken, Token endToken) {
|
| @@ -941,14 +853,6 @@ class ElementListener extends Listener {
|
| }
|
|
|
| void addScriptTag(ScriptTag tag) {
|
| - // TODO(ahe): Remove this method.
|
| - addLibraryTag(tag.toLibraryTag());
|
| - }
|
| -
|
| - void addLibraryTag(LibraryTag tag) {
|
| - if (!allowLibraryTags()) {
|
| - recoverableError('library tags not allowed here', node: tag);
|
| - }
|
| compilationUnitElement.getLibrary().addTag(tag, listener);
|
| }
|
|
|
|
|