Under the premise that 'parse' without the second parameter behaves like the newLISP source parser, there is nothing unexpected in the behavior of 'parse'. The confusion arises when octal numbers are discovered. See the same examples changing to octal:
Code: Select all
> (parse "0F000801")
("0" "F000801")
> (parse "06000801") ; change F to a valid octal
("06000" "801")
> (parse "06000701") ; change 8 to valid octal
("06000701")
>
> (parse "0F 00 08 01")
("0" "F" "00" "0" "8" "01")
> (parse "06 00 07 01") ; all string are valid octal
("06" "00" "07" "01")
>
This
octal confusion is a well known phenomenon in any programming language, because virtually all of them follow the same rules when parsing numbers: Numbers have certain valid start characters and and the parser ends them and restarts when an invalid character for that specific number format is found - octal numbers start with a '0' -
As Cormullion mentions: "what would be a better choice?" (for the default parse behavior). There are just too much possibilities, therefore I think that newLISP-source parsing as a default is a sensible choice. Yes, perhaps adding something in the manual will alleviate the confusion. Currently 'parse' mentions "newLISP parsing rules" in the description. Perhaps a chapter about "newLISP parsing rules" has to be added and the description of 'parse' would link to it.
Last not least: in many cases where parse is used, 'find-all' would be the better choice. While 'parse' takes break strings or regex expressions in the optional second parameter, 'find-all' describes the tokens itself:
Code: Select all
> (find-all "[^:]+" "0F:02:56")
("0F" "02" "56")