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

Function fxProgram

xs/sources/xsSyntaxical.c:1149–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1147}
1148
1149void fxProgram(txParser* parser)
1150{
1151 txInteger count = parser->nodeCount;
1152 txInteger line = parser->states[0].line;
1153 txNode* node;
1154 while (parser->states[0].token != XS_TOKEN_EOF) {
1155 fxStatement(parser, -1);
1156 node = parser->root;
1157 if (!node || !node->description || (node->description->token != XS_TOKEN_STATEMENT))
1158 break;
1159 node = ((txStatementNode*)node)->expression;
1160 if (!node || !node->description || (node->description->token != XS_TOKEN_STRING))
1161 break;
1162 if (!(node->flags & mxStringEscapeFlag) && (c_strcmp(((txStringNode*)node)->value, "use strict") == 0)) {
1163 if (!(parser->flags & mxStrictFlag)) {
1164 parser->flags |= mxStrictFlag;
1165 if (parser->states[0].token == XS_TOKEN_IDENTIFIER)
1166 fxCheckStrictKeyword(parser);
1167 }
1168 }
1169 }
1170 while (parser->states[0].token != XS_TOKEN_EOF) {
1171 fxStatement(parser, -1);
1172 }
1173 count = parser->nodeCount - count;
1174 if (count > 1) {
1175 fxPushNodeList(parser, count);
1176 fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENTS, line);
1177 }
1178 else if (count == 0) {
1179 fxPushNodeStruct(parser, 0, XS_TOKEN_UNDEFINED, line);
1180 fxPushNodeStruct(parser, 1, XS_TOKEN_STATEMENT, line);
1181 }
1182 fxPushNodeStruct(parser, 1, XS_TOKEN_PROGRAM, line);
1183 if (parser->flags & mxFieldFlag)
1184 if (parser->flags & mxArgumentsFlag)
1185 fxReportParserError(parser, parser->states[0].line, "invalid arguments");
1186 parser->root->flags = parser->flags & mxStrictFlag;
1187}
1188
1189void fxBody(txParser* parser)
1190{

Callers 1

fxParserTreeFunction · 0.85

Calls 5

fxStatementFunction · 0.85
fxCheckStrictKeywordFunction · 0.85
fxPushNodeListFunction · 0.85
fxPushNodeStructFunction · 0.85
fxReportParserErrorFunction · 0.85

Tested by

no test coverage detected