Changeset 32d6fdc for src/Parser
- Timestamp:
- Apr 13, 2023, 10:28:47 AM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 1b8fc06c
- Parents:
- 52f9804
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r52f9804 r32d6fdc 387 387 388 388 // Question 389 ast::Stmt * build_asm( const CodeLocation & location, bool voltile, ast::Expr* instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) {389 ast::Stmt * build_asm( const CodeLocation & location, bool is_volatile, ExpressionNode * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) { 390 390 std::vector<ast::ptr<ast::Expr>> out, in; 391 391 std::vector<ast::ptr<ast::ConstantExpr>> clob; … … 395 395 buildMoveList( clobber, clob ); 396 396 return new ast::AsmStmt( location, 397 voltile,398 instruction,397 is_volatile, 398 maybeMoveBuild( instruction ), 399 399 std::move( out ), 400 400 std::move( in ), -
src/Parser/StatementNode.h
r52f9804 r32d6fdc 94 94 ast::Stmt * build_compound( const CodeLocation &, StatementNode * first ); 95 95 StatementNode * maybe_build_compound( const CodeLocation &, StatementNode * first ); 96 ast::Stmt * build_asm( const CodeLocation &, bool voltile, ast::Expr* instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );96 ast::Stmt * build_asm( const CodeLocation &, bool is_volatile, ExpressionNode * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr ); 97 97 ast::Stmt * build_directive( const CodeLocation &, std::string * directive ); 98 98 ast::SuspendStmt * build_suspend( const CodeLocation &, StatementNode *, ast::SuspendStmt::Kind ); -
src/Parser/parser.yy
r52f9804 r32d6fdc 300 300 %union { 301 301 Token tok; 302 ParseNode * pn; 303 ExpressionNode * en; 302 ExpressionNode * expr; 304 303 DeclarationNode * decl; 305 304 ast::AggregateDecl::Aggregate aggKey; 306 305 ast::TypeDecl::Kind tclass; 307 StatementNode * s n;306 StatementNode * stmt; 308 307 ClauseNode * clause; 309 308 ast::WaitForStmt * wfs; 310 ast::Expr * constant;311 309 CondCtl * ifctl; 312 ForCtrl * fctl; 313 OperKinds compop; 314 LabelNode * label; 315 InitializerNode * in; 316 OperKinds op; 310 ForCtrl * forctl; 311 LabelNode * labels; 312 InitializerNode * init; 313 OperKinds oper; 317 314 std::string * str; 318 bool flag;319 EnumHiding hide;320 ast::ExceptionKind catch_kind;315 bool is_volatile; 316 EnumHiding enum_hiding; 317 ast::ExceptionKind except_kind; 321 318 ast::GenericExpr * genexpr; 322 319 } … … 384 381 %type<tok> identifier identifier_at identifier_or_type_name attr_name 385 382 %type<tok> quasi_keyword 386 %type< constant> string_literal383 %type<expr> string_literal 387 384 %type<str> string_literal_list 388 385 389 %type< hide> hide_opt visible_hide_opt386 %type<enum_hiding> hide_opt visible_hide_opt 390 387 391 388 // expressions 392 %type<e n> constant393 %type<e n> tuple tuple_expression_list394 %type<op > ptrref_operator unary_operator assignment_operator simple_assignment_operator compound_assignment_operator395 %type<e n> primary_expression postfix_expression unary_expression396 %type<e n> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression397 %type<e n> shift_expression relational_expression equality_expression398 %type<e n> AND_expression exclusive_OR_expression inclusive_OR_expression399 %type<e n> logical_AND_expression logical_OR_expression400 %type<e n> conditional_expression constant_expression assignment_expression assignment_expression_opt401 %type<e n> comma_expression comma_expression_opt402 %type<e n> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt389 %type<expr> constant 390 %type<expr> tuple tuple_expression_list 391 %type<oper> ptrref_operator unary_operator assignment_operator simple_assignment_operator compound_assignment_operator 392 %type<expr> primary_expression postfix_expression unary_expression 393 %type<expr> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression 394 %type<expr> shift_expression relational_expression equality_expression 395 %type<expr> AND_expression exclusive_OR_expression inclusive_OR_expression 396 %type<expr> logical_AND_expression logical_OR_expression 397 %type<expr> conditional_expression constant_expression assignment_expression assignment_expression_opt 398 %type<expr> comma_expression comma_expression_opt 399 %type<expr> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt 403 400 %type<ifctl> conditional_declaration 404 %type<f ctl> for_control_expression for_control_expression_list405 %type< compop> upupeq updown updowneq downupdowneq406 %type<e n> subrange401 %type<forctl> for_control_expression for_control_expression_list 402 %type<oper> upupeq updown updowneq downupdowneq 403 %type<expr> subrange 407 404 %type<decl> asm_name_opt 408 %type<e n> asm_operands_opt asm_operands_list asm_operand409 %type<label > label_list410 %type<e n> asm_clobbers_list_opt411 %type< flag> asm_volatile_opt412 %type<e n> handler_predicate_opt405 %type<expr> asm_operands_opt asm_operands_list asm_operand 406 %type<labels> label_list 407 %type<expr> asm_clobbers_list_opt 408 %type<is_volatile> asm_volatile_opt 409 %type<expr> handler_predicate_opt 413 410 %type<genexpr> generic_association generic_assoc_list 414 411 415 412 // statements 416 %type<s n> statement labeled_statement compound_statement417 %type<s n> statement_decl statement_decl_list statement_list_nodecl418 %type<s n> selection_statement if_statement413 %type<stmt> statement labeled_statement compound_statement 414 %type<stmt> statement_decl statement_decl_list statement_list_nodecl 415 %type<stmt> selection_statement if_statement 419 416 %type<clause> switch_clause_list_opt switch_clause_list 420 %type<e n> case_value417 %type<expr> case_value 421 418 %type<clause> case_clause case_value_list case_label case_label_list 422 %type<s n> iteration_statement jump_statement423 %type<s n> expression_statement asm_statement424 %type<s n> with_statement425 %type<e n> with_clause_opt426 %type<s n> exception_statement419 %type<stmt> iteration_statement jump_statement 420 %type<stmt> expression_statement asm_statement 421 %type<stmt> with_statement 422 %type<expr> with_clause_opt 423 %type<stmt> exception_statement 427 424 %type<clause> handler_clause finally_clause 428 %type< catch_kind> handler_key429 %type<s n> mutex_statement430 %type<e n> when_clause when_clause_opt waitfor waituntil timeout431 %type<s n> waitfor_statement waituntil_statement425 %type<except_kind> handler_key 426 %type<stmt> mutex_statement 427 %type<expr> when_clause when_clause_opt waitfor waituntil timeout 428 %type<stmt> waitfor_statement waituntil_statement 432 429 %type<wfs> wor_waitfor_clause waituntil_clause wand_waituntil_clause wor_waituntil_clause 433 430 … … 442 439 %type<decl> assertion assertion_list assertion_list_opt 443 440 444 %type<e n> bit_subrange_size_opt bit_subrange_size441 %type<expr> bit_subrange_size_opt bit_subrange_size 445 442 446 443 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type … … 455 452 456 453 %type<decl> enumerator_list enum_type enum_type_nobody 457 %type<in > enumerator_value_opt454 %type<init> enumerator_value_opt 458 455 459 456 %type<decl> external_definition external_definition_list external_definition_list_opt … … 462 459 463 460 %type<decl> field_declaration_list_opt field_declaration field_declaring_list_opt field_declarator field_abstract_list_opt field_abstract 464 %type<e n> field field_name_list field_name fraction_constants_opt461 %type<expr> field field_name_list field_name fraction_constants_opt 465 462 466 463 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 511 508 %type<decl> type_parameter type_parameter_list type_initializer_opt 512 509 513 %type<e n> type_parameters_opt type_list array_type_list510 %type<expr> type_parameters_opt type_list array_type_list 514 511 515 512 %type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list … … 522 519 523 520 // initializers 524 %type<in > initializer initializer_list_opt initializer_opt521 %type<init> initializer initializer_list_opt initializer_opt 525 522 526 523 // designators 527 %type<e n> designator designator_list designation524 %type<expr> designator designator_list designation 528 525 529 526 … … 647 644 648 645 string_literal: 649 string_literal_list { $$ = build_constantStr( yylloc, *$1); }646 string_literal_list { $$ = new ExpressionNode( build_constantStr( yylloc, *$1 ) ); } 650 647 ; 651 648 … … 742 739 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } 743 740 | string_literal '[' assignment_expression ']' // "abc"[3], 3["abc"] 744 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }741 { $$ = new ExpressionNode( build_binary_val( yylloc, OperKinds::Index, $1, $3 ) ); } 745 742 | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call 746 743 { … … 760 757 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); } 761 758 | string_literal '`' identifier // CFA, postfix call 762 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), new ExpressionNode( $1 )) ); }759 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); } 763 760 | postfix_expression '.' identifier 764 761 { $$ = new ExpressionNode( build_fieldSel( yylloc, $1, build_varref( yylloc, $3 ) ) ); } … … 860 857 | constant 861 858 | string_literal 862 { $$ = new ExpressionNode( $1 ); }859 { $$ = $1; } 863 860 | EXTENSION cast_expression // GCC 864 861 { $$ = $2->set_extension( true ); } … … 1810 1807 asm_operand: // GCC 1811 1808 string_literal '(' constant_expression ')' 1812 { $$ = new ExpressionNode( new ast::AsmExpr( yylloc, "", $1, maybeMoveBuild( $3 ) ) ); }1809 { $$ = new ExpressionNode( new ast::AsmExpr( yylloc, "", maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1813 1810 | '[' IDENTIFIER ']' string_literal '(' constant_expression ')' 1814 1811 { 1815 $$ = new ExpressionNode( new ast::AsmExpr( yylloc, *$2.str, $4, maybeMoveBuild( $6 ) ) );1812 $$ = new ExpressionNode( new ast::AsmExpr( yylloc, *$2.str, maybeMoveBuild( $4 ), maybeMoveBuild( $6 ) ) ); 1816 1813 delete $2.str; 1817 1814 } … … 1822 1819 { $$ = nullptr; } // use default argument 1823 1820 | string_literal 1824 { $$ = new ExpressionNode( $1 ); }1821 { $$ = $1; } 1825 1822 | asm_clobbers_list_opt ',' string_literal 1826 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( $3 ) )); }1823 { $$ = (ExpressionNode *)( $1->set_last( $3 ) ); } 1827 1824 ; 1828 1825 … … 1896 1893 static_assert: 1897 1894 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1898 { $$ = DeclarationNode::newStaticAssert( $3, $5); }1895 { $$ = DeclarationNode::newStaticAssert( $3, maybeMoveBuild( $5 ) ); } 1899 1896 | STATICASSERT '(' constant_expression ')' ';' // CFA 1900 1897 { $$ = DeclarationNode::newStaticAssert( $3, build_constantStr( yylloc, *new string( "\"\"" ) ) ); } … … 3326 3323 { 3327 3324 DeclarationNode * name = new DeclarationNode(); 3328 name->asmName = $3;3325 name->asmName = maybeMoveBuild( $3 ); 3329 3326 $$ = name->addQualifiers( $5 ); 3330 3327 }
Note: See TracChangeset
for help on using the changeset viewer.