Hi,
I want to use the PLSQL grammar from antlr.org with some modifications to
detect table names in statements. I want to check, whenever I hit the
"table_spec" rule, if this table name is in a whitelist and perform further
actions.
I have a problem now: How can I add global variables to the parser?
I need to give the parser a pointer to the whitelist in memory and some other
variables for detecting valid / invalid table names.
Defining variables in @members doesn't help, I am not able to access this from
outside of the parser code.
In Java it seems to be much easier, since you have a class where you can add
public members, but in C I have no clue how to do it (yes, I need to use C,
and I never programmed in that language, only in C++ and Python so far).
I want to do something like this.
In the parser rule "table_spec", I want to check the table name:
{
char result[256];
strcat(result, s.tree ? s.tree->getText(s.tree)->chars : "");
strcat(result, s.tree ? "." : "");
strcat(result, t.tree ? t.tree->getText(t.tree)->chars : "");
isValid = checkForValidTable(result);
}
"isValid" and "checkForValidTable" are defined in @members, but the check
function needs some statement handlers and other stuff coming from the
outside. In the end, I wanted to have something like this in my main.cpp:
[...]
parser->setStmtHandle(some pointer);
parser->setWhiteListHandle(some pointer);
parser->sql_statement(parser); // this is the main function I would use from
the PL/SQL grammar file
bool isValid = parser->isValid();
[...]
Is it possible to do something like that? If not, how can I fix this problem?
I need to get those handles inside of the parser somehow?
Any ideas?
Andi
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.