[LinkerScript] parse OUTPUT_FORMAT : treat quotedStrings as identifier

llvm-svn: 202166
This commit is contained in:
Shankar Easwaran 2014-02-25 17:02:54 +00:00
parent 18583d71e8
commit a328344367
3 changed files with 10 additions and 11 deletions

View File

@ -37,7 +37,6 @@ public:
eof,
identifier,
comma,
quotedString,
l_paren,
r_paren,
kw_entry,

View File

@ -29,7 +29,6 @@ void Token::dump(raw_ostream &os) const {
CASE(kw_group)
CASE(kw_output_format)
CASE(kw_output_arch)
CASE(quotedString)
CASE(comma)
CASE(l_paren)
CASE(r_paren)
@ -106,7 +105,8 @@ void Lexer::lex(Token &tok) {
_buffer = _buffer.drop_front();
return;
default:
// Quoted strings ?
// Handle quoted strings. They are treated as identifiers for
// simplicity.
if ((_buffer[0] == '\"') || (_buffer[0] == '\'')) {
char c = _buffer[0];
_buffer = _buffer.drop_front();
@ -114,7 +114,7 @@ void Lexer::lex(Token &tok) {
if (quotedStringEnd == StringRef::npos || quotedStringEnd == 0)
break;
StringRef word = _buffer.substr(0, quotedStringEnd);
tok = Token(word, Token::quotedString);
tok = Token(word, Token::identifier);
_buffer = _buffer.drop_front(quotedStringEnd + 1);
return;
}
@ -238,8 +238,8 @@ OutputFormat *Parser::parseOutputFormat() {
if (!expectAndConsume(Token::l_paren, "expected ("))
return nullptr;
if (_tok._kind != Token::quotedString && _tok._kind != Token::identifier) {
error(_tok, "Expected identifier/string in OUTPUT_FORMAT.");
if (_tok._kind != Token::identifier) {
error(_tok, "Expected identifier in OUTPUT_FORMAT.");
return nullptr;
}
@ -251,8 +251,8 @@ OutputFormat *Parser::parseOutputFormat() {
consumeToken();
else
break;
if (_tok._kind != Token::quotedString && _tok._kind != Token::identifier) {
error(_tok, "Expected identifier/string in OUTPUT_FORMAT.");
if (_tok._kind != Token::identifier) {
error(_tok, "Expected identifier in OUTPUT_FORMAT.");
return nullptr;
}
ret->addOutputFormat(_tok._range);

View File

@ -13,11 +13,11 @@ CHECK: identifier: i386:x86_64
CHECK: r_paren: )
CHECK: kw_output_format: OUTPUT_FORMAT
CHECK: l_paren: (
CHECK: quotedString: elf64-x86-64
CHECK: identifier: elf64-x86-64
CHECK: comma: ,
CHECK: quotedString: elf64-x86-64
CHECK: identifier: elf64-x86-64
CHECK: comma: ,
CHECK: quotedString: elf64-x86-64
CHECK: identifier: elf64-x86-64
CHECK: r_paren: )
CHECK: kw_group: GROUP
CHECK: l_paren: (