Ignore:
Timestamp:
Mar 9, 2023, 2:37:53 PM (14 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
fed03b3
Parents:
a29477f
Message:

Pre-translation pass on the parser. Entirely code readability improvements, no behaviour (on a larger scale) should be effected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    ra29477f r702e826  
    137137        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
    138138
    139         Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
     139        Expression * build() const {
     140                Expression * node = const_cast<ExpressionNode *>(this)->expr.release();
     141                node->set_extension( this->get_extension() );
     142                node->location = this->location;
     143                return node;
     144        }
    140145
    141146        std::unique_ptr<Expression> expr;                                       // public because of lifetime implications
     
    143148        bool extension = false;
    144149}; // ExpressionNode
    145 
    146 template< typename T >
    147 struct maybeBuild_t< Expression, T > {
    148         static inline Expression * doit( const T * orig ) {
    149                 if ( orig ) {
    150                         Expression * p = orig->build();
    151                         p->set_extension( orig->get_extension() );
    152                         p->location = orig->location;
    153                         return p;
    154                 } else {
    155                         return nullptr;
    156                 } // if
    157         }
    158 };
    159150
    160151// Must harmonize with OperName.
     
    199190Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind );
    200191Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node );
    201 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node );
    202192Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
    203193Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );
     
    213203struct DeclarationNode : public ParseNode {
    214204        // These enumerations must harmonize with their names in DeclarationNode.cc.
    215         enum BasicType { Void, Bool, Char, Int, Int128,
    216                                          Float, Double, LongDouble, uuFloat80, uuFloat128,
    217                                          uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, NoBasicType };
     205        enum BasicType {
     206                Void, Bool, Char, Int, Int128,
     207                Float, Double, LongDouble, uuFloat80, uuFloat128,
     208                uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x,
     209                NoBasicType
     210        };
    218211        static const char * basicTypeNames[];
    219212        enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message
     
    451444        while ( cur ) {
    452445                try {
    453                         SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild< typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) );
     446                        SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild( cur ) );
    454447                        if ( result ) {
    455448                                result->location = cur->location;
Note: See TracChangeset for help on using the changeset viewer.