| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_GN_PARSE_TREE_H_ | 5 #ifndef TOOLS_GN_PARSE_TREE_H_ |
| 6 #define TOOLS_GN_PARSE_TREE_H_ | 6 #define TOOLS_GN_PARSE_TREE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // identifier. So you can't do things like: | 132 // identifier. So you can't do things like: |
| 133 // function_call()[1] | 133 // function_call()[1] |
| 134 // a = b.c.d | 134 // a = b.c.d |
| 135 // These are easier to implement if we needed them but given the very limited | 135 // These are easier to implement if we needed them but given the very limited |
| 136 // use cases for this, it hasn't seemed worth the bother. | 136 // use cases for this, it hasn't seemed worth the bother. |
| 137 class AccessorNode : public ParseNode { | 137 class AccessorNode : public ParseNode { |
| 138 public: | 138 public: |
| 139 AccessorNode(); | 139 AccessorNode(); |
| 140 virtual ~AccessorNode(); | 140 virtual ~AccessorNode(); |
| 141 | 141 |
| 142 virtual const AccessorNode* AsAccessor() const OVERRIDE; | 142 virtual const AccessorNode* AsAccessor() const override; |
| 143 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 143 virtual Value Execute(Scope* scope, Err* err) const override; |
| 144 virtual LocationRange GetRange() const OVERRIDE; | 144 virtual LocationRange GetRange() const override; |
| 145 virtual Err MakeErrorDescribing( | 145 virtual Err MakeErrorDescribing( |
| 146 const std::string& msg, | 146 const std::string& msg, |
| 147 const std::string& help = std::string()) const OVERRIDE; | 147 const std::string& help = std::string()) const override; |
| 148 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 148 virtual void Print(std::ostream& out, int indent) const override; |
| 149 | 149 |
| 150 // Base is the thing on the left of the [] or dot, currently always required | 150 // Base is the thing on the left of the [] or dot, currently always required |
| 151 // to be an identifier token. | 151 // to be an identifier token. |
| 152 const Token& base() const { return base_; } | 152 const Token& base() const { return base_; } |
| 153 void set_base(const Token& b) { base_ = b; } | 153 void set_base(const Token& b) { base_ = b; } |
| 154 | 154 |
| 155 // Index is the expression inside the []. Will be null if member is set. | 155 // Index is the expression inside the []. Will be null if member is set. |
| 156 const ParseNode* index() const { return index_.get(); } | 156 const ParseNode* index() const { return index_.get(); } |
| 157 void set_index(scoped_ptr<ParseNode> i) { index_ = i.Pass(); } | 157 void set_index(scoped_ptr<ParseNode> i) { index_ = i.Pass(); } |
| 158 | 158 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 175 DISALLOW_COPY_AND_ASSIGN(AccessorNode); | 175 DISALLOW_COPY_AND_ASSIGN(AccessorNode); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 // BinaryOpNode ---------------------------------------------------------------- | 178 // BinaryOpNode ---------------------------------------------------------------- |
| 179 | 179 |
| 180 class BinaryOpNode : public ParseNode { | 180 class BinaryOpNode : public ParseNode { |
| 181 public: | 181 public: |
| 182 BinaryOpNode(); | 182 BinaryOpNode(); |
| 183 virtual ~BinaryOpNode(); | 183 virtual ~BinaryOpNode(); |
| 184 | 184 |
| 185 virtual const BinaryOpNode* AsBinaryOp() const OVERRIDE; | 185 virtual const BinaryOpNode* AsBinaryOp() const override; |
| 186 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 186 virtual Value Execute(Scope* scope, Err* err) const override; |
| 187 virtual LocationRange GetRange() const OVERRIDE; | 187 virtual LocationRange GetRange() const override; |
| 188 virtual Err MakeErrorDescribing( | 188 virtual Err MakeErrorDescribing( |
| 189 const std::string& msg, | 189 const std::string& msg, |
| 190 const std::string& help = std::string()) const OVERRIDE; | 190 const std::string& help = std::string()) const override; |
| 191 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 191 virtual void Print(std::ostream& out, int indent) const override; |
| 192 | 192 |
| 193 const Token& op() const { return op_; } | 193 const Token& op() const { return op_; } |
| 194 void set_op(const Token& t) { op_ = t; } | 194 void set_op(const Token& t) { op_ = t; } |
| 195 | 195 |
| 196 const ParseNode* left() const { return left_.get(); } | 196 const ParseNode* left() const { return left_.get(); } |
| 197 void set_left(scoped_ptr<ParseNode> left) { | 197 void set_left(scoped_ptr<ParseNode> left) { |
| 198 left_ = left.Pass(); | 198 left_ = left.Pass(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 const ParseNode* right() const { return right_.get(); } | 201 const ParseNode* right() const { return right_.get(); } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 // BlockNode ------------------------------------------------------------------- | 214 // BlockNode ------------------------------------------------------------------- |
| 215 | 215 |
| 216 class BlockNode : public ParseNode { | 216 class BlockNode : public ParseNode { |
| 217 public: | 217 public: |
| 218 // Set has_scope if this block introduces a nested scope. | 218 // Set has_scope if this block introduces a nested scope. |
| 219 explicit BlockNode(bool has_scope); | 219 explicit BlockNode(bool has_scope); |
| 220 virtual ~BlockNode(); | 220 virtual ~BlockNode(); |
| 221 | 221 |
| 222 virtual const BlockNode* AsBlock() const OVERRIDE; | 222 virtual const BlockNode* AsBlock() const override; |
| 223 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 223 virtual Value Execute(Scope* scope, Err* err) const override; |
| 224 virtual LocationRange GetRange() const OVERRIDE; | 224 virtual LocationRange GetRange() const override; |
| 225 virtual Err MakeErrorDescribing( | 225 virtual Err MakeErrorDescribing( |
| 226 const std::string& msg, | 226 const std::string& msg, |
| 227 const std::string& help = std::string()) const OVERRIDE; | 227 const std::string& help = std::string()) const override; |
| 228 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 228 virtual void Print(std::ostream& out, int indent) const override; |
| 229 | 229 |
| 230 void set_begin_token(const Token& t) { begin_token_ = t; } | 230 void set_begin_token(const Token& t) { begin_token_ = t; } |
| 231 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } | 231 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } |
| 232 const EndNode* End() const { return end_.get(); } | 232 const EndNode* End() const { return end_.get(); } |
| 233 | 233 |
| 234 const std::vector<ParseNode*>& statements() const { return statements_; } | 234 const std::vector<ParseNode*>& statements() const { return statements_; } |
| 235 void append_statement(scoped_ptr<ParseNode> s) { | 235 void append_statement(scoped_ptr<ParseNode> s) { |
| 236 statements_.push_back(s.release()); | 236 statements_.push_back(s.release()); |
| 237 } | 237 } |
| 238 | 238 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 253 DISALLOW_COPY_AND_ASSIGN(BlockNode); | 253 DISALLOW_COPY_AND_ASSIGN(BlockNode); |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 // ConditionNode --------------------------------------------------------------- | 256 // ConditionNode --------------------------------------------------------------- |
| 257 | 257 |
| 258 class ConditionNode : public ParseNode { | 258 class ConditionNode : public ParseNode { |
| 259 public: | 259 public: |
| 260 ConditionNode(); | 260 ConditionNode(); |
| 261 virtual ~ConditionNode(); | 261 virtual ~ConditionNode(); |
| 262 | 262 |
| 263 virtual const ConditionNode* AsConditionNode() const OVERRIDE; | 263 virtual const ConditionNode* AsConditionNode() const override; |
| 264 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 264 virtual Value Execute(Scope* scope, Err* err) const override; |
| 265 virtual LocationRange GetRange() const OVERRIDE; | 265 virtual LocationRange GetRange() const override; |
| 266 virtual Err MakeErrorDescribing( | 266 virtual Err MakeErrorDescribing( |
| 267 const std::string& msg, | 267 const std::string& msg, |
| 268 const std::string& help = std::string()) const OVERRIDE; | 268 const std::string& help = std::string()) const override; |
| 269 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 269 virtual void Print(std::ostream& out, int indent) const override; |
| 270 | 270 |
| 271 void set_if_token(const Token& token) { if_token_ = token; } | 271 void set_if_token(const Token& token) { if_token_ = token; } |
| 272 | 272 |
| 273 const ParseNode* condition() const { return condition_.get(); } | 273 const ParseNode* condition() const { return condition_.get(); } |
| 274 void set_condition(scoped_ptr<ParseNode> c) { | 274 void set_condition(scoped_ptr<ParseNode> c) { |
| 275 condition_ = c.Pass(); | 275 condition_ = c.Pass(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 const BlockNode* if_true() const { return if_true_.get(); } | 278 const BlockNode* if_true() const { return if_true_.get(); } |
| 279 void set_if_true(scoped_ptr<BlockNode> t) { | 279 void set_if_true(scoped_ptr<BlockNode> t) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 298 DISALLOW_COPY_AND_ASSIGN(ConditionNode); | 298 DISALLOW_COPY_AND_ASSIGN(ConditionNode); |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 // FunctionCallNode ------------------------------------------------------------ | 301 // FunctionCallNode ------------------------------------------------------------ |
| 302 | 302 |
| 303 class FunctionCallNode : public ParseNode { | 303 class FunctionCallNode : public ParseNode { |
| 304 public: | 304 public: |
| 305 FunctionCallNode(); | 305 FunctionCallNode(); |
| 306 virtual ~FunctionCallNode(); | 306 virtual ~FunctionCallNode(); |
| 307 | 307 |
| 308 virtual const FunctionCallNode* AsFunctionCall() const OVERRIDE; | 308 virtual const FunctionCallNode* AsFunctionCall() const override; |
| 309 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 309 virtual Value Execute(Scope* scope, Err* err) const override; |
| 310 virtual LocationRange GetRange() const OVERRIDE; | 310 virtual LocationRange GetRange() const override; |
| 311 virtual Err MakeErrorDescribing( | 311 virtual Err MakeErrorDescribing( |
| 312 const std::string& msg, | 312 const std::string& msg, |
| 313 const std::string& help = std::string()) const OVERRIDE; | 313 const std::string& help = std::string()) const override; |
| 314 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 314 virtual void Print(std::ostream& out, int indent) const override; |
| 315 | 315 |
| 316 const Token& function() const { return function_; } | 316 const Token& function() const { return function_; } |
| 317 void set_function(Token t) { function_ = t; } | 317 void set_function(Token t) { function_ = t; } |
| 318 | 318 |
| 319 const ListNode* args() const { return args_.get(); } | 319 const ListNode* args() const { return args_.get(); } |
| 320 void set_args(scoped_ptr<ListNode> a) { args_ = a.Pass(); } | 320 void set_args(scoped_ptr<ListNode> a) { args_ = a.Pass(); } |
| 321 | 321 |
| 322 const BlockNode* block() const { return block_.get(); } | 322 const BlockNode* block() const { return block_.get(); } |
| 323 void set_block(scoped_ptr<BlockNode> b) { block_ = b.Pass(); } | 323 void set_block(scoped_ptr<BlockNode> b) { block_ = b.Pass(); } |
| 324 | 324 |
| 325 private: | 325 private: |
| 326 Token function_; | 326 Token function_; |
| 327 scoped_ptr<ListNode> args_; | 327 scoped_ptr<ListNode> args_; |
| 328 scoped_ptr<BlockNode> block_; // May be null. | 328 scoped_ptr<BlockNode> block_; // May be null. |
| 329 | 329 |
| 330 DISALLOW_COPY_AND_ASSIGN(FunctionCallNode); | 330 DISALLOW_COPY_AND_ASSIGN(FunctionCallNode); |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 // IdentifierNode -------------------------------------------------------------- | 333 // IdentifierNode -------------------------------------------------------------- |
| 334 | 334 |
| 335 class IdentifierNode : public ParseNode { | 335 class IdentifierNode : public ParseNode { |
| 336 public: | 336 public: |
| 337 IdentifierNode(); | 337 IdentifierNode(); |
| 338 IdentifierNode(const Token& token); | 338 IdentifierNode(const Token& token); |
| 339 virtual ~IdentifierNode(); | 339 virtual ~IdentifierNode(); |
| 340 | 340 |
| 341 virtual const IdentifierNode* AsIdentifier() const OVERRIDE; | 341 virtual const IdentifierNode* AsIdentifier() const override; |
| 342 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 342 virtual Value Execute(Scope* scope, Err* err) const override; |
| 343 virtual LocationRange GetRange() const OVERRIDE; | 343 virtual LocationRange GetRange() const override; |
| 344 virtual Err MakeErrorDescribing( | 344 virtual Err MakeErrorDescribing( |
| 345 const std::string& msg, | 345 const std::string& msg, |
| 346 const std::string& help = std::string()) const OVERRIDE; | 346 const std::string& help = std::string()) const override; |
| 347 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 347 virtual void Print(std::ostream& out, int indent) const override; |
| 348 | 348 |
| 349 const Token& value() const { return value_; } | 349 const Token& value() const { return value_; } |
| 350 void set_value(const Token& t) { value_ = t; } | 350 void set_value(const Token& t) { value_ = t; } |
| 351 | 351 |
| 352 private: | 352 private: |
| 353 Token value_; | 353 Token value_; |
| 354 | 354 |
| 355 DISALLOW_COPY_AND_ASSIGN(IdentifierNode); | 355 DISALLOW_COPY_AND_ASSIGN(IdentifierNode); |
| 356 }; | 356 }; |
| 357 | 357 |
| 358 // ListNode -------------------------------------------------------------------- | 358 // ListNode -------------------------------------------------------------------- |
| 359 | 359 |
| 360 class ListNode : public ParseNode { | 360 class ListNode : public ParseNode { |
| 361 public: | 361 public: |
| 362 ListNode(); | 362 ListNode(); |
| 363 virtual ~ListNode(); | 363 virtual ~ListNode(); |
| 364 | 364 |
| 365 virtual const ListNode* AsList() const OVERRIDE; | 365 virtual const ListNode* AsList() const override; |
| 366 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 366 virtual Value Execute(Scope* scope, Err* err) const override; |
| 367 virtual LocationRange GetRange() const OVERRIDE; | 367 virtual LocationRange GetRange() const override; |
| 368 virtual Err MakeErrorDescribing( | 368 virtual Err MakeErrorDescribing( |
| 369 const std::string& msg, | 369 const std::string& msg, |
| 370 const std::string& help = std::string()) const OVERRIDE; | 370 const std::string& help = std::string()) const override; |
| 371 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 371 virtual void Print(std::ostream& out, int indent) const override; |
| 372 | 372 |
| 373 void set_begin_token(const Token& t) { begin_token_ = t; } | 373 void set_begin_token(const Token& t) { begin_token_ = t; } |
| 374 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } | 374 void set_end(scoped_ptr<EndNode> e) { end_ = e.Pass(); } |
| 375 const EndNode* End() const { return end_.get(); } | 375 const EndNode* End() const { return end_.get(); } |
| 376 | 376 |
| 377 void append_item(scoped_ptr<ParseNode> s) { | 377 void append_item(scoped_ptr<ParseNode> s) { |
| 378 contents_.push_back(s.release()); | 378 contents_.push_back(s.release()); |
| 379 } | 379 } |
| 380 const std::vector<const ParseNode*>& contents() const { return contents_; } | 380 const std::vector<const ParseNode*>& contents() const { return contents_; } |
| 381 | 381 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 // LiteralNode ----------------------------------------------------------------- | 394 // LiteralNode ----------------------------------------------------------------- |
| 395 | 395 |
| 396 class LiteralNode : public ParseNode { | 396 class LiteralNode : public ParseNode { |
| 397 public: | 397 public: |
| 398 LiteralNode(); | 398 LiteralNode(); |
| 399 LiteralNode(const Token& token); | 399 LiteralNode(const Token& token); |
| 400 virtual ~LiteralNode(); | 400 virtual ~LiteralNode(); |
| 401 | 401 |
| 402 virtual const LiteralNode* AsLiteral() const OVERRIDE; | 402 virtual const LiteralNode* AsLiteral() const override; |
| 403 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 403 virtual Value Execute(Scope* scope, Err* err) const override; |
| 404 virtual LocationRange GetRange() const OVERRIDE; | 404 virtual LocationRange GetRange() const override; |
| 405 virtual Err MakeErrorDescribing( | 405 virtual Err MakeErrorDescribing( |
| 406 const std::string& msg, | 406 const std::string& msg, |
| 407 const std::string& help = std::string()) const OVERRIDE; | 407 const std::string& help = std::string()) const override; |
| 408 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 408 virtual void Print(std::ostream& out, int indent) const override; |
| 409 | 409 |
| 410 const Token& value() const { return value_; } | 410 const Token& value() const { return value_; } |
| 411 void set_value(const Token& t) { value_ = t; } | 411 void set_value(const Token& t) { value_ = t; } |
| 412 | 412 |
| 413 private: | 413 private: |
| 414 Token value_; | 414 Token value_; |
| 415 | 415 |
| 416 DISALLOW_COPY_AND_ASSIGN(LiteralNode); | 416 DISALLOW_COPY_AND_ASSIGN(LiteralNode); |
| 417 }; | 417 }; |
| 418 | 418 |
| 419 // UnaryOpNode ----------------------------------------------------------------- | 419 // UnaryOpNode ----------------------------------------------------------------- |
| 420 | 420 |
| 421 class UnaryOpNode : public ParseNode { | 421 class UnaryOpNode : public ParseNode { |
| 422 public: | 422 public: |
| 423 UnaryOpNode(); | 423 UnaryOpNode(); |
| 424 virtual ~UnaryOpNode(); | 424 virtual ~UnaryOpNode(); |
| 425 | 425 |
| 426 virtual const UnaryOpNode* AsUnaryOp() const OVERRIDE; | 426 virtual const UnaryOpNode* AsUnaryOp() const override; |
| 427 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 427 virtual Value Execute(Scope* scope, Err* err) const override; |
| 428 virtual LocationRange GetRange() const OVERRIDE; | 428 virtual LocationRange GetRange() const override; |
| 429 virtual Err MakeErrorDescribing( | 429 virtual Err MakeErrorDescribing( |
| 430 const std::string& msg, | 430 const std::string& msg, |
| 431 const std::string& help = std::string()) const OVERRIDE; | 431 const std::string& help = std::string()) const override; |
| 432 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 432 virtual void Print(std::ostream& out, int indent) const override; |
| 433 | 433 |
| 434 const Token& op() const { return op_; } | 434 const Token& op() const { return op_; } |
| 435 void set_op(const Token& t) { op_ = t; } | 435 void set_op(const Token& t) { op_ = t; } |
| 436 | 436 |
| 437 const ParseNode* operand() const { return operand_.get(); } | 437 const ParseNode* operand() const { return operand_.get(); } |
| 438 void set_operand(scoped_ptr<ParseNode> operand) { | 438 void set_operand(scoped_ptr<ParseNode> operand) { |
| 439 operand_ = operand.Pass(); | 439 operand_ = operand.Pass(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 private: | 442 private: |
| 443 Token op_; | 443 Token op_; |
| 444 scoped_ptr<ParseNode> operand_; | 444 scoped_ptr<ParseNode> operand_; |
| 445 | 445 |
| 446 DISALLOW_COPY_AND_ASSIGN(UnaryOpNode); | 446 DISALLOW_COPY_AND_ASSIGN(UnaryOpNode); |
| 447 }; | 447 }; |
| 448 | 448 |
| 449 // BlockCommentNode ------------------------------------------------------------ | 449 // BlockCommentNode ------------------------------------------------------------ |
| 450 | 450 |
| 451 // This node type is only used for standalone comments (that is, those not | 451 // This node type is only used for standalone comments (that is, those not |
| 452 // specifically attached to another syntax element. The most common of these | 452 // specifically attached to another syntax element. The most common of these |
| 453 // is a standard header block. This node contains only the last line of such | 453 // is a standard header block. This node contains only the last line of such |
| 454 // a comment block as the anchor, and other lines of the block comment are | 454 // a comment block as the anchor, and other lines of the block comment are |
| 455 // hung off of it as Before comments, similar to other syntax elements. | 455 // hung off of it as Before comments, similar to other syntax elements. |
| 456 class BlockCommentNode : public ParseNode { | 456 class BlockCommentNode : public ParseNode { |
| 457 public: | 457 public: |
| 458 BlockCommentNode(); | 458 BlockCommentNode(); |
| 459 virtual ~BlockCommentNode(); | 459 virtual ~BlockCommentNode(); |
| 460 | 460 |
| 461 virtual const BlockCommentNode* AsBlockComment() const OVERRIDE; | 461 virtual const BlockCommentNode* AsBlockComment() const override; |
| 462 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 462 virtual Value Execute(Scope* scope, Err* err) const override; |
| 463 virtual LocationRange GetRange() const OVERRIDE; | 463 virtual LocationRange GetRange() const override; |
| 464 virtual Err MakeErrorDescribing( | 464 virtual Err MakeErrorDescribing( |
| 465 const std::string& msg, | 465 const std::string& msg, |
| 466 const std::string& help = std::string()) const OVERRIDE; | 466 const std::string& help = std::string()) const override; |
| 467 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 467 virtual void Print(std::ostream& out, int indent) const override; |
| 468 | 468 |
| 469 const Token& comment() const { return comment_; } | 469 const Token& comment() const { return comment_; } |
| 470 void set_comment(const Token& t) { comment_ = t; } | 470 void set_comment(const Token& t) { comment_ = t; } |
| 471 | 471 |
| 472 private: | 472 private: |
| 473 Token comment_; | 473 Token comment_; |
| 474 | 474 |
| 475 DISALLOW_COPY_AND_ASSIGN(BlockCommentNode); | 475 DISALLOW_COPY_AND_ASSIGN(BlockCommentNode); |
| 476 }; | 476 }; |
| 477 | 477 |
| 478 // EndNode --------------------------------------------------------------------- | 478 // EndNode --------------------------------------------------------------------- |
| 479 | 479 |
| 480 // This node type is used as the end_ object for lists and blocks (rather than | 480 // This node type is used as the end_ object for lists and blocks (rather than |
| 481 // just the end ']', '}', or ')' token). This is so that during formatting | 481 // just the end ']', '}', or ')' token). This is so that during formatting |
| 482 // traversal there is a node that appears at the end of the block to which | 482 // traversal there is a node that appears at the end of the block to which |
| 483 // comments can be attached. | 483 // comments can be attached. |
| 484 class EndNode : public ParseNode { | 484 class EndNode : public ParseNode { |
| 485 public: | 485 public: |
| 486 EndNode(const Token& token); | 486 EndNode(const Token& token); |
| 487 virtual ~EndNode(); | 487 virtual ~EndNode(); |
| 488 | 488 |
| 489 virtual const EndNode* AsEnd() const OVERRIDE; | 489 virtual const EndNode* AsEnd() const override; |
| 490 virtual Value Execute(Scope* scope, Err* err) const OVERRIDE; | 490 virtual Value Execute(Scope* scope, Err* err) const override; |
| 491 virtual LocationRange GetRange() const OVERRIDE; | 491 virtual LocationRange GetRange() const override; |
| 492 virtual Err MakeErrorDescribing( | 492 virtual Err MakeErrorDescribing( |
| 493 const std::string& msg, | 493 const std::string& msg, |
| 494 const std::string& help = std::string()) const OVERRIDE; | 494 const std::string& help = std::string()) const override; |
| 495 virtual void Print(std::ostream& out, int indent) const OVERRIDE; | 495 virtual void Print(std::ostream& out, int indent) const override; |
| 496 | 496 |
| 497 const Token& value() const { return value_; } | 497 const Token& value() const { return value_; } |
| 498 void set_value(const Token& t) { value_ = t; } | 498 void set_value(const Token& t) { value_ = t; } |
| 499 | 499 |
| 500 private: | 500 private: |
| 501 Token value_; | 501 Token value_; |
| 502 | 502 |
| 503 DISALLOW_COPY_AND_ASSIGN(EndNode); | 503 DISALLOW_COPY_AND_ASSIGN(EndNode); |
| 504 }; | 504 }; |
| 505 | 505 |
| 506 #endif // TOOLS_GN_PARSE_TREE_H_ | 506 #endif // TOOLS_GN_PARSE_TREE_H_ |
| OLD | NEW |