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

Function fxWithAttributes

xs/sources/xsSyntaxical.c:1104–1147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102}
1103
1104void fxWithAttributes(txParser* parser)
1105{
1106 txBoolean flag = 0;
1107 txString string;
1108 fxMatchToken(parser, XS_TOKEN_LEFT_BRACE);
1109 while (parser->states[0].token != XS_TOKEN_RIGHT_BRACE) {
1110 if ((gxTokenFlags[parser->states[0].token] & XS_TOKEN_IDENTIFIER_NAME))
1111 string = parser->states[0].symbol->string;
1112 else if (parser->states[0].token == XS_TOKEN_STRING)
1113 string = parser->states[0].string;
1114 else {
1115 fxReportParserError(parser, parser->states[0].line, "missing attribute key");
1116 break;
1117 }
1118 if (c_strcmp(string, "type"))
1119 fxReportParserError(parser, parser->states[0].line, "invalid attribute key");
1120 else if (flag)
1121 fxReportParserError(parser, parser->states[0].line, "duplicate attribute");
1122 fxGetNextToken(parser);
1123 if (parser->states[0].token != XS_TOKEN_COLON) {
1124 fxReportParserError(parser, parser->states[0].line, "missing :");
1125 break;
1126 }
1127 fxGetNextToken(parser);
1128 if (parser->states[0].token == XS_TOKEN_STRING)
1129 string = parser->states[0].string;
1130 else {
1131 fxReportParserError(parser, parser->states[0].line, "missing attribute value");
1132 break;
1133 }
1134 if (c_strcmp(string, "json"))
1135 fxReportParserError(parser, parser->states[0].line, "invalid attribute value");
1136 flag = 1;
1137 fxGetNextToken(parser);
1138 if (parser->states[0].token != XS_TOKEN_COMMA)
1139 break;
1140 fxGetNextToken(parser);
1141 }
1142 fxMatchToken(parser, XS_TOKEN_RIGHT_BRACE);
1143 if (flag)
1144 fxPushSymbol(parser, parser->jsonSymbol);
1145 else
1146 fxPushNULL(parser);
1147}
1148
1149void fxProgram(txParser* parser)
1150{

Callers 2

fxExportDeclarationFunction · 0.85
fxImportDeclarationFunction · 0.85

Calls 5

fxMatchTokenFunction · 0.85
fxReportParserErrorFunction · 0.85
fxGetNextTokenFunction · 0.85
fxPushSymbolFunction · 0.85
fxPushNULLFunction · 0.85

Tested by

no test coverage detected