This is the first time I am working with ANTLR for a project at Imperial College London and until now it has been really useful. I have already defined a simple recursive grammar as follows
grammar Hello;      
execution: workflow;
workflow : Task 
         | workflow OPERATOR workflow 
         |'(' workflow OPERATOR workflow ')'                        
         |'(' workflow OPERATOR workflow ')' (OPERATOR workflow)*                        
          ;
Task : 'T' ('0'..'9')+ | 'WF' ('0'..'9')+;
OPERATOR: 'AND' | 'OR'  | 'XOR' |';' ;
WS  :   [ \t\n\r]+ -> channel(HIDDEN) ; 
to evaluate strings like :
T6 ; (T4 AND T7) ; T5 ; ( (WF23 OR WF2) OR (T3 AND WF4) AND T4) AND T5 OR T11
and it works perfectly, my problem comes when I try to evaluate an incorrect string like
T6 ; (T4 AND T7) ; T5 ; ( (WF23 OR WF2) OR (T3 AND WF4) AND T4) AND (T5;OR() T2) 
according to my rules after the last AND the string "(T5;OR() T2) " is not valid since it doesn't fits with my grammar definition, but when testing this I get the tree for the string
   T6 ; (T4 AND T7) ; T5 ; ( (WF23 OR WF2) OR (T3 AND WF4) AND T4)
and the last part "(T5;OR() T2) " which is incorrect is simply ignored.
My question is what am I missing, what should I do to get and error saying that "(T5;OR() T2) " doesn't fits with my grammar definition, can somebody knows??
Thanks a lot