{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace." } ;
-HELP: (scan-token)
+HELP: ?scan-token
{ $values { "str/f" { $maybe string } } }
{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word outputs " { $link f } " on end of input. To throw an error on end of input, use " { $link scan-token } " instead." }
$parsing-note ;
HELP: scan-token
{ $values { "str" string } }
-{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link (scan-token) } " instead." }
+{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link ?scan-token } " instead." }
{ $values { "string" string } { "word/number" "a word or number" } }
{ $description "If " { $snippet "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 " { $link (scan-datum) } " and " { $link scan-datum } "." } ;
+{ $notes "This word is used to implement " { $link ?scan-datum } " and " { $link scan-datum } "." } ;
{ $errors "Throws an error if the scanned token is a number or upon finding end of file." }
$parsing-note ;
-HELP: (scan-datum)
-{ $values { "word/number/f" "a word, a number, or " { $link f } } }
+HELP: ?scan-datum
+{ $values { "word/number/f" { $maybe word number } } }
{ $description "Reads the next token from parser input. If the token is found in the vocabulary search path, returns the word named by the token. If the token does not find a word, it is next converted to a number. If this conversion fails, too, this word returns " { $link f } "." }
$parsing-note ;
HELP: scan-datum
-{ $values { "word/number" "a word or a number" } }
+{ $values { "word/number" { $or word number } } }
{ $description "Reads the next token from parser input. If the token is found in the vocabulary search path, returns the word named be the token. If the token is not found in the vocabulary search path, it is converted to a number. If this conversion fails, an error is thrown." }
{ $errors "Throws an error if the token is not a number or end of file is reached." }
$parsing-note ;
HELP: scan-number
-{ $values { "number" "a number" } }
+{ $values { "number" number } }
{ $description "Reads the next token from parser input. If the token is a number literal, it is converted to a number. Otherwise, it throws an error." }
{ $errors "Throws an error if the token is not a number or end of file is reached." }
$parsing-note ;
HELP: parse-until-step
-{ $values { "accum" vector } { "end" word } { "?" "a boolean" } }
{ $description "Parses a token. If the token is a number or an ordinary word, it is added to the accumulator. If it is a parsing word, calls the parsing word with the accumulator on the stack. Outputs " { $link f } " if " { $snippet "end" } " is encountered, " { $link t } " otherwise." }