Fix listener example in C++ documentation.
The listener example still refers to Ref<> and shared pointers, but in reality the generated method does not pass a shared pointer. The actual signature looks more like this: virtual void enterKey(ParserRuleContext * /*ctx*/) override { } This change updates the example to match that signature, and removes a line discussing Ref<>. It also adds the "override" keyword in order to make the user's code a little more robust against typos/changes in the grammar.
This commit is contained in:
parent
fd5efc250d
commit
1bb3eb1ebf
|
@ -49,7 +49,7 @@ using namespace org::antlr::v4::runtime;
|
|||
|
||||
class TreeShapeListener : public MyGrammarBaseListener {
|
||||
public:
|
||||
void enterKey(Ref<ParserRuleContext> ctx) {
|
||||
void enterKey(ParserRuleContext *ctx) override {
|
||||
// Do something when entering the key rule.
|
||||
}
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
```
|
||||
|
||||
This example assumes your grammar contains a parser rule named `key` for which the enterKey function was generated. The `Ref<>` template is an alias for `std::shared_ptr<>` to simplify the runtime source code which often makes use of smart pointers.
|
||||
This example assumes your grammar contains a parser rule named `key` for which the enterKey function was generated.
|
||||
|
||||
## Specialities of this ANTLR target
|
||||
|
||||
|
|
Loading…
Reference in New Issue