I have a grammar which parses alphabet characters and numbers separately:
grammar Demo;
options
{
language = C;
}
program : process+
;
process : Alphanumeric {printf("\%s",$Alphanumeric.text->chars);}
;
Alphanumeric : (Alphabet | Number)+
;
fragment Alphabet : ('a'..'z')+
;
fragment Number : ('0'..'9')+
;
Suppose, the input is 'a10' or 'b10', the printf statement would display a10 or b10, but I want the alphabet character and the number to be split i.e, a and 10 has to be split separately, because I need 'a' to be compared with an other string and save the number, the one next to 'a' or 'b' etc., to a table.
To be precise, a10 has to be split -> a for comparison and 10 for the storage and I should be able to fetch both the alphabet and number separately.
How to define a grammar for something like this?