Chromium Code Reviews| Index: tools/gn/parse_tree.h |
| diff --git a/tools/gn/parse_tree.h b/tools/gn/parse_tree.h |
| index 73ac0e5196f7fd3fce9b7552041730a6ce8cf4df..df12a7ad6d44f7d3470b66890f8ec50bda1d6e3e 100644 |
| --- a/tools/gn/parse_tree.h |
| +++ b/tools/gn/parse_tree.h |
| @@ -25,6 +25,7 @@ class LiteralNode; |
| class Scope; |
| class UnaryOpNode; |
| class BlockCommentNode; |
| +class EndNode; |
|
brettw
2014/09/26 21:37:34
Can you sort this list?
scottmg
2014/09/26 21:47:32
Done.
|
| class Comments { |
| public: |
| @@ -82,6 +83,7 @@ class ParseNode { |
| virtual const LiteralNode* AsLiteral() const; |
| virtual const UnaryOpNode* AsUnaryOp() const; |
| virtual const BlockCommentNode* AsBlockComment() const; |
| + virtual const EndNode* AsEnd() const; |
| virtual Value Execute(Scope* scope, Err* err) const = 0; |
| @@ -226,7 +228,8 @@ class BlockNode : public ParseNode { |
| virtual void Print(std::ostream& out, int indent) const OVERRIDE; |
| void set_begin_token(const Token& t) { begin_token_ = t; } |
| - void set_end_token(const Token& t) { end_token_ = t; } |
| + void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } |
| + const EndNode* End() const { return end_.get(); } |
| const std::vector<ParseNode*>& statements() const { return statements_; } |
| void append_statement(scoped_ptr<ParseNode> s) { |
| @@ -239,9 +242,10 @@ class BlockNode : public ParseNode { |
| private: |
| bool has_scope_; |
| - // Tokens corresponding to { and }, if any (may be NULL). |
| + // Tokens corresponding to { and }, if any (may be NULL). The end is stored |
| + // in a custom parse node so that it can have comments hung off of it. |
| Token begin_token_; |
| - Token end_token_; |
| + scoped_ptr<EndNode> end_; |
| // Owning pointers, use unique_ptr when we can use C++11. |
| std::vector<ParseNode*> statements_; |
| @@ -367,7 +371,8 @@ class ListNode : public ParseNode { |
| virtual void Print(std::ostream& out, int indent) const OVERRIDE; |
| void set_begin_token(const Token& t) { begin_token_ = t; } |
| - void set_end_token(const Token& t) { end_token_ = t; } |
| + void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } |
| + const EndNode* End() const { return end_.get(); } |
| void append_item(scoped_ptr<ParseNode> s) { |
| contents_.push_back(s.release()); |
| @@ -375,9 +380,10 @@ class ListNode : public ParseNode { |
| const std::vector<const ParseNode*>& contents() const { return contents_; } |
| private: |
| - // Tokens corresponding to the [ and ]. |
| + // Tokens corresponding to the [ and ]. The end token is stored in inside an |
| + // custom parse node so that it can have comments hung off of it. |
| Token begin_token_; |
| - Token end_token_; |
| + scoped_ptr<EndNode> end_; |
| // Owning pointers, use unique_ptr when we can use C++11. |
| std::vector<const ParseNode*> contents_; |
| @@ -469,4 +475,17 @@ class BlockCommentNode : public ParseNode { |
| DISALLOW_COPY_AND_ASSIGN(BlockCommentNode); |
| }; |
| +// EndNode --------------------------------------------------------------------- |
| + |
| +class EndNode : public IdentifierNode { |
|
brettw
2014/09/26 21:37:34
Can you document here what this is for? It's not s
scottmg
2014/09/26 21:47:32
Done.
|
| + public: |
| + EndNode(); |
| + EndNode(const Token& token); |
| + virtual ~EndNode(); |
| + |
| + virtual const IdentifierNode* AsIdentifier() const OVERRIDE; |
| + virtual const EndNode* AsEnd() const OVERRIDE; |
| + virtual void Print(std::ostream& out, int indent) const OVERRIDE; |
| +}; |
| + |
| #endif // TOOLS_GN_PARSE_TREE_H_ |