source: src/Parser/ParseNode.h @ 80fc78f

Last change on this file since 80fc78f was c468150, checked in by Andrew Beach <ajbeach@…>, 19 months ago

Split up ParseNode?.h so that headers match implementation. May have a bit less to include total because of it.

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[b87a5ed]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[974906e2]7// ParseNode.h --
[b87a5ed]8//
9// Author           : Rodolfo G. Esteves
10// Created On       : Sat May 16 13:28:16 2015
[bb7422a]11// Last Modified By : Andrew Beach
12// Last Modified On : Mon Apr  3 17:55:00 2023
13// Update Count     : 942
[b87a5ed]14//
15
[6b0b624]16#pragma once
[51b7345]17
[d180746]18#include <algorithm>               // for move
19#include <cassert>                 // for assert, assertf
20#include <iosfwd>                  // for ostream
21#include <iterator>                // for back_insert_iterator
22#include <list>                    // for list
23#include <memory>                  // for unique_ptr, pointer_traits
24#include <string>                  // for string
[51b7345]25
[bb7422a]26#include "AST/Expr.hpp"            // for Expr, NameExpr LogicalFlag
27#include "AST/Fwd.hpp"             // for ptr, Decl, DeclWithType,
28#include "AST/Stmt.hpp"            // for Stmt
[21f0aa8]29#include "Common/CodeLocation.h"   // for CodeLocation
[d180746]30#include "Common/SemanticError.h"  // for SemanticError
[be9288a]31#include "Common/UniqueName.h"     // for UniqueName
[4b60b28]32#include "Common/utility.h"        // for maybeClone
[bb7422a]33#include "Parser/parserutility.h"  // for maybeBuild, maybeCopy
[d180746]34
35class Attribute;
36class Declaration;
[b2e0df3]37struct DeclarationNode;
[d180746]38class DeclarationWithType;
39class Initializer;
[c468150]40class InitializerNode;
[a6e5091]41class ExpressionNode;
[b2e0df3]42struct StatementNode;
[51b7345]43
[7880579]44//##############################################################################
45
[d48e529]46typedef CodeLocation YYLTYPE;
47#define YYLTYPE_IS_DECLARED 1 /* alert the parser that we have our own definition */
48
49extern YYLTYPE yylloc;
[294647b]50
[51b7345]51class ParseNode {
[bdd516a]52  public:
[99cad3aa]53        ParseNode() {};
[2298f728]54        virtual ~ParseNode() { delete next; delete name; };
[b6424d9]55        virtual ParseNode * clone() const = 0;
[51b7345]56
[b6424d9]57        ParseNode * get_next() const { return next; }
58        ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; }
[1b772749]59
[b6424d9]60        ParseNode * get_last() {
61                ParseNode * current;
[2298f728]62                for ( current = this; current->get_next() != nullptr; current = current->get_next() );
[99cad3aa]63                return current;
64        }
[b6424d9]65        ParseNode * set_last( ParseNode * newlast ) {
[2298f728]66                if ( newlast != nullptr ) get_last()->set_next( newlast );
[99cad3aa]67                return this;
68        }
[51b7345]69
[f2f512ba]70        virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}
71        virtual void printList( std::ostream & os, int indent = 0 ) const {
[e4bc986]72                print( os, indent );
73                if ( next ) next->print( os, indent );
74        }
[1b772749]75
[b87a5ed]76        static int indent_by;
[7880579]77
[b6424d9]78        ParseNode * next = nullptr;
[25bca42]79        const std::string * name = nullptr;
[d48e529]80        CodeLocation location = yylloc;
[7880579]81}; // ParseNode
[51b7345]82
[e5f2a67]83// Must harmonize with OperName.
[d9e2280]84enum class OperKinds {
85        // diadic
[e5f2a67]86        SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
[d9e2280]87        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
[e5f2a67]88        Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
[d9e2280]89        Index, Range,
90        // monadic
[5809461]91        UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost,
[d9e2280]92        Ctor, Dtor,
[c1c1112]93}; // OperKinds
[51b7345]94
[7cf8006]95enum class EnumHiding { Visible, Hide };
96
[e82aa9df]97struct LabelNode {
[bb7422a]98        std::vector<ast::Label> labels;
[e82aa9df]99};
100
[c8dfcd3]101std::ostream & operator<<( std::ostream & out, const ParseNode * node );
[7ecbb7e]102
[51b7345]103// Local Variables: //
[b87a5ed]104// tab-width: 4 //
105// mode: c++ //
106// compile-command: "make install" //
[51b7345]107// End: //
Note: See TracBrowser for help on using the repository browser.