Hello,
I have the following grammar file for ANTLR 4.5.1:
grammar Daty;
@lexer::members
{
private String day;
private String month;
private String tail(String str, Integer len) {
return str.substring(str.length() - len, str.length());
}
private void after_DD() {
System.out.println(getText());
day = tail(getText(), 2);
}
private void after_JUNE() {
month = "06";
}
}
start : d+;
d : (D1);
D1 : JUNE{after_JUNE();}' 'DD{after_DD();}', ';
WS : .+? -> skip;
fragment DD : '01'|'02'|'03'|'04'|'05'|'06'|'07'|'08'|'09'|'10'|
'11'|'12'|'13'|'14'|'15'|'16'|'17'|'18'|'19'|'20'|
'21'|'22'|'23'|'24'|'25'|'26'|'27'|'28'|'29'|'30'|
'31';
fragment JUNE : 'czerwiec'|'czerwca';
And I'm trying to parse the following string:
In function after_DD() the getText() returns:
Why function works properly the first time, and the second no longer?
Thanks,
K.