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.
8 #include "ParserRuleContext.h"
13 * This class extends {@link ParserRuleContext} by allowing the value of
14 * {@link #getRuleIndex} to be explicitly set for the context.
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>
24 class ANTLR4CPP_PUBLIC InterpreterRuleContext : public ParserRuleContext {
26 InterpreterRuleContext();
29 * Constructs a new {@link InterpreterRuleContext} with the specified
30 * parent, invoking state, and rule index.
32 * @param parent The parent context.
33 * @param invokingStateNumber The invoking state number.
34 * @param ruleIndex The rule index for the current context.
36 InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex);
38 virtual size_t getRuleIndex() const override;
41 /** This is the backing field for {@link #getRuleIndex}. */
42 const size_t _ruleIndex = INVALID_INDEX;