add asm statements/expressions

This commit is contained in:
Josh Holtrop 2018-05-12 11:40:28 -04:00
parent c5c0bddc33
commit b40f501d2a
3 changed files with 30 additions and 1 deletions

View File

@ -48,7 +48,7 @@ int main(int argc, char * argv[])
/* Clean up temporary files. */
if (preprocessed_fname_created)
{
unlink(preprocessed_fname);
//unlink(preprocessed_fname);
}
return 0;

View File

@ -123,6 +123,8 @@ sizeof return SIZEOF;
__attribute__ return ATTRIBUTE;
__restrict return RESTRICT;
asm return ASM;
__asm__ return ASM;
L?'[^\\]' return CHAR_CONST;
L?'\\.' return CHAR_CONST;

View File

@ -114,6 +114,7 @@ int yylex(YYSTYPE *, YYLTYPE *);
%token TYPE_NAME;
%token ATTRIBUTE;
%token RESTRICT;
%token ASM;
%start translation_unit
@ -516,6 +517,7 @@ statement
| selection_statement
| iteration_statement
| jump_statement
| asm_statement
;
labeled_statement
@ -567,6 +569,29 @@ jump_statement
| RETURN expression SEMICOLON
;
asm_statement
: asm_expression SEMICOLON
;
asm_expression
: ASM LPAREN string_literals asm_operands RPAREN
;
asm_operands
:
| asm_operand
| asm_operands asm_operand
;
asm_operand
: COLON primary_expressions
;
primary_expressions
: primary_expression
| primary_expressions primary_expression
;
translation_unit
: external_declaration
| translation_unit external_declaration
@ -588,6 +613,8 @@ attributes
: { $$ = nullptr; }
| attribute_spec
| attributes attribute_spec
| asm_expression
| attributes asm_expression
;
attribute_spec