Permalink
Browse files

keep a weak reference to Grammar* in Parser

  • Loading branch information...
1 parent 7e291e3 commit 968d6083ac923e2dc4307f5927a7006b2602715b @rsms committed Apr 23, 2011
Showing with 4 additions and 0 deletions.
  1. +1 −0 runtime/Parser.cc
  2. +3 −0 runtime/include/gazelle/Parser.hh
View
1 runtime/Parser.cc
@@ -60,6 +60,7 @@ Parser::~Parser() {
void Parser::setGrammar(Grammar *grammar) {
+ grammar_ = grammar;
state_ = gzl_alloc_parse_state();
assert(state_ != NULL);
state_->user_data = (void*)this;
View
3 runtime/include/gazelle/Parser.hh
@@ -30,6 +30,7 @@ class Parser {
// Set the grammar which should be used for the next call to parse
void setGrammar(Grammar *grammar);
+ Grammar *grammar() { return grammar_; }
// A structure which contains the current state (see parse.h for details)
inline gzl_parse_state *state() { return state_; }
@@ -101,6 +102,8 @@ class Parser {
// The Gazelle parse state
gzl_parse_state *state_;
+
+ Grammar *grammar_; // weak
};

0 comments on commit 968d608

Please sign in to comment.