QmlJS: Support .import directives in js files.

* Allow .import...
* Fix parsing of JS files when using Lexer::scanDirectives()
* Clean up ImportInfo construction.
* Rename ImportInfo::id to ImportInfo::as.

Change-Id: I888da248f06dc6184db99aa74c3b50d7f2f5e491
Reviewed-on: http://codereview.qt-project.org/5625
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Christian Kamm
2011-09-27 15:12:22 +02:00
parent faa792f3cd
commit 82cbd0a974
10 changed files with 186 additions and 95 deletions

View File

@@ -138,7 +138,20 @@ bool Parser::parse(int startToken)
token_buffer[0].token = startToken;
first_token = &token_buffer[0];
last_token = &token_buffer[1];
if (startToken == T_FEED_JS_PROGRAM) {
Directives ignoreDirectives;
Directives *directives = driver->directives();
if (!directives)
directives = &ignoreDirectives;
lexer->scanDirectives(directives);
token_buffer[1].token = lexer->tokenKind();
token_buffer[1].dval = lexer->tokenValue();
token_buffer[1].loc = location(lexer);
token_buffer[1].spell = lexer->tokenSpell();
last_token = &token_buffer[2];
} else {
last_token = &token_buffer[1];
}
tos = -1;
program = 0;