MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / parsePrimaryExpr

Method parsePrimaryExpr

extern/cloop/src/cloop/Parser.cpp:418–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416}
417
418Expr* Parser::parsePrimaryExpr()
419{
420 lexer->getToken(token);
421
422 switch (token.type)
423 {
424 case Token::TYPE_BOOLEAN_LITERAL:
425 return new BooleanLiteralExpr(token.text == "true");
426
427 case Token::TYPE_INT_LITERAL:
428 {
429 const char* p = token.text.c_str();
430 size_t len = strlen(p);
431 int base = len > 2 && tolower(p[1]) == 'x' ? 16 : 10;
432 long long val = strtoll(p, NULL, base);
433
434 return new IntLiteralExpr((int) val, base == 16);
435 }
436
437 case Token::TYPE_IDENTIFIER:
438 {
439 string text = token.text;
440
441 if (lexer->getToken(token).type == Token::TYPE_DOUBLE_COLON)
442 {
443 getToken(token, Token::TYPE_IDENTIFIER);
444 map<string, BaseType*>::iterator it = typesByName.find(text);
445
446 if (it == typesByName.end() || it->second->type != BaseType::TYPE_INTERFACE)
447 error(token, string("Interface '") + text + "' not found.");
448
449 return new ConstantExpr(static_cast<Interface*>(it->second), token.text);
450 }
451 else
452 {
453 lexer->pushToken(token);
454 return new ConstantExpr(interface, text);
455 }
456 }
457
458 case Token::TYPE_DOUBLE_COLON:
459 getToken(token, Token::TYPE_IDENTIFIER);
460 return new ConstantExpr(nullptr, token.text);
461
462 default:
463 syntaxError(token);
464 return NULL; // warning
465 }
466}
467
468void Parser::checkType(TypeRef& typeRef)
469{

Callers

nothing calls this directly

Calls 6

pushTokenMethod · 0.80
getTokenFunction · 0.50
errorFunction · 0.50
c_strMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected