Hi!
I hava to intercept a expression between two string, and then send to another
application.
like a Java regex, for example:
// -------------------------------------------------------------------------
// Java Code Begin
// -------------------------------------------------------------------------
String regex = "select\\s+((.)+)\\s+from";
Pattern p = Pattern.complie(regex);
Matcher m = p.matcher("select stu.id as 'Student ID', stu.name as 'Student
Name' from");
String select = null;
if(m.find()){
select = m.group(1);
}
System.out.println(select);// print [stu.id as 'Student ID', stu.name as
'Student Name']
send(select);// send to another application.
// -------------------------------------------------------------------------
// Java Code End
// -------------------------------------------------------------------------
I try to write a sample grammar file, but it dosen't works.
// -------------------------------------------------------------------------
// Grammar File Begin
// -------------------------------------------------------------------------
start : 'select' WS SELECT WS 'from';
SELECT : (.)+ {
System.out.println(getText());
send(getText());
};
WS : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+;
// -------------------------------------------------------------------------
// Grammar File End
// -------------------------------------------------------------------------
I get a error message as follow when I generate code:
// -------------------------------------------------------------------------
// Error Message Begin
// -------------------------------------------------------------------------
[23:31:49] error(208): Sql.g:28:1: The following token definitions can never be
matched because prior tokens match the same input: WS
// -------------------------------------------------------------------------
// Message Begin
// -------------------------------------------------------------------------
Thanks a lot!
---------------------------------
THE
POWER
OF
JAVA
_________________________________________________________________
上MClub和Messenger好友一起都市寻宝!
http://club.msn.cn/?from=1
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address