Changeset 6c3744e for translator/Parser
- Timestamp:
- Jan 19, 2015, 6:29:10 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- f7f6785
- Parents:
- 0b8cd722
- Location:
- translator/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/Parser/TypeData.cc
r0b8cd722 r6c3744e 696 696 } else { 697 697 switch ( ret ) { 698 case BasicType::LongLongSignedInt: // PAB 699 ret = BasicType::LongLongUnsignedInt; 700 break; 701 case BasicType::LongSignedInt: 702 ret = BasicType::LongUnsignedInt; 703 break; 698 704 case BasicType::SignedInt: 699 705 case BasicType::ShortSignedInt: … … 715 721 } else { 716 722 switch ( ret ) { 723 case BasicType::LongLongSignedInt: // PAB 724 ret = BasicType::LongLongUnsignedInt; 725 break; 717 726 case BasicType::LongSignedInt: 718 727 ret = BasicType::LongUnsignedInt; -
translator/Parser/cfa.y
r0b8cd722 r6c3744e 10 10 * Created On : Sat Sep 1 20:22:55 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Jan 7 09:19:57201513 * Update Count : 90 612 * Last Modified On : Sat Jan 17 09:23:45 2015 13 * Update Count : 908 14 14 */ 15 15 16 /* This grammar is based on the ANSI99 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on the17 C grammar by James A. Roskind, specifically parts of DECLARATIONS and EXTERNAL DEFINITIONS. While parts18 have been copied, important changes have been made in all sections; these changes are sufficient to16 /* This grammar is based on the ANSI99/11 C grammar, specifically parts of EXPRESSION and STATEMENTS, and on 17 the C grammar by James A. Roskind, specifically parts of DECLARATIONS and EXTERNAL DEFINITIONS. While 18 parts have been copied, important changes have been made in all sections; these changes are sufficient to 19 19 constitute a new grammar. In particular, this grammar attempts to be more syntactically precise, i.e., it 20 20 parses less incorrect language syntax that must be subsequently rejected by semantic checks. Nevertheless, 21 there are still several semantic checks required and many are noted in the grammar. Finally, the grammar 22 isextended with GCC and CFA language extensions. */21 there are still several semantic checks required and many are noted in the grammar. Finally, the grammar is 22 extended with GCC and CFA language extensions. */ 23 23 24 24 /* Acknowledgments to Richard Bilson, Glen Ditchfield, and Rodolfo Gabriel Esteves who all helped when I got 25 25 stuck with the grammar. */ 26 26 27 /* The root language for this grammar is ANSI99 C. All of ANSI99is parsed, except for:27 /* The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for: 28 28 29 29 1. designation with '=' (use ':' instead) 30 30 31 Most of the syntactic extensions from ANSI90 to ANSI 99 C are marked with the comment "ANSI99". This grammar31 Most of the syntactic extensions from ANSI90 to ANSI11 C are marked with the comment "C99/C11". This grammar 32 32 also has two levels of extensions. The first extensions cover most of the GCC C extensions, except for: 33 33 … … 40 40 Cforall (CFA), which fixes several of C's outstanding problems and extends C with many modern language 41 41 concepts. All of the syntactic extensions for CFA C are marked with the comment "CFA". As noted above, 42 there is one unreconcileable parsing problem between ANSI99 and CFA with respect to designators; this is42 there is one unreconcileable parsing problem between C99 and CFA with respect to designators; this is 43 43 discussed in detail before the "designation" grammar rule. */ 44 44 … … 67 67 %token TYPEDEF 68 68 %token AUTO EXTERN REGISTER STATIC 69 %token INLINE /* ANSI99 */70 %token FORTRAN /* ANSI99, extension ISO/IEC 9899:1999 Section J.5.9(1) */69 %token INLINE /* C99 */ 70 %token FORTRAN /* C99, extension ISO/IEC 9899:1999 Section J.5.9(1) */ 71 71 %token CONST VOLATILE 72 %token RESTRICT /* ANSI99 */72 %token RESTRICT /* C99 */ 73 73 %token FORALL LVALUE /* CFA */ 74 74 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 75 %token BOOL COMPLEX IMAGINARY /* ANSI99 */75 %token BOOL COMPLEX IMAGINARY /* C99 */ 76 76 %token TYPEOF LABEL /* GCC */ 77 77 %token ENUM STRUCT UNION 78 78 %token TYPE FTYPE DTYPE CONTEXT /* CFA */ 79 79 %token SIZEOF 80 %token A LIGNOF ATTRIBUTE EXTENSION/* GCC */80 %token ATTRIBUTE EXTENSION /* GCC */ 81 81 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 82 82 %token CHOOSE FALLTHRU TRY CATCH FINALLY THROW /* CFA */ 83 %token ASM /* ANSI99, extension ISO/IEC 9899:1999 Section J.5.10(1) */ 83 %token ASM /* C99, extension ISO/IEC 9899:1999 Section J.5.10(1) */ 84 %token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL /* C11 */ 84 85 85 86 /* names and constants: lexer differentiates between identifier and typedef names */ … … 362 363 { $$ = new CompositeExprNode(new OperatorNode(OperatorNode::DecrPost), $1); } 363 364 /* GCC has priority: cast_expression */ 364 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' /* ANSI99 */365 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' /* C99 */ 365 366 { $$ = 0; } 366 367 ; … … 642 643 push push 643 644 label_declaration_opt /* GCC, local labels */ 644 block_item_list pop '}' /* ANSI99, intermix declarations and statements */645 block_item_list pop '}' /* C99, intermix declarations and statements */ 645 646 { $$ = new CompoundStmtNode( $5 ); } 646 647 ; 647 648 648 block_item_list: /* ANSI99 */649 block_item_list: /* C99 */ 649 650 block_item 650 651 | block_item_list push block_item … … 773 774 comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt 774 775 { $$ = new ForCtlExprNode($1, $4, $6); } 775 | declaration comma_expression_opt ';' comma_expression_opt /* ANSI99 */776 | declaration comma_expression_opt ';' comma_expression_opt /* C99 */ 776 777 /* Like C++, the loop index can be declared local to the loop. */ 777 778 { $$ = new ForCtlExprNode($1, $2, $4); } … … 1244 1245 | STATIC 1245 1246 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Static ); } 1246 | INLINE /* ANSI99 */1247 | INLINE /* C99 */ 1247 1248 /* INLINE is essentially a storage class specifier for functions, and hence, belongs here. */ 1248 1249 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); } 1249 | FORTRAN /* ANSI99 */1250 | FORTRAN /* C99 */ 1250 1251 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 1251 1252 ; … … 1270 1271 | VOID 1271 1272 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 1272 | BOOL /* ANSI99 */1273 | BOOL /* C99 */ 1273 1274 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1274 | COMPLEX /* ANSI99 */1275 | COMPLEX /* C99 */ 1275 1276 { $$ = DeclarationNode::newBasicType( DeclarationNode::Complex ); } 1276 | IMAGINARY /* ANSI99 */1277 | IMAGINARY /* C99 */ 1277 1278 { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); } 1278 1279 ; … … 1642 1643 ; 1643 1644 1644 /* There is an unreconcileable parsing problem between ANSI99 and CFA with respect to designators. The problem1645 /* There is an unreconcileable parsing problem between C99 and CFA with respect to designators. The problem 1645 1646 is use of '=' to separator the designator from the initializer value, as in: 1646 1647 … … 1653 1654 1654 1655 designation: 1655 designator_list ':' /* ANSI99, CFA uses ":" instead of "=" */1656 designator_list ':' /* C99, CFA uses ":" instead of "=" */ 1656 1657 | no_attr_identifier_or_typedef_name ':' /* GCC, field name */ 1657 1658 { $$ = new VarRefNode( $1 ); } 1658 1659 ; 1659 1660 1660 designator_list: /* ANSI99 */1661 designator_list: /* C99 */ 1661 1662 designator 1662 1663 | designator_list designator { $$ = (ExpressionNode *)($1->set_link( $2 )); } … … 1664 1665 1665 1666 designator: 1666 '.' no_attr_identifier_or_typedef_name /* ANSI99, field name */1667 '.' no_attr_identifier_or_typedef_name /* C99, field name */ 1667 1668 { $$ = new VarRefNode( $2 ); } 1668 | '[' push assignment_expression pop ']' /* ANSI99, single array element */1669 | '[' push assignment_expression pop ']' /* C99, single array element */ 1669 1670 /* assignment_expression used instead of constant_expression because of shift/reduce conflicts 1670 1671 with tuple. */ … … 2257 2258 2258 2259 /* This pattern parses a declaration for a parameter variable or function prototype that is not redefining a 2259 typedef name and allows the ANSI99 array options, which can only appear in a parameter list. The pattern2260 typedef name and allows the C99 array options, which can only appear in a parameter list. The pattern 2260 2261 precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays 2261 2262 and functions versus pointers to arrays and functions. */ … … 2303 2304 int f( int foo ); // redefine typedef name in new scope 2304 2305 2305 and allows the ANSI99 array options, which can only appear in a parameter list. In addition, the pattern2306 and allows the C99 array options, which can only appear in a parameter list. In addition, the pattern 2306 2307 handles the special meaning of parenthesis around a typedef name: 2307 2308 … … 2420 2421 '[' push assignment_expression pop ']' 2421 2422 { $$ = DeclarationNode::newArray( $3, 0, false ); } 2422 | '[' push '*' pop ']' /* ANSI99 */2423 | '[' push '*' pop ']' /* C99 */ 2423 2424 { $$ = DeclarationNode::newVarArray( 0 ); } 2424 2425 | multi_array_dimension '[' push assignment_expression pop ']' 2425 2426 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); } 2426 | multi_array_dimension '[' push '*' pop ']' /* ANSI99 */2427 | multi_array_dimension '[' push '*' pop ']' /* C99 */ 2427 2428 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 2428 2429 ; … … 2493 2494 { $$ = DeclarationNode::newArray( 0, 0, false ); } 2494 2495 // multi_array_dimension handles the '[' '*' ']' case 2495 | '[' push type_qualifier_list '*' pop ']' /* remaining ANSI99 */2496 | '[' push type_qualifier_list '*' pop ']' /* remaining C99 */ 2496 2497 { $$ = DeclarationNode::newVarArray( $3 ); } 2497 2498 | '[' push type_qualifier_list pop ']' … … 2551 2552 2552 2553 /* This pattern parses a new-style declaration for a parameter variable or function prototype that is either 2553 an identifier or typedef name and allows the ANSI99 array options, which can only appear in a parameter2554 an identifier or typedef name and allows the C99 array options, which can only appear in a parameter 2554 2555 list. */ 2555 2556 … … 2607 2608 2608 2609 new_array_parameter_1st_dimension: 2609 '[' push type_qualifier_list '*' pop ']' /* remaining ANSI99 */2610 '[' push type_qualifier_list '*' pop ']' /* remaining C99 */ 2610 2611 { $$ = DeclarationNode::newVarArray( $3 ); } 2611 2612 | '[' push type_qualifier_list assignment_expression pop ']' -
translator/Parser/lex.l
r0b8cd722 r6c3744e 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Dec 3 13:37:52 201413 * Update Count : 31 712 * Last Modified On : Sat Jan 17 09:15:03 2015 13 * Update Count : 318 14 14 */ 15 15 … … 180 180 181 181 /* keywords */ 182 _Alignas { KEYWORD_RETURN(ALIGNAS); } // C11 183 _Alignof { KEYWORD_RETURN(ALIGNOF); } // C11 182 184 __alignof { KEYWORD_RETURN(ALIGNOF); } // GCC 183 185 __alignof__ { KEYWORD_RETURN(ALIGNOF); } // GCC … … 185 187 __asm { KEYWORD_RETURN(ASM); } // GCC 186 188 __asm__ { KEYWORD_RETURN(ASM); } // GCC 189 _Atomic { KEYWORD_RETURN(ATOMIC); } // C11 187 190 __attribute { KEYWORD_RETURN(ATTRIBUTE); } // GCC 188 191 __attribute__ { KEYWORD_RETURN(ATTRIBUTE); } // GCC … … 217 220 fortran { KEYWORD_RETURN(FORTRAN); } 218 221 ftype { KEYWORD_RETURN(FTYPE); } // CFA 222 _Generic { KEYWORD_RETURN(GENERIC); } // C11 219 223 goto { KEYWORD_RETURN(GOTO); } 220 224 if { KEYWORD_RETURN(IF); } … … 229 233 long { KEYWORD_RETURN(LONG); } 230 234 lvalue { KEYWORD_RETURN(LVALUE); } // CFA 235 _Noreturn { KEYWORD_RETURN(NORETURN); } // C11 231 236 register { KEYWORD_RETURN(REGISTER); } 232 237 restrict { KEYWORD_RETURN(RESTRICT); } // C99 … … 240 245 sizeof { KEYWORD_RETURN(SIZEOF); } 241 246 static { KEYWORD_RETURN(STATIC); } 247 _Static_assert { KEYWORD_RETURN(STATICASSERT); } // C11 242 248 struct { KEYWORD_RETURN(STRUCT); } 243 249 switch { KEYWORD_RETURN(SWITCH); } 250 _Thread_local { KEYWORD_RETURN(THREADLOCAL); } // C11 244 251 throw { KEYWORD_RETURN(THROW); } // CFA 245 252 try { KEYWORD_RETURN(TRY); } // CFA
Note: See TracChangeset
for help on using the changeset viewer.