add class declaration to the parser
This commit is contained in:
1 parent
153d129111
commit
21e8c6c4ca
4 files changed
+35
No files matched your search
@@ -131,6 +131,8 @@ asm return ASM;
|
||||
__asm__ return ASM;
|
||||
__extension__ return EXTENSION;
|
||||
|
||||
class return CLASS;
|
||||
|
||||
L?'[^\\]' return CHAR_CONST;
|
||||
L?'\\.' return CHAR_CONST;
|
||||
L?'\\x[0-9A-Fa-f]{2}' return CHAR_CONST;
|
||||
|
||||
@@ -117,6 +117,8 @@ int yylex(YYSTYPE *, YYLTYPE *);
|
||||
%token ASM;
|
||||
%token EXTENSION;
|
||||
|
||||
%token CLASS;
|
||||
|
||||
%start translation_unit
|
||||
|
||||
%%
|
||||
@@ -591,6 +593,7 @@ type_specifier
|
||||
| UNSIGNED { $$ = $1; }
|
||||
| struct_or_union_specifier { $$ = $1; }
|
||||
| enum_specifier { $$ = $1; }
|
||||
| class_specifier { $$ = $1; }
|
||||
| TYPE_NAME { $$ = $1; }
|
||||
;
|
||||
|
||||
@@ -743,6 +746,26 @@ enumerator
|
||||
}
|
||||
;
|
||||
|
||||
class_specifier
|
||||
: CLASS IDENTIFIER LCURLY RCURLY {
|
||||
$$ = new Node(NODE_TYPE_LIST);
|
||||
}
|
||||
| CLASS IDENTIFIER LCURLY external_declaration_list RCURLY {
|
||||
$$ = new Node(NODE_TYPE_LIST);
|
||||
}
|
||||
;
|
||||
|
||||
external_declaration_list
|
||||
: external_declaration {
|
||||
$$ = new Node(NODE_TYPE_LIST);
|
||||
$$->list->push_back($1);
|
||||
}
|
||||
| external_declaration_list external_declaration {
|
||||
$$ = $1;
|
||||
$$->list->push_back($2);
|
||||
}
|
||||
;
|
||||
|
||||
type_qualifier
|
||||
: CONST { $$ = $1; }
|
||||
| VOLATILE { $$ = $1; }
|
||||
|
||||
Reference in new issue
Block a user