Remove nested expressions
[babeltrace.git] / formats / ctf / metadata / ctf-parser.y
index ce514c682c64d68c7205d315583f5871ba424084..1ccc718a0954ff063e72cefc7c3bd69b75ff6961 100644 (file)
@@ -109,41 +109,6 @@ static struct gc_string *gc_string_alloc(struct ctf_scanner *scanner,
        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);
@@ -1064,12 +1029,13 @@ void ctf_scanner_free(struct ctf_scanner *scanner)
  */
 %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;
@@ -1079,6 +1045,7 @@ void ctf_scanner_free(struct ctf_scanner *scanner)
 
 %type <gs> keywords
 
+%type <ull> INTEGER_LITERAL
 %type <n> postfix_expression unary_expression unary_expression_or_range
 
 %type <n> declaration
@@ -1212,26 +1179,11 @@ postfix_expression:
                        $$->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
                {
@@ -1247,9 +1199,7 @@ postfix_expression:
                }
        |       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
                {
This page took 0.024513 seconds and 4 git commands to generate.