parse-datum ( string -- word/number )


Vocabulary
parser

Inputs and outputs
stringa string
word/numbera word or number


Word description
If string is a valid number literal, it is converted to a number, otherwise the current vocabulary search path is searched for a word named by the string.

Errors
Throws an error if the token does not name a word, and does not parse as a number.

Notes
This word is used to implement (scan-datum) and scan-datum.

Definition
USING: kernel math.parser vocabs.parser ;

IN: parser

: parse-datum ( string -- word/number )
dup search
[ ] [ dup string>number [ ] [ no-word ] ?if ] ?if ;