prog @init { int sum=0; } : (DIGIT {sum +=Integer.parseInt($DIGIT.text);} )+ { sum <=10}? '\r'? '\n' ; DIGIT: '0' .. '9';
1234
12345
line 1:5 rule prog failed predicate: { sum <=10}?