Hi list,
I'm having a little trouble getting my head around memory management within a
Lemon-generated parser. Specifically the part of the docs stating when a
destructor will or will not be called.
For example, this is a portion of a grammar based on the SQLite parse.y file:
columnName ::= nm(N). {
BSSQLiteColumn *col = [[BSSQLiteColumn alloc] init];
col.name = N.textValue;
[[parsedTable columns] addObject:col];
}
nm(A) ::= id(X). { A = X; }
nm(A) ::= STRING(X). { A = X; }
id(A) ::= ID(X). { A = X; }
Notes:
- The token type here is a struct containing an Objective-C string which needs
freeing when done with.
- Only a %token_destructor is defined, not any others
I know that the last three assignments are leaking memory, but I don't know
when I should be explicitly freeing my allocated memory within a token and when
I should be relying on the destructor defined by %token_destructor{}. Or for
that matter whether I should be declaring a more specific symbol destructor.
Can anyone shed some light on how this should be done?
Thanks,
Ben
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users