Skip to content

Commit

Permalink
[TEMPORARY] JavaScript: prototyping of code handling 'export default'
Browse files Browse the repository at this point in the history
Just for evaluating vue parser.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 20, 2017
1 parent ce2225c commit 8330eea
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions parsers/jscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));
Expand Down

0 comments on commit 8330eea

Please sign in to comment.