return gstr;
}
-/*
- * note: never use gc_string_append on a string that has external references.
- * gsrc will be garbage collected immediately, and gstr might be.
- * Should only be used to append characters to a string literal or constant.
- */
-BT_HIDDEN
-struct gc_string *gc_string_append(struct ctf_scanner *scanner,
- struct gc_string *gstr,
- struct gc_string *gsrc)
-{
- size_t newlen = strlen(gsrc->s) + strlen(gstr->s) + 1;
- size_t alloclen;
-
- /* TODO: could be faster with find first bit or glib Gstring */
- /* sizeof long to account for malloc header (int or long ?) */
- for (alloclen = 8; alloclen < sizeof(long) + sizeof(*gstr) + newlen;
- alloclen *= 2);
-
- if (alloclen > gstr->alloclen) {
- struct gc_string *newgstr;
-
- newgstr = gc_string_alloc(scanner, newlen);
- strcpy(newgstr->s, gstr->s);
- strcat(newgstr->s, gsrc->s);
- bt_list_del(&gstr->gc);
- free(gstr);
- gstr = newgstr;
- } else {
- strcat(gstr->s, gsrc->s);
- }
- bt_list_del(&gsrc->gc);
- free(gsrc);
- return gstr;
-}
-
void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src)
{
lvalp->gs = gc_string_alloc(scanner, strlen(src) + 1);
*/
%expect 2
%start file
-%token STRING_LITERAL CHARACTER_LITERAL LSBRAC RSBRAC LPAREN RPAREN LBRAC RBRAC RARROW STAR PLUS MINUS LT GT TYPEASSIGN COLON SEMICOLON DOTDOTDOT DOT EQUAL COMMA CONST CHAR DOUBLE ENUM ENV EVENT FLOATING_POINT FLOAT INTEGER INT LONG SHORT SIGNED STREAM STRING STRUCT TRACE CALLSITE CLOCK TYPEALIAS TYPEDEF UNSIGNED VARIANT VOID _BOOL _COMPLEX _IMAGINARY DECIMAL_CONSTANT OCTAL_CONSTANT HEXADECIMAL_CONSTANT TOK_ALIGN
+%token INTEGER_LITERAL STRING_LITERAL CHARACTER_LITERAL LSBRAC RSBRAC LPAREN RPAREN LBRAC RBRAC RARROW STAR PLUS MINUS LT GT TYPEASSIGN COLON SEMICOLON DOTDOTDOT DOT EQUAL COMMA CONST CHAR DOUBLE ENUM ENV EVENT FLOATING_POINT FLOAT INTEGER INT LONG SHORT SIGNED STREAM STRING STRUCT TRACE CALLSITE CLOCK TYPEALIAS TYPEDEF UNSIGNED VARIANT VOID _BOOL _COMPLEX _IMAGINARY TOK_ALIGN
%token <gs> IDENTIFIER ID_TYPE
%token ERROR
%union
{
long long ll;
+ unsigned long long ull;
char c;
struct gc_string *gs;
struct ctf_node *n;
%type <gs> keywords
+%type <ull> INTEGER_LITERAL
%type <n> postfix_expression unary_expression unary_expression_or_range
%type <n> declaration
$$->u.unary_expression.type = UNARY_STRING;
$$->u.unary_expression.u.string = yylval.gs->s;
}
- | DECIMAL_CONSTANT
- {
- $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
- $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
- sscanf(yylval.gs->s, "%" PRIu64,
- &$$->u.unary_expression.u.unsigned_constant);
- }
- | OCTAL_CONSTANT
+ | INTEGER_LITERAL
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
- sscanf(yylval.gs->s, "0%" PRIo64,
- &$$->u.unary_expression.u.unsigned_constant);
- }
- | HEXADECIMAL_CONSTANT
- {
- $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
- $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
- sscanf(yylval.gs->s, "0x%" PRIx64,
- &$$->u.unary_expression.u.unsigned_constant);
+ $$->u.unary_expression.u.unsigned_constant = $1;
}
| STRING_LITERAL
{
}
| LPAREN unary_expression RPAREN
{
- $$ = make_node(scanner, NODE_UNARY_EXPRESSION);
- $$->u.unary_expression.type = UNARY_NESTED;
- $$->u.unary_expression.u.nested_exp = $2;
+ $$ = $2;
}
| postfix_expression LSBRAC unary_expression RSBRAC
{