From 8330eea19cc5f8b8d5c0b534ca8b07ca8c3e0ab4 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sat, 21 Oct 2017 06:46:56 +0900 Subject: [PATCH] [TEMPORARY] JavaScript: prototyping of code handling 'export default' Just for evaluating vue parser. Signed-off-by: Masatake YAMATO --- parsers/jscript.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/parsers/jscript.c b/parsers/jscript.c index 4e8c36488a..f2dfb45855 100644 --- a/parsers/jscript.c +++ b/parsers/jscript.c @@ -2192,6 +2192,26 @@ static bool parseLine (tokenInfo *const token, tokenInfo *const parent, bool is_ return is_terminated; } +static void parseExport (tokenInfo *const token) +{ + readToken (token); + + if (! (isType (token, TOKEN_KEYWORD) && (token->keyword == KEYWORD_default))) + return; + + tokenInfo *const parent = newToken (); + copyToken(parent, token, false); + + readToken (token); + if (!isType (token, TOKEN_OPEN_CURLY)) + goto out; + + parseMethods (token, parent, false); + + out: + deletePoolToken (parent); +} + static void parseJsFile (tokenInfo *const token) { JSCRIPT_DEBUG_ENTER(); @@ -2202,9 +2222,8 @@ static void parseJsFile (tokenInfo *const token) if (isType (token, TOKEN_KEYWORD) && token->keyword == KEYWORD_sap) parseUI5 (token); - else if (isType (token, TOKEN_KEYWORD) && (token->keyword == KEYWORD_export || - token->keyword == KEYWORD_default)) - /* skip those at top-level */; + if (isType (token, TOKEN_KEYWORD) && (token->keyword == KEYWORD_export)) + parseExport (token); else parseLine (token, NULL, false); } while (! isType (token, TOKEN_EOF));