Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | // All rights reserved. This program and the accompanying materials | |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef _Asn_Block_HH | |
9 | #define _Asn_Block_HH | |
10 | ||
11 | #include "../AST.hh" | |
12 | ||
13 | namespace Asn { | |
14 | ||
15 | using namespace Common; | |
16 | ||
17 | extern Node *parsed_node; | |
18 | ||
19 | class TokenBuf; | |
20 | ||
21 | /** | |
22 | * A node which represents an unparsed block. When parsing a file, | |
23 | * it is not always known what to expect when a block begins | |
24 | * ('{'). So, the tokens of the block are pushed into a TokenBuf. | |
25 | * Block is a wrapping-class for TokenBuf. As Block is a | |
26 | * Node-descendant, it can be used in the AST. | |
27 | * | |
28 | * After the examination of the block's context, it is known what to | |
29 | * expect in the block, so the block can be parsed. | |
30 | */ | |
31 | class Block : public Node, public Location { | |
32 | private: | |
33 | /** The wrapped token buffer. */ | |
34 | TokenBuf *tokenbuf; | |
35 | ||
36 | Block(const Block& p); | |
37 | public: | |
38 | /** Constructs a Block from a TokenBuf. */ | |
39 | Block(TokenBuf *p_tokenbuf); | |
40 | /** The destructor. */ | |
41 | virtual ~Block(); | |
42 | virtual Block* clone() const | |
43 | {return new Block(*this);} | |
44 | /** Returns the TokenBuf. You can modify (put tokens into/remove | |
45 | * tokens from) it, but do not delete the buffer! */ | |
46 | TokenBuf* get_TokenBuf() {return tokenbuf;} | |
47 | /** Parses the block. The expected content is expressed by \a | |
48 | * kw_token, which is a constant defined in the grammar | |
49 | * (asn1p.y). Returns an AST-subtree. To use this function, you | |
50 | * have to include the TokenBuf header, too. */ | |
51 | Node* parse(int kw_token); | |
52 | ||
53 | virtual void dump(unsigned) const; | |
54 | }; | |
55 | ||
56 | } // namespace Asn | |
57 | ||
58 | #endif /* _Asn_Block_HH */ |