| 1150 | } |
| 1151 | |
| 1152 | void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList &tokenList) |
| 1153 | { |
| 1154 | // assembler code.. |
| 1155 | for (simplecpp::Token *tok = tokenList.front(); tok; tok = tok->next) { |
| 1156 | if (tok->op != '#') |
| 1157 | continue; |
| 1158 | if (sameline(tok, tok->previousSkipComments())) |
| 1159 | continue; |
| 1160 | |
| 1161 | const simplecpp::Token * const tok2 = tok->nextSkipComments(); |
| 1162 | if (!tok2 || !sameline(tok, tok2) || tok2->str() != "pragma") |
| 1163 | continue; |
| 1164 | |
| 1165 | const simplecpp::Token * const tok3 = tok2->nextSkipComments(); |
| 1166 | if (!tok3 || !sameline(tok, tok3) || tok3->str() != "asm") |
| 1167 | continue; |
| 1168 | |
| 1169 | const simplecpp::Token *endasm = tok3; |
| 1170 | bool foundEndasm = false; |
| 1171 | while ((endasm = endasm->next) != nullptr) { |
| 1172 | if (endasm->op != '#' || sameline(endasm,endasm->previousSkipComments())) |
| 1173 | continue; |
| 1174 | const simplecpp::Token * const endasm2 = endasm->nextSkipComments(); |
| 1175 | if (!endasm2 || !sameline(endasm, endasm2) || endasm2->str() != "pragma") |
| 1176 | continue; |
| 1177 | const simplecpp::Token * const endasm3 = endasm2->nextSkipComments(); |
| 1178 | if (!endasm3 || !sameline(endasm2, endasm3) || endasm3->str() != "endasm") |
| 1179 | continue; |
| 1180 | while (sameline(endasm,endasm3)) |
| 1181 | endasm = endasm->next; |
| 1182 | foundEndasm = true; |
| 1183 | break; |
| 1184 | } |
| 1185 | |
| 1186 | if (!foundEndasm) |
| 1187 | throw InternalError(nullptr, "syntax error: missing #pragma endasm", InternalError::SYNTAX); |
| 1188 | |
| 1189 | const simplecpp::Token * const tok4 = tok3->next; |
| 1190 | tok->setstr("asm"); |
| 1191 | const_cast<simplecpp::Token *>(tok2)->setstr("("); |
| 1192 | const_cast<simplecpp::Token *>(tok3)->setstr(")"); |
| 1193 | const_cast<simplecpp::Token *>(tok4)->setstr(";"); |
| 1194 | while (tok4->next != endasm) |
| 1195 | tokenList.deleteToken(tok4->next); |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | void Preprocessor::addRemarkComments(const simplecpp::TokenList &tokens, std::vector<RemarkComment> &remarkComments) const |
nothing calls this directly
no test coverage detected