I am supposed to write a simple line editor. The bit I have been stuck at for a few days is "parsing commands". The users enters a line range (12,27
) and then a command (c
), e.g., 12,27c
or 14,1532c
(all whitespaces are ignored). The command line can have missing parts, e.g., 27c
or 27
or , or symbols ".
" (Current Line in Buffer) and "$
" (Last Line in Buffer), for example: .,$c
. I have to extract the info entered by user and then use default values for the missing bits and bobs.
My problem is: I cannot find a way to tokenise such a string when there are no delimiters. I would very much appreciate a nudge in the right direction!
Another way that I thought of is to test the input for int
and get the int
if it is there, if not read a character (",
" or "c
"), and so on ...
I am not looking for a solution so much so as I am looking for an idea to help put me on the correct path.
vendredi 10 juin 2016
Simple Line Editor: How to parsing commands?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire