add asm statements/expressions

This commit is contained in:
josh committed 2018-05-12 11:41:45 -04:00
1 parent c5c0bddc33
commit b40f501d2a
3 files changed
+30 -1

No files matched your search

+1 -1
View File
@@ -48,7 +48,7 @@ int main(int argc, char * argv[])
/* Clean up temporary files. */ /* Clean up temporary files. */
if (preprocessed_fname_created) if (preprocessed_fname_created)
{ {
unlink(preprocessed_fname); //unlink(preprocessed_fname);
} }
return 0; return 0;
+2
View File
@@ -123,6 +123,8 @@ sizeof return SIZEOF;
__attribute__ return ATTRIBUTE; __attribute__ return ATTRIBUTE;
__restrict return RESTRICT; __restrict return RESTRICT;
asm return ASM;
__asm__ return ASM;
L?'[^\\]' return CHAR_CONST; L?'[^\\]' return CHAR_CONST;
L?'\\.' return CHAR_CONST; L?'\\.' return CHAR_CONST;
+27
View File
@@ -114,6 +114,7 @@ int yylex(YYSTYPE *, YYLTYPE *);
%token TYPE_NAME; %token TYPE_NAME;
%token ATTRIBUTE; %token ATTRIBUTE;
%token RESTRICT; %token RESTRICT;
%token ASM;
%start translation_unit %start translation_unit
@@ -516,6 +517,7 @@ statement
| selection_statement | selection_statement
| iteration_statement | iteration_statement
| jump_statement | jump_statement
| asm_statement
; ;
labeled_statement labeled_statement
@@ -567,6 +569,29 @@ jump_statement
| RETURN expression SEMICOLON | 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 translation_unit
: external_declaration : external_declaration
| translation_unit external_declaration | translation_unit external_declaration
@@ -588,6 +613,8 @@ attributes
: { $$ = nullptr; } : { $$ = nullptr; }
| attribute_spec | attribute_spec
| attributes attribute_spec | attributes attribute_spec
| asm_expression
| attributes asm_expression
; ;
attribute_spec attribute_spec