~sircmpwn/annotatec

74eaf24f0bf305ad77bd671a413454171484d6e7 — Drew DeVault 7 months ago abbd755
parser: combine successive string literals
1 files changed, 23 insertions(+), 13 deletions(-)

M lang.y
M lang.y => lang.y +23 -13
@@ 62,6 62,7 @@ struct parse_state parse_state = { 0 };
%type<strloc> primary_expression postfix_expression;
%type<strloc_list> init_declarator_list;
%type<token> storage_class_specifier declaration_specifiers;
%type<sval> string_literal;

%start program



@@ 74,6 75,15 @@ program
	| translation_unit
	;

string_literal
	: CZ_STRING_LITERAL
	| string_literal CZ_STRING_LITERAL {
		$$ = calloc(strlen($1) + strlen($2) + 1, 1);
		strcpy($$, $1);
		strcat($$, $2);
	}
	;

primary_expression
	: CZ_IDENTIFIER {
		$$.name = $1;


@@ 83,7 93,7 @@ primary_expression
	| constant {
		$$.name = NULL;
	}
	| CZ_STRING_LITERAL {
	| string_literal {
		$$.name = NULL;
	}
	| '(' expression ')' {


@@ 574,7 584,7 @@ designator
	;

static_assert_declaration
	: CZ_STATIC_ASSERT '(' constant_expression ',' CZ_STRING_LITERAL ')' ';'
	: CZ_STATIC_ASSERT '(' constant_expression ',' string_literal ')' ';'
	;

statement


@@ 703,17 713,17 @@ gnu_asm_qualifiers
	;

gnu_inline_asm
	: CZ_STRING_LITERAL
	| CZ_STRING_LITERAL ':'
	| CZ_STRING_LITERAL ':' gnu_asm_output_operands
	| CZ_STRING_LITERAL ':' gnu_asm_output_operands ':'
	| CZ_STRING_LITERAL ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers
	| CZ_STRING_LITERAL ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers ':'
	| CZ_STRING_LITERAL ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers ':' gnu_asm_goto_labels
	: string_literal
	| string_literal ':'
	| string_literal ':' gnu_asm_output_operands
	| string_literal ':' gnu_asm_output_operands ':'
	| string_literal ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers
	| string_literal ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers ':'
	| string_literal ':' gnu_asm_output_operands ':' gnu_asm_input_operands ':' gnu_asm_clobbers ':' gnu_asm_goto_labels
	;

gnu_asm_output_operand
	: CZ_STRING_LITERAL '(' CZ_IDENTIFIER ')'
	: string_literal '(' CZ_IDENTIFIER ')'
	;

gnu_asm_output_operands


@@ 722,7 732,7 @@ gnu_asm_output_operands
	;

gnu_asm_input_operand
	: CZ_STRING_LITERAL '(' expression ')'
	: string_literal '(' expression ')'
	;

gnu_asm_input_operands


@@ 731,8 741,8 @@ gnu_asm_input_operands
	;

gnu_asm_clobbers
	: CZ_STRING_LITERAL
	| gnu_asm_clobbers ',' CZ_STRING_LITERAL
	: string_literal
	| gnu_asm_clobbers ',' string_literal
	;

gnu_asm_goto_labels