Skip to content

Instantly share code, notes, and snippets.

@mingodad
Last active May 29, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingodad/e9ccc835021f9004ef9d82d178c0f460 to your computer and use it in GitHub Desktop.
Save mingodad/e9ccc835021f9004ef9d82d178c0f460 to your computer and use it in GitHub Desktop.
GCCGO __FILE__ and __LINE__ builtin constants
// Pick up an identifier.
Token
Lex::gather_identifier()
{
...
if (has_non_ascii_char)
return Token::make_identifier_token(buf, is_exported, location);
else
{
Keyword code = keywords.keyword_to_code(pstart, p - pstart);
if (code == KEYWORD_INVALID)
{
buf.assign(pstart, p - pstart);
if(buf.size() > 1 && buf[0] == '_')
{
if(buf == "__LINE__")
{
mpz_t val;
mpz_init_set_ui(val, this->lineno_);
Token ret = Token::make_integer_token(val, location);
mpz_clear(val);
return ret;
}
else if(buf == "__FILE__")
{
buf = this->input_file_name_;
return Token::make_string_token(buf, location);
}
}
return Token::make_identifier_token(buf,
is_exported, location);
}
else
{
switch (code)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment