You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find it somewhat annoying that I have to write 3 4 * instead of 3 4*. I know that clac uses sdssplitargs(), which needs whitespace between tokens, and that any enhancement needs to be unambiguous for both the code and the user. I propose the following solution:
Every token output by sdssplitargs() is examined first in its entirety, as it is now, and then, if it's not recognized, it is split into a head and a tail in a loop, where the tail is 1, 2, 3... characters long, until the head is recognized (or until the head would be empty, in which case everything is discarded). As soon as the head is recognized, it is processed, and then the tail is handled in the same way (cyclically or recursively).
E.g., if the input is 2pi* (supposing pi is a word): it is not recognized, so 2pi is tried (the tail being *), then 2p (with tail i*) and then 2, which is recognized and processed. Then the tail pi* is not recognized, so that pi is tried, which is recognized and processed, and finally the tail * is recognized and processed.
In other words: tokens are parsed in a "greedy" way, with backtracking.
The text was updated successfully, but these errors were encountered:
I see that in the code head and tail are already used for the list of words, so it would probably be better to use different terms. E.g., tokenhead and tokentail, or arghead and argtail.
I find it somewhat annoying that I have to write
3 4 *
instead of3 4*
. I know that clac usessdssplitargs()
, which needs whitespace between tokens, and that any enhancement needs to be unambiguous for both the code and the user. I propose the following solution:Every token output by
sdssplitargs()
is examined first in its entirety, as it is now, and then, if it's not recognized, it is split into a head and a tail in a loop, where the tail is 1, 2, 3... characters long, until the head is recognized (or until the head would be empty, in which case everything is discarded). As soon as the head is recognized, it is processed, and then the tail is handled in the same way (cyclically or recursively).E.g., if the input is
2pi*
(supposingpi
is a word): it is not recognized, so2pi
is tried (the tail being*
), then2p
(with taili*
) and then2
, which is recognized and processed. Then the tailpi*
is not recognized, so thatpi
is tried, which is recognized and processed, and finally the tail*
is recognized and processed.In other words: tokens are parsed in a "greedy" way, with backtracking.
The text was updated successfully, but these errors were encountered: