/*
* This file is part of cparser.
- * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
*/
#include <config.h>
#include "symbol_t.h"
#include <assert.h>
-#include <stdio.h>
-#include "symbol.h"
#include "lang_features.h"
#include "adt/array.h"
#include "adt/error.h"
#include "adt/util.h"
+#include "symbol_table.h"
symbol_t *token_symbols[T_LAST_TOKEN];
-const source_position_t builtin_source_position = { "<built-in>", 0, 0, true };
+const position_t builtin_position = { "<built-in>", 0, 0, true };
static token_kind_t last_id;
void init_tokens(void)
{
+ static bool tokens_initialized = false;
+ if (tokens_initialized)
+ return;
+ tokens_initialized = true;
+
memset(token_symbols, 0, T_LAST_TOKEN * sizeof(token_symbols[0]));
#define T(mode,x,str,val) register_token(mode, x, str);
-#define TS(x,str,val) intern_register_token(x, str);
#include "tokens.inc"
-#undef TS
#undef T
#define T(token) register_pp_token(TP_##token, #token);
char const *get_string_encoding_prefix(string_encoding_t const enc)
{
switch (enc) {
- case STRING_ENCODING_CHAR: return "";
- case STRING_ENCODING_WIDE: return "L";
+ case STRING_ENCODING_CHAR: return "";
+ case STRING_ENCODING_CHAR16: return "u";
+ case STRING_ENCODING_CHAR32: return "U";
+ case STRING_ENCODING_UTF8: return "u8";
+ case STRING_ENCODING_WIDE: return "L";
}
panic("invalid string encoding");
}
val = token->base.symbol->string;
break;
- case T_HEADERNAME:
case T_STRING_LITERAL:
delim = '"';
/* FALLTHROUGH */