Using the tab function for parsing in Icon
Recall that Icon's ``
e1 ? e2''
operator not only sets the subject ``
to e1 during the evaluation of e2, but it
also sets up an implied position in a variable
The implied subject for string scanning is strictly defined as
the portion of the current subject past the current
position. So, if ``
&pos'' is 3, then
the current subject is all but the first two characters of
You can use the
tab() function to work your way
through a complex subject. Here is what a call to
tab ( n )'' does:
&pos) is saved.
For example, ``
tab ( many ( &digits ) )''
finds the position of the next character in the subject that is
not a digit, sets the new position there, and returns the string
of digits between the old and new positions.
John Shipman, email@example.com
Last updated: 1996/01/06 21:12:57 UT