]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/InterpreterRuleContext.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / InterpreterRuleContext.h
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #pragma once
7
8 #include "ParserRuleContext.h"
9
10 namespace antlr4 {
11
12   /**
13    * This class extends {@link ParserRuleContext} by allowing the value of
14    * {@link #getRuleIndex} to be explicitly set for the context.
15    *
16    * <p>
17    * {@link ParserRuleContext} does not include field storage for the rule index
18    * since the context classes created by the code generator override the
19    * {@link #getRuleIndex} method to return the correct value for that context.
20    * Since the parser interpreter does not use the context classes generated for a
21    * parser, this class (with slightly more memory overhead per node) is used to
22    * provide equivalent functionality.</p>
23    */
24   class ANTLR4CPP_PUBLIC InterpreterRuleContext : public ParserRuleContext {
25   public:
26     InterpreterRuleContext();
27
28     /**
29      * Constructs a new {@link InterpreterRuleContext} with the specified
30      * parent, invoking state, and rule index.
31      *
32      * @param parent The parent context.
33      * @param invokingStateNumber The invoking state number.
34      * @param ruleIndex The rule index for the current context.
35      */
36     InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex);
37
38     virtual size_t getRuleIndex() const override;
39
40   protected:
41     /** This is the backing field for {@link #getRuleIndex}. */
42     const size_t _ruleIndex = INVALID_INDEX;
43 };
44
45 } // namespace antlr4