More often than not, we have to handle default/implicit value in string parsing which requires special handling.
Here is an example in Python
Example: a grammar:
<line> ::= { <property> [<separator> <digits>] <separator> }
Example:
computer_id 1 port1 80 port2 88
computer_id 2 port1 port2 8080
By not specifying value, default/implicit value is 80.
elements.split(" ");
for i in range(1, len(elements)):
if i+1 < len(elements) and elements[i+1].isdigit():
process(elements[i], elements[i+1])
else:
process(elements[i], 80)