// Parse ENTRY(ident) Entry *Parser::parseEntry() { assert(_tok._kind == Token::kw_entry && "Expected ENTRY!"); consumeToken(); if (!expectAndConsume(Token::l_paren, "expected (")) return nullptr; if (_tok._kind != Token::identifier) { error(_tok, "expected identifier in ENTRY"); return nullptr; } StringRef entryName(_tok._range); consumeToken(); if (!expectAndConsume(Token::r_paren, "expected )")) return nullptr; return new (_alloc) Entry(entryName); }
// NAME [outputPath] [BASE=address] bool Parser::parseName(std::string &outputPath, uint64_t &baseaddr) { consumeToken(); if (_tok._kind == Kind::identifier) { outputPath = _tok._range; } else { outputPath = ""; ungetToken(); return true; } consumeToken(); if (_tok._kind == Kind::kw_base) { if (!expectAndConsume(Kind::equal, "'=' expected")) return false; if (!consumeTokenAsInt(baseaddr)) return false; } else { ungetToken(); baseaddr = 0; } return true; }