add class declaration to the parser
This commit is contained in:
parent
153d129111
commit
21e8c6c4ca
@ -131,6 +131,8 @@ asm return ASM;
|
|||||||
__asm__ return ASM;
|
__asm__ return ASM;
|
||||||
__extension__ return EXTENSION;
|
__extension__ return EXTENSION;
|
||||||
|
|
||||||
|
class return CLASS;
|
||||||
|
|
||||||
L?'[^\\]' return CHAR_CONST;
|
L?'[^\\]' return CHAR_CONST;
|
||||||
L?'\\.' return CHAR_CONST;
|
L?'\\.' return CHAR_CONST;
|
||||||
L?'\\x[0-9A-Fa-f]{2}' return CHAR_CONST;
|
L?'\\x[0-9A-Fa-f]{2}' return CHAR_CONST;
|
||||||
|
@ -117,6 +117,8 @@ int yylex(YYSTYPE *, YYLTYPE *);
|
|||||||
%token ASM;
|
%token ASM;
|
||||||
%token EXTENSION;
|
%token EXTENSION;
|
||||||
|
|
||||||
|
%token CLASS;
|
||||||
|
|
||||||
%start translation_unit
|
%start translation_unit
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -591,6 +593,7 @@ type_specifier
|
|||||||
| UNSIGNED { $$ = $1; }
|
| UNSIGNED { $$ = $1; }
|
||||||
| struct_or_union_specifier { $$ = $1; }
|
| struct_or_union_specifier { $$ = $1; }
|
||||||
| enum_specifier { $$ = $1; }
|
| enum_specifier { $$ = $1; }
|
||||||
|
| class_specifier { $$ = $1; }
|
||||||
| TYPE_NAME { $$ = $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
|
type_qualifier
|
||||||
: CONST { $$ = $1; }
|
: CONST { $$ = $1; }
|
||||||
| VOLATILE { $$ = $1; }
|
| VOLATILE { $$ = $1; }
|
||||||
|
10
tests/t006.cxl
Normal file
10
tests/t006.cxl
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
0
tests/t006.x
Normal file
0
tests/t006.x
Normal file
Loading…
x
Reference in New Issue
Block a user