* SOFTWARE.
*/
+#define BT_LOG_TAG "PLUGIN-CTF-METADATA-PARSER"
+#include "logging.h"
+
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <inttypes.h>
#include <babeltrace/list-internal.h>
-#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/assert-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
#include "objstack.h"
-BT_HIDDEN
-int yydebug;
+#if BT_LOG_ENABLED_VERBOSE
+# define YYDEBUG 1
+# define YYFPRINTF(_stream, _fmt, args...) BT_LOGV(_fmt, ## args)
+#else
+# define YYDEBUG 0
+#endif
/* Join two lists, put "add" at the end of "head". */
static inline void
return -1;
}
}
- assert(nr_char > 0);
+ BT_ASSERT(nr_char > 0);
buffer[nr_char] = '\0';
*buf_len = nr_char;
return 0;
lvalp->s = objstack_alloc(scanner->objstack, len);
if (src[0] == 'L') {
// TODO: import wide string
- printfl_error(yyget_lineno(scanner),
- "Wide string not supported yet.");
+ _BT_LOGE_LINENO(yyget_lineno(scanner),
+ "wide characters are not supported as of this version: "
+ "scanner-addr=%p", scanner);
return -1;
} else {
return import_basic_string(scanner, lvalp, len, src, delim);
{
struct ctf_scanner_scope *ns;
- printf_debug("push scope\n");
+ BT_LOGV("Pushing scope: scanner-addr=%p", scanner);
ns = malloc(sizeof(struct ctf_scanner_scope));
init_scope(ns, scanner->cs);
scanner->cs = ns;
{
struct ctf_scanner_scope *os;
- printf_debug("pop scope\n");
+ BT_LOGV("Popping scope: scanner-addr=%p", scanner);
os = scanner->cs;
scanner->cs = os->parent;
finalize_scope(os);
{
int ret;
- ret = (int) (long) g_hash_table_lookup(s->types, id);
- printf_debug("lookup %p %s %d\n", s, id, ret);
+ ret = GPOINTER_TO_INT(g_hash_table_lookup(s->types, id));
+ BT_LOGV("Looked up type: scanner-addr=%p, id=\"%s\", ret=%d",
+ s, id, ret);
return ret;
}
break;
}
}
- printf_debug("is type %s %d\n", id, ret);
+ BT_LOGV("Found if ID is type: scanner-addr=%p, id=\"%s\", ret=%d",
+ scanner, id, ret);
return ret;
}
static void add_type(struct ctf_scanner *scanner, char *id)
{
- printf_debug("add type %s\n", id);
+ BT_LOGV("Adding type: scanner-addr=%p, id=\"%s\"",
+ scanner, id);
if (lookup_type(scanner->cs, id))
return;
g_hash_table_insert(scanner->cs->types, id, id);
node = objstack_alloc(scanner->objstack, sizeof(*node));
if (!node) {
- printfl_fatal(yyget_lineno(scanner->scanner), "out of memory");
+ _BT_LOGE_LINENO(yyget_lineno(scanner->scanner),
+ "failed to allocate one stack entry: "
+ "scanner-addr=%p", scanner);
return &error_node;
}
node->type = type;
switch (type) {
case NODE_ROOT:
node->type = NODE_ERROR;
- printfn_fatal(node, "trying to create root node");
+ BT_LOGE("Trying to create root node: scanner-addr=%p",
+ scanner);
break;
-
case NODE_EVENT:
BT_INIT_LIST_HEAD(&node->u.event.declaration_list);
break;
case NODE_CALLSITE:
BT_INIT_LIST_HEAD(&node->u.callsite.declaration_list);
break;
-
case NODE_CTF_EXPRESSION:
BT_INIT_LIST_HEAD(&node->u.ctf_expression.left);
BT_INIT_LIST_HEAD(&node->u.ctf_expression.right);
break;
case NODE_UNARY_EXPRESSION:
break;
-
case NODE_TYPEDEF:
BT_INIT_LIST_HEAD(&node->u._typedef.type_declarators);
break;
break;
case NODE_TYPEALIAS:
break;
-
case NODE_TYPE_SPECIFIER:
break;
case NODE_TYPE_SPECIFIER_LIST:
case NODE_TYPE_DECLARATOR:
BT_INIT_LIST_HEAD(&node->u.type_declarator.pointers);
break;
-
case NODE_FLOATING_POINT:
BT_INIT_LIST_HEAD(&node->u.floating_point.expressions);
break;
BT_INIT_LIST_HEAD(&node->u._struct.declaration_list);
BT_INIT_LIST_HEAD(&node->u._struct.min_align);
break;
-
case NODE_UNKNOWN:
default:
node->type = NODE_ERROR;
- printfn_fatal(node, "unknown node type '%d'", (int) type);
+ BT_LOGE("Unknown node type: scanner-addr=%p, node-type=%d",
+ scanner, type);
break;
}
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type %d", parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
switch (node->type) {
case NODE_ROOT:
- printfn_fatal(node, "trying to reparent root node");
+ BT_LOGE_STR("Trying to reparent root node.");
return -EINVAL;
case NODE_EVENT:
case NODE_UNKNOWN:
default:
- printfn_fatal(node, "unknown node type '%d'", (int) parent->type);
+ BT_LOGE("Unknown node type: node-type=%d", parent->type);
return -EINVAL;
}
return 0;
BT_HIDDEN
void yyerror(struct ctf_scanner *scanner, yyscan_t yyscanner, const char *str)
{
- printfl_error(yyget_lineno(scanner->scanner),
- "token \"%s\": %s\n",
- yyget_text(scanner->scanner), str);
+ _BT_LOGE_LINENO(yyget_lineno(scanner->scanner),
+ "%s: token=\"%s\"", str, yyget_text(scanner->scanner));
}
BT_HIDDEN
{
/* Start processing new stream */
yyrestart(input, scanner->scanner);
- if (yydebug)
- fprintf(stdout, "Scanner input is a%s.\n",
- isatty(fileno(input)) ? "n interactive tty" :
- " noninteractive file");
return yyparse(scanner, scanner->scanner);
}
struct ctf_scanner *scanner;
int ret;
- yydebug = babeltrace_debug;
-
scanner = malloc(sizeof(*scanner));
if (!scanner)
return NULL;
memset(scanner, 0, sizeof(*scanner));
ret = yylex_init_extra(scanner, &scanner->scanner);
if (ret) {
- printf_fatal("yylex_init error");
+ BT_LOGE("yylex_init_extra() failed: ret=%d", ret);
goto cleanup_scanner;
}
scanner->objstack = objstack_create();
cleanup_lexer:
ret = yylex_destroy(scanner->scanner);
if (!ret)
- printf_fatal("yylex_destroy error");
+ BT_LOGE("yylex_destroy() failed: scanner-addr=%p, ret=%d",
+ scanner, ret);
cleanup_scanner:
free(scanner);
return NULL;
objstack_destroy(scanner->objstack);
ret = yylex_destroy(scanner->scanner);
if (ret)
- printf_error("yylex_destroy error");
+ BT_LOGE("yylex_destroy() failed: scanner-addr=%p, ret=%d",
+ scanner, ret);
free(scanner);
}
*/
%expect 2
%start file
-%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 CTF_INTEGER_LITERAL CTF_STRING_LITERAL CTF_CHARACTER_LITERAL CTF_LSBRAC CTF_RSBRAC CTF_LPAREN CTF_RPAREN CTF_LBRAC CTF_RBRAC CTF_RARROW CTF_STAR CTF_PLUS CTF_MINUS CTF_LT CTF_GT CTF_TYPEASSIGN CTF_COLON CTF_SEMICOLON CTF_DOTDOTDOT CTF_DOT CTF_EQUAL CTF_COMMA CTF_CONST CTF_CHAR CTF_DOUBLE CTF_ENUM CTF_ENV CTF_EVENT CTF_FLOATING_POINT CTF_FLOAT CTF_INTEGER CTF_INT CTF_LONG CTF_SHORT CTF_SIGNED CTF_STREAM CTF_STRING CTF_STRUCT CTF_TRACE CTF_CALLSITE CTF_CLOCK CTF_TYPEALIAS CTF_TYPEDEF CTF_UNSIGNED CTF_VARIANT CTF_VOID CTF_BOOL CTF_COMPLEX CTF_IMAGINARY CTF_TOK_ALIGN
%token <s> IDENTIFIER ID_TYPE
-%token ERROR
+%token CTF_ERROR
%union
{
long long ll;
struct ctf_node *n;
}
-%type <s> STRING_LITERAL CHARACTER_LITERAL
+%type <s> CTF_STRING_LITERAL CTF_CHARACTER_LITERAL
%type <s> keywords
-%type <ull> INTEGER_LITERAL
+%type <ull> CTF_INTEGER_LITERAL
%type <n> postfix_expression unary_expression unary_expression_or_range
%type <n> declaration
;
keywords:
- VOID
+ CTF_VOID
{ $$ = yylval.s; }
- | CHAR
+ | CTF_CHAR
{ $$ = yylval.s; }
- | SHORT
+ | CTF_SHORT
{ $$ = yylval.s; }
- | INT
+ | CTF_INT
{ $$ = yylval.s; }
- | LONG
+ | CTF_LONG
{ $$ = yylval.s; }
- | FLOAT
+ | CTF_FLOAT
{ $$ = yylval.s; }
- | DOUBLE
+ | CTF_DOUBLE
{ $$ = yylval.s; }
- | SIGNED
+ | CTF_SIGNED
{ $$ = yylval.s; }
- | UNSIGNED
+ | CTF_UNSIGNED
{ $$ = yylval.s; }
- | _BOOL
+ | CTF_BOOL
{ $$ = yylval.s; }
- | _COMPLEX
+ | CTF_COMPLEX
{ $$ = yylval.s; }
- | _IMAGINARY
+ | CTF_IMAGINARY
{ $$ = yylval.s; }
- | FLOATING_POINT
+ | CTF_FLOATING_POINT
{ $$ = yylval.s; }
- | INTEGER
+ | CTF_INTEGER
{ $$ = yylval.s; }
- | STRING
+ | CTF_STRING
{ $$ = yylval.s; }
- | ENUM
+ | CTF_ENUM
{ $$ = yylval.s; }
- | VARIANT
+ | CTF_VARIANT
{ $$ = yylval.s; }
- | STRUCT
+ | CTF_STRUCT
{ $$ = yylval.s; }
- | CONST
+ | CTF_CONST
{ $$ = yylval.s; }
- | TYPEDEF
+ | CTF_TYPEDEF
{ $$ = yylval.s; }
- | EVENT
+ | CTF_EVENT
{ $$ = yylval.s; }
- | STREAM
+ | CTF_STREAM
{ $$ = yylval.s; }
- | ENV
+ | CTF_ENV
{ $$ = yylval.s; }
- | TRACE
+ | CTF_TRACE
{ $$ = yylval.s; }
- | CLOCK
+ | CTF_CLOCK
{ $$ = yylval.s; }
- | CALLSITE
+ | CTF_CALLSITE
{ $$ = yylval.s; }
- | TOK_ALIGN
+ | CTF_TOK_ALIGN
{ $$ = yylval.s; }
;
$$->u.unary_expression.type = UNARY_STRING;
$$->u.unary_expression.u.string = yylval.s;
}
- | INTEGER_LITERAL
+ | CTF_INTEGER_LITERAL
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT;
$$->u.unary_expression.u.unsigned_constant = $1;
}
- | STRING_LITERAL
+ | CTF_STRING_LITERAL
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
$$->u.unary_expression.u.string = $1;
}
- | CHARACTER_LITERAL
+ | CTF_CHARACTER_LITERAL
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
$$->u.unary_expression.u.string = $1;
}
- | LPAREN unary_expression RPAREN
+ | CTF_LPAREN unary_expression CTF_RPAREN
{
$$ = $2;
}
- | postfix_expression LSBRAC unary_expression RSBRAC
+ | postfix_expression CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_SBRAC;
bt_list_splice(&($1)->tmp_head, &($$)->tmp_head);
bt_list_add_tail(&($$)->siblings, &($$)->tmp_head);
}
- | postfix_expression DOT IDENTIFIER
+ | postfix_expression CTF_DOT IDENTIFIER
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
bt_list_splice(&($1)->tmp_head, &($$)->tmp_head);
bt_list_add_tail(&($$)->siblings, &($$)->tmp_head);
}
- | postfix_expression DOT ID_TYPE
+ | postfix_expression CTF_DOT ID_TYPE
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
bt_list_splice(&($1)->tmp_head, &($$)->tmp_head);
bt_list_add_tail(&($$)->siblings, &($$)->tmp_head);
}
- | postfix_expression DOT keywords
+ | postfix_expression CTF_DOT keywords
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
bt_list_splice(&($1)->tmp_head, &($$)->tmp_head);
bt_list_add_tail(&($$)->siblings, &($$)->tmp_head);
}
- | postfix_expression RARROW IDENTIFIER
+ | postfix_expression CTF_RARROW IDENTIFIER
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
bt_list_splice(&($1)->tmp_head, &($$)->tmp_head);
bt_list_add_tail(&($$)->siblings, &($$)->tmp_head);
}
- | postfix_expression RARROW ID_TYPE
+ | postfix_expression CTF_RARROW ID_TYPE
{
$$ = make_node(scanner, NODE_UNARY_EXPRESSION);
$$->u.unary_expression.type = UNARY_STRING;
unary_expression:
postfix_expression
{ $$ = $1; }
- | PLUS postfix_expression
+ | CTF_PLUS postfix_expression
{
$$ = $2;
if ($$->u.unary_expression.type != UNARY_UNSIGNED_CONSTANT
reparent_error(scanner, "expecting numeric constant");
}
}
- | MINUS postfix_expression
+ | CTF_MINUS postfix_expression
{
$$ = $2;
if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) {
;
unary_expression_or_range:
- unary_expression DOTDOTDOT unary_expression
+ unary_expression CTF_DOTDOTDOT unary_expression
{
$$ = $1;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->tmp_head);
/* 2.2: Declarations */
declaration:
- declaration_specifiers SEMICOLON
+ declaration_specifiers CTF_SEMICOLON
{ $$ = $1; }
| event_declaration
{ $$ = $1; }
{ $$ = $1; }
| callsite_declaration
{ $$ = $1; }
- | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
_bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
+ | CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
_bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
_bt_list_splice_tail(&($1)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
+ | CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
;
event_declaration_begin:
- EVENT LBRAC
+ CTF_EVENT CTF_LBRAC
{ push_scope(scanner); }
;
event_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
;
stream_declaration_begin:
- STREAM LBRAC
+ CTF_STREAM CTF_LBRAC
{ push_scope(scanner); }
;
stream_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
;
env_declaration_begin:
- ENV LBRAC
+ CTF_ENV CTF_LBRAC
{ push_scope(scanner); }
;
env_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
;
trace_declaration_begin:
- TRACE LBRAC
+ CTF_TRACE CTF_LBRAC
{ push_scope(scanner); }
;
trace_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
clock_declaration:
- CLOCK clock_declaration_begin clock_declaration_end
+ CTF_CLOCK clock_declaration_begin clock_declaration_end
{
$$ = make_node(scanner, NODE_CLOCK);
}
- | CLOCK clock_declaration_begin ctf_assignment_expression_list clock_declaration_end
+ | CTF_CLOCK clock_declaration_begin ctf_assignment_expression_list clock_declaration_end
{
$$ = make_node(scanner, NODE_CLOCK);
if (set_parent_node($3, $$))
;
clock_declaration_begin:
- LBRAC
+ CTF_LBRAC
{ push_scope(scanner); }
;
clock_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
callsite_declaration:
- CALLSITE callsite_declaration_begin callsite_declaration_end
+ CTF_CALLSITE callsite_declaration_begin callsite_declaration_end
{
$$ = make_node(scanner, NODE_CALLSITE);
}
- | CALLSITE callsite_declaration_begin ctf_assignment_expression_list callsite_declaration_end
+ | CTF_CALLSITE callsite_declaration_begin ctf_assignment_expression_list callsite_declaration_end
{
$$ = make_node(scanner, NODE_CALLSITE);
if (set_parent_node($3, $$))
;
callsite_declaration_begin:
- LBRAC
+ CTF_LBRAC
{ push_scope(scanner); }
;
callsite_declaration_end:
- RBRAC SEMICOLON
+ CTF_RBRAC CTF_SEMICOLON
{ pop_scope(scanner); }
;
integer_declaration_specifiers:
- CONST
+ CTF_CONST
{
struct ctf_node *node;
node = $1;
bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
- | integer_declaration_specifiers CONST
+ | integer_declaration_specifiers CTF_CONST
{
struct ctf_node *node;
;
declaration_specifiers:
- CONST
+ CTF_CONST
{
struct ctf_node *node;
node = $1;
bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
- | declaration_specifiers CONST
+ | declaration_specifiers CTF_CONST
{
struct ctf_node *node;
type_declarator_list:
type_declarator
{ $$ = $1; }
- | type_declarator_list COMMA type_declarator
+ | type_declarator_list CTF_COMMA type_declarator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
;
integer_type_specifier:
- CHAR
+ CTF_CHAR
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_CHAR;
}
- | SHORT
+ | CTF_SHORT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_SHORT;
}
- | INT
+ | CTF_INT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INT;
}
- | LONG
+ | CTF_LONG
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_LONG;
}
- | SIGNED
+ | CTF_SIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_SIGNED;
}
- | UNSIGNED
+ | CTF_UNSIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_UNSIGNED;
}
- | _BOOL
+ | CTF_BOOL
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_BOOL;
$$->u.type_specifier.type = TYPESPEC_ID_TYPE;
$$->u.type_specifier.id_type = yylval.s;
}
- | INTEGER LBRAC RBRAC
+ | CTF_INTEGER CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INTEGER;
$$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
}
- | INTEGER LBRAC ctf_assignment_expression_list RBRAC
+ | CTF_INTEGER CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INTEGER;
;
type_specifier:
- VOID
+ CTF_VOID
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_VOID;
}
- | CHAR
+ | CTF_CHAR
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_CHAR;
}
- | SHORT
+ | CTF_SHORT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_SHORT;
}
- | INT
+ | CTF_INT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INT;
}
- | LONG
+ | CTF_LONG
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_LONG;
}
- | FLOAT
+ | CTF_FLOAT
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_FLOAT;
}
- | DOUBLE
+ | CTF_DOUBLE
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_DOUBLE;
}
- | SIGNED
+ | CTF_SIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_SIGNED;
}
- | UNSIGNED
+ | CTF_UNSIGNED
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_UNSIGNED;
}
- | _BOOL
+ | CTF_BOOL
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_BOOL;
}
- | _COMPLEX
+ | CTF_COMPLEX
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_COMPLEX;
}
- | _IMAGINARY
+ | CTF_IMAGINARY
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_IMAGINARY;
$$->u.type_specifier.type = TYPESPEC_ID_TYPE;
$$->u.type_specifier.id_type = yylval.s;
}
- | FLOATING_POINT LBRAC RBRAC
+ | CTF_FLOATING_POINT CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
$$->u.type_specifier.node = make_node(scanner, NODE_FLOATING_POINT);
}
- | FLOATING_POINT LBRAC ctf_assignment_expression_list RBRAC
+ | CTF_FLOATING_POINT CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_FLOATING_POINT;
if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "floating point reparent error");
}
- | INTEGER LBRAC RBRAC
+ | CTF_INTEGER CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INTEGER;
$$->u.type_specifier.node = make_node(scanner, NODE_INTEGER);
}
- | INTEGER LBRAC ctf_assignment_expression_list RBRAC
+ | CTF_INTEGER CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_INTEGER;
if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "integer reparent error");
}
- | STRING
+ | CTF_STRING
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_STRING;
$$->u.type_specifier.node = make_node(scanner, NODE_STRING);
}
- | STRING LBRAC RBRAC
+ | CTF_STRING CTF_LBRAC CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_STRING;
$$->u.type_specifier.node = make_node(scanner, NODE_STRING);
}
- | STRING LBRAC ctf_assignment_expression_list RBRAC
+ | CTF_STRING CTF_LBRAC ctf_assignment_expression_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_STRING;
if (set_parent_node($3, $$->u.type_specifier.node))
reparent_error(scanner, "string reparent error");
}
- | ENUM enum_type_specifier
+ | CTF_ENUM enum_type_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_ENUM;
$$->u.type_specifier.node = $2;
}
- | VARIANT variant_type_specifier
+ | CTF_VARIANT variant_type_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_VARIANT;
$$->u.type_specifier.node = $2;
}
- | STRUCT struct_type_specifier
+ | CTF_STRUCT struct_type_specifier
{
$$ = make_node(scanner, NODE_TYPE_SPECIFIER);
$$->u.type_specifier.type = TYPESPEC_STRUCT;
$$->u._struct.has_body = 0;
$$->u._struct.name = $1;
}
- | struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN
+ | struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end CTF_TOK_ALIGN CTF_LPAREN unary_expression CTF_RPAREN
{
$$ = make_node(scanner, NODE_STRUCT);
$$->u._struct.has_body = 1;
if ($2 && set_parent_node($2, $$))
reparent_error(scanner, "struct reparent error");
}
- | IDENTIFIER struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN
+ | IDENTIFIER struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end CTF_TOK_ALIGN CTF_LPAREN unary_expression CTF_RPAREN
{
$$ = make_node(scanner, NODE_STRUCT);
$$->u._struct.has_body = 1;
if ($3 && set_parent_node($3, $$))
reparent_error(scanner, "struct reparent error");
}
- | ID_TYPE struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end TOK_ALIGN LPAREN unary_expression RPAREN
+ | ID_TYPE struct_declaration_begin struct_or_variant_declaration_list struct_declaration_end CTF_TOK_ALIGN CTF_LPAREN unary_expression CTF_RPAREN
{
$$ = make_node(scanner, NODE_STRUCT);
$$->u._struct.has_body = 1;
;
struct_declaration_begin:
- LBRAC
+ CTF_LBRAC
{ push_scope(scanner); }
;
struct_declaration_end:
- RBRAC
+ CTF_RBRAC
{ pop_scope(scanner); }
;
if ($2 && set_parent_node($2, $$))
reparent_error(scanner, "variant reparent error");
}
- | LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | CTF_LT IDENTIFIER CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($5 && set_parent_node($5, $$))
reparent_error(scanner, "variant reparent error");
}
- | LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | CTF_LT ID_TYPE CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($3 && set_parent_node($3, $$))
reparent_error(scanner, "variant reparent error");
}
- | IDENTIFIER LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | IDENTIFIER CTF_LT IDENTIFIER CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($6 && set_parent_node($6, $$))
reparent_error(scanner, "variant reparent error");
}
- | IDENTIFIER LT IDENTIFIER GT
+ | IDENTIFIER CTF_LT IDENTIFIER CTF_GT
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 0;
$$->u.variant.name = $1;
$$->u.variant.choice = $3;
}
- | IDENTIFIER LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | IDENTIFIER CTF_LT ID_TYPE CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($6 && set_parent_node($6, $$))
reparent_error(scanner, "variant reparent error");
}
- | IDENTIFIER LT ID_TYPE GT
+ | IDENTIFIER CTF_LT ID_TYPE CTF_GT
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 0;
if ($3 && set_parent_node($3, $$))
reparent_error(scanner, "variant reparent error");
}
- | ID_TYPE LT IDENTIFIER GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | ID_TYPE CTF_LT IDENTIFIER CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($6 && set_parent_node($6, $$))
reparent_error(scanner, "variant reparent error");
}
- | ID_TYPE LT IDENTIFIER GT
+ | ID_TYPE CTF_LT IDENTIFIER CTF_GT
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 0;
$$->u.variant.name = $1;
$$->u.variant.choice = $3;
}
- | ID_TYPE LT ID_TYPE GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
+ | ID_TYPE CTF_LT ID_TYPE CTF_GT variant_declaration_begin struct_or_variant_declaration_list variant_declaration_end
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 1;
if ($6 && set_parent_node($6, $$))
reparent_error(scanner, "variant reparent error");
}
- | ID_TYPE LT ID_TYPE GT
+ | ID_TYPE CTF_LT ID_TYPE CTF_GT
{
$$ = make_node(scanner, NODE_VARIANT);
$$->u.variant.has_body = 0;
;
variant_declaration_begin:
- LBRAC
+ CTF_LBRAC
{ push_scope(scanner); }
;
variant_declaration_end:
- RBRAC
+ CTF_RBRAC
{ pop_scope(scanner); }
;
enum_type_specifier:
- LBRAC enumerator_list RBRAC
+ CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
_bt_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
+ | CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
($$)->u._enum.container_type = $2;
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | IDENTIFIER LBRAC enumerator_list RBRAC
+ | IDENTIFIER CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
+ | IDENTIFIER CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
($$)->u._enum.container_type = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | ID_TYPE LBRAC enumerator_list RBRAC
+ | ID_TYPE CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list RBRAC
+ | ID_TYPE CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
($$)->u._enum.container_type = $3;
_bt_list_splice_tail(&($5)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | LBRAC enumerator_list COMMA RBRAC
+ | CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
_bt_list_splice_tail(&($2)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
+ | CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
($$)->u._enum.container_type = $2;
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | IDENTIFIER LBRAC enumerator_list COMMA RBRAC
+ | IDENTIFIER CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | IDENTIFIER COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
+ | IDENTIFIER CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.has_body = 0;
$$->u._enum.enum_id = $1;
}
- | ID_TYPE LBRAC enumerator_list COMMA RBRAC
+ | ID_TYPE CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
$$->u._enum.enum_id = $1;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._enum.enumerator_list);
}
- | ID_TYPE COLON integer_declaration_specifiers LBRAC enumerator_list COMMA RBRAC
+ | ID_TYPE CTF_COLON integer_declaration_specifiers CTF_LBRAC enumerator_list CTF_COMMA CTF_RBRAC
{
$$ = make_node(scanner, NODE_ENUM);
$$->u._enum.has_body = 1;
;
struct_or_variant_declaration:
- declaration_specifiers struct_or_variant_declarator_list SEMICOLON
+ declaration_specifiers struct_or_variant_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_bt_list_splice_tail(&($2)->tmp_head, &($$)->u.struct_or_variant_declaration.type_declarators);
}
- | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
_bt_list_splice_tail(&($3)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEDEF declaration_specifiers type_declarator_list SEMICOLON
+ | CTF_TYPEDEF declaration_specifiers type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
_bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | declaration_specifiers TYPEDEF type_declarator_list SEMICOLON
+ | declaration_specifiers CTF_TYPEDEF type_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list SEMICOLON
+ | CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list CTF_SEMICOLON
{
struct ctf_node *list;
;
alias_declaration_specifiers:
- CONST
+ CTF_CONST
{
struct ctf_node *node;
node->u.type_specifier.id_type = yylval.s;
bt_list_add_tail(&node->siblings, &($$)->u.type_specifier_list.head);
}
- | alias_declaration_specifiers CONST
+ | alias_declaration_specifiers CTF_CONST
{
struct ctf_node *node;
struct_or_variant_declarator_list:
struct_or_variant_declarator
{ $$ = $1; }
- | struct_or_variant_declarator_list COMMA struct_or_variant_declarator
+ | struct_or_variant_declarator_list CTF_COMMA struct_or_variant_declarator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
struct_or_variant_declarator:
declarator
{ $$ = $1; }
- | COLON unary_expression
+ | CTF_COLON unary_expression
{ $$ = $2; }
- | declarator COLON unary_expression
+ | declarator CTF_COLON unary_expression
{
$$ = $1;
if (set_parent_node($3, $1))
enumerator_list:
enumerator
{ $$ = $1; }
- | enumerator_list COMMA enumerator
+ | enumerator_list CTF_COMMA enumerator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
}
- | STRING_LITERAL
+ | CTF_STRING_LITERAL
{
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
}
- | IDENTIFIER EQUAL unary_expression_or_range
+ | IDENTIFIER CTF_EQUAL unary_expression_or_range
{
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
}
- | ID_TYPE EQUAL unary_expression_or_range
+ | ID_TYPE CTF_EQUAL unary_expression_or_range
{
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
}
- | keywords EQUAL unary_expression_or_range
+ | keywords CTF_EQUAL unary_expression_or_range
{
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
bt_list_splice(&($3)->tmp_head, &($$)->u.enumerator.values);
}
- | STRING_LITERAL EQUAL unary_expression_or_range
+ | CTF_STRING_LITERAL CTF_EQUAL unary_expression_or_range
{
$$ = make_node(scanner, NODE_ENUMERATOR);
$$->u.enumerator.id = $1;
abstract_declarator_list:
abstract_declarator
{ $$ = $1; }
- | abstract_declarator_list COMMA abstract_declarator
+ | abstract_declarator_list CTF_COMMA abstract_declarator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
$$->u.type_declarator.type = TYPEDEC_ID;
$$->u.type_declarator.u.id = $1;
}
- | LPAREN abstract_declarator RPAREN
+ | CTF_LPAREN abstract_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $2;
}
- | direct_abstract_declarator LSBRAC unary_expression RSBRAC
+ | direct_abstract_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
}
- | direct_abstract_declarator LSBRAC RSBRAC
+ | direct_abstract_declarator CTF_LSBRAC CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
alias_abstract_declarator_list:
alias_abstract_declarator
{ $$ = $1; }
- | alias_abstract_declarator_list COMMA alias_abstract_declarator
+ | alias_abstract_declarator_list CTF_COMMA alias_abstract_declarator
{
$$ = $1;
bt_list_add_tail(&($3)->siblings, &($$)->tmp_head);
$$->u.type_declarator.type = TYPEDEC_ID;
/* id is NULL */
}
- | LPAREN alias_abstract_declarator RPAREN
+ | CTF_LPAREN alias_abstract_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $2;
}
- | direct_alias_abstract_declarator LSBRAC unary_expression RSBRAC
+ | direct_alias_abstract_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
BT_INIT_LIST_HEAD(&($$)->u.type_declarator.u.nested.length);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u.type_declarator.u.nested.length);
}
- | direct_alias_abstract_declarator LSBRAC RSBRAC
+ | direct_alias_abstract_declarator CTF_LSBRAC CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.type = TYPEDEC_ID;
$$->u.type_declarator.u.id = $1;
}
- | LPAREN declarator RPAREN
+ | CTF_LPAREN declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $2;
}
- | direct_declarator LSBRAC unary_expression RSBRAC
+ | direct_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.type = TYPEDEC_ID;
$$->u.type_declarator.u.id = $1;
}
- | LPAREN type_declarator RPAREN
+ | CTF_LPAREN type_declarator CTF_RPAREN
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
$$->u.type_declarator.u.nested.type_declarator = $2;
}
- | direct_type_declarator LSBRAC unary_expression RSBRAC
+ | direct_type_declarator CTF_LSBRAC unary_expression CTF_RSBRAC
{
$$ = make_node(scanner, NODE_TYPE_DECLARATOR);
$$->u.type_declarator.type = TYPEDEC_NESTED;
;
pointer:
- STAR
+ CTF_STAR
{
$$ = make_node(scanner, NODE_POINTER);
}
- | STAR pointer
+ | CTF_STAR pointer
{
$$ = make_node(scanner, NODE_POINTER);
bt_list_splice(&($2)->tmp_head, &($$)->tmp_head);
}
- | STAR type_qualifier_list pointer
+ | CTF_STAR type_qualifier_list pointer
{
$$ = make_node(scanner, NODE_POINTER);
$$->u.pointer.const_qualifier = 1;
type_qualifier_list:
/* pointer assumes only const type qualifier */
- CONST
- | type_qualifier_list CONST
+ CTF_CONST
+ | type_qualifier_list CTF_CONST
;
/* 2.3: CTF-specific declarations */
ctf_assignment_expression_list:
- ctf_assignment_expression SEMICOLON
+ ctf_assignment_expression CTF_SEMICOLON
{ $$ = $1; }
- | ctf_assignment_expression_list ctf_assignment_expression SEMICOLON
+ | ctf_assignment_expression_list ctf_assignment_expression CTF_SEMICOLON
{
$$ = $1;
bt_list_add_tail(&($2)->siblings, &($$)->tmp_head);
;
ctf_assignment_expression:
- unary_expression EQUAL unary_expression
+ unary_expression CTF_EQUAL unary_expression
{
/*
* Because we have left and right, cannot use
reparent_error(scanner, "ctf_assignment_expression left expects string");
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u.ctf_expression.right);
}
- | unary_expression TYPEASSIGN declaration_specifiers /* Only allow struct */
+ | unary_expression CTF_TYPEASSIGN declaration_specifiers /* Only allow struct */
{
/*
* Because we have left and right, cannot use
reparent_error(scanner, "ctf_assignment_expression left expects string");
bt_list_add_tail(&($3)->siblings, &($$)->u.ctf_expression.right);
}
- | declaration_specifiers TYPEDEF declaration_specifiers type_declarator_list
+ | declaration_specifiers CTF_TYPEDEF declaration_specifiers type_declarator_list
{
struct ctf_node *list;
($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_bt_list_splice_tail(&($4)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEDEF declaration_specifiers type_declarator_list
+ | CTF_TYPEDEF declaration_specifiers type_declarator_list
{
struct ctf_node *list;
_bt_list_splice_tail(&($2)->u.type_specifier_list.head, &list->u.type_specifier_list.head);
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | declaration_specifiers TYPEDEF type_declarator_list
+ | declaration_specifiers CTF_TYPEDEF type_declarator_list
{
struct ctf_node *list;
($$)->u.struct_or_variant_declaration.type_specifier_list = list;
_bt_list_splice_tail(&($3)->tmp_head, &($$)->u._typedef.type_declarators);
}
- | TYPEALIAS declaration_specifiers abstract_declarator_list TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list
+ | CTF_TYPEALIAS declaration_specifiers abstract_declarator_list CTF_TYPEASSIGN alias_declaration_specifiers alias_abstract_declarator_list
{
struct ctf_node *list;