MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxImportDeclaration

Function fxImportDeclaration

xs/sources/xsSyntaxical.c:997–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

995
996
997void fxImportDeclaration(txParser* parser)
998{
999 txBoolean asFlag = 1;
1000 txBoolean fromFlag = 0;
1001 txInteger count = parser->nodeCount;
1002 fxMatchToken(parser, XS_TOKEN_IMPORT);
1003 if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
1004 fxPushSymbol(parser, parser->defaultSymbol);
1005 fxPushSymbol(parser, parser->states[0].symbol);
1006 fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, parser->states[0].line);
1007 fxGetNextToken(parser);
1008 if (parser->states[0].token == XS_TOKEN_COMMA)
1009 fxGetNextToken(parser);
1010 else
1011 asFlag = 0;
1012 fromFlag = 1;
1013 }
1014 if (asFlag) {
1015 if (parser->states[0].token == XS_TOKEN_MULTIPLY) {
1016 fxGetNextToken(parser);
1017 if (fxIsKeyword(parser, parser->asSymbol)) {
1018 fxGetNextToken(parser);
1019 if (parser->states[0].token == XS_TOKEN_IDENTIFIER) {
1020 fxPushNULL(parser);
1021 fxPushSymbol(parser, parser->states[0].symbol);
1022 fxPushNodeStruct(parser, 2, XS_TOKEN_SPECIFIER, parser->states[0].line);
1023 fxGetNextToken(parser);
1024 }
1025 else {
1026 fxReportParserError(parser, parser->states[0].line, "missing identifier");
1027 }
1028 }
1029 else {
1030 fxReportParserError(parser, parser->states[0].line, "missing as");
1031 }
1032 fromFlag = 1;
1033 }
1034 else if (parser->states[0].token == XS_TOKEN_LEFT_BRACE) {
1035 fxSpecifiers(parser);
1036 fromFlag = 1;
1037 }
1038 }
1039 fxPushNodeList(parser, parser->nodeCount - count);
1040 if (fromFlag) {
1041 if (fxIsKeyword(parser, parser->fromSymbol)) {
1042 fxGetNextToken(parser);
1043 if (parser->states[0].token == XS_TOKEN_STRING) {
1044 fxPushStringNode(parser, parser->states[0].stringLength, parser->states[0].string, parser->states[0].line);
1045 fxGetNextToken(parser);
1046 }
1047 else {
1048 fxPushNULL(parser);
1049 fxReportParserError(parser, parser->states[0].line, "missing module");
1050 }
1051 }
1052 else {
1053 fxPushNULL(parser);
1054 fxReportParserError(parser, parser->states[0].line, "missing from");

Callers 1

fxModuleFunction · 0.85

Calls 12

fxMatchTokenFunction · 0.85
fxPushSymbolFunction · 0.85
fxPushNodeStructFunction · 0.85
fxGetNextTokenFunction · 0.85
fxPushNULLFunction · 0.85
fxReportParserErrorFunction · 0.85
fxSpecifiersFunction · 0.85
fxPushNodeListFunction · 0.85
fxPushStringNodeFunction · 0.85
fxWithAttributesFunction · 0.85
fxSemicolonFunction · 0.85
fxIsKeywordFunction · 0.70

Tested by

no test coverage detected