MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / tokenize

Function tokenize

arch/powerpc/assembler.cpp:2237–2324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2235};
2236
2237int tokenize(string src, vector<token>& result, string& err)
2238{
2239 int rc = -1, n=0;
2240 char *endptr;
2241 const char *inbuf = src.c_str();
2242
2243 result.clear();
2244
2245 /* grab opcode */
2246 while(isalnum(inbuf[n]))
2247 n++;
2248 result.push_back({TT_OPC, 0, string(inbuf, n)});
2249 inbuf += n;
2250
2251 /* loop over the rest */
2252 while(inbuf[0]) {
2253 char c = inbuf[0];
2254 char d = inbuf[1];
2255
2256 /* skip spaces */
2257 if(c == ' ') {
2258 inbuf += 1;
2259 }
2260 /* GPR's */
2261 else if(c=='r') {
2262 uint32_t value = strtoul(inbuf+1, &endptr, 10);
2263 result.push_back({TT_GPR, value, ""});
2264 inbuf = endptr;
2265 }
2266 /* vs registers */
2267 else if(c=='v' && inbuf[1]=='s') {
2268 uint32_t value = strtoul(inbuf+2, &endptr, 10);
2269 result.push_back({TT_VSREG, value, ""});
2270 inbuf = endptr;
2271 }
2272 /* v registers */
2273 else if(c=='v') {
2274 uint32_t value = strtoul(inbuf+1, &endptr, 10);
2275 result.push_back({TT_VREG, value, ""});
2276 inbuf = endptr;
2277 }
2278 /* f registers */
2279 else if(c=='f') {
2280 uint32_t value = strtoul(inbuf+1, &endptr, 10);
2281 result.push_back({TT_FREG, value, ""});
2282 inbuf = endptr;
2283 }
2284 /* cr registers */
2285 else if(c=='c' && inbuf[1]=='r') {
2286 uint32_t value = strtoul(inbuf+2, &endptr, 10);
2287 result.push_back({TT_CREG, value, ""});
2288 inbuf = endptr;
2289 }
2290 /* FLAGS: lt, gt, eq, so */
2291 else if((c=='l' && d=='t') || (c=='g' && d=='t') ||
2292 (c=='e' && d=='q') || (c=='s' && d=='o')) {
2293
2294 result.push_back({TT_FLAG, 0, string(inbuf, 2)});

Callers 2

scoreFunction · 0.85
assemble_singleFunction · 0.85

Calls 3

c_strMethod · 0.80
push_backMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected