Parsed tree contains each letter in a different child

59 Views Asked by At

In the grammar file, I have 'LETTER' which is basically A-Za-z, but in the tree representation, it is taking each letter into a separate child. Is this ok as I go and start working on Java? Is there a way get the whole value into one field?

Sample string I usedAABBAX11BBBXvalue1BBCXvalue2AABBAX11BXvalue3BBCXvalue4BBDXvalue5

Grammar:

transaction: (SEGMENT_SEPARATOR (segment | ' ')+)+;
header: 'F6' (LETTER | DIGIT) (LETTER | DIGIT);
segment: FIELD_SEPARATOR field value;
field: (LETTER | DIGIT) (LETTER | DIGIT);
value: (LETTER | DIGIT | SPECIAL_CHARS)+;

LETTER : [A-Za-z];
DIGIT: [0-9];
SPECIAL_CHARS: '{' | '}' | '.';

FIELD_SEPARATOR: 'BB';
SEGMENT_SEPARATOR: 'AA';

Tree Image: Parsed Tree

0

There are 0 best solutions below