Concatenative topics
Concatenative meta
Other languages
Meta
In Forth "parsing words" read the text of the input stream.
Parsing words are typically used by Forth to add definition labels to the system like variables, constants or new Forth words defined with colon/semi-colon.
Since the internals of Forth are exposed to the programmer the parsing words are available for other uses.
The primary parsing word in ANS Forth is called "PARSE". PARSE takes and delimiter character for its input argument and returns an addr/length pair on the data stack.
https://forth-standard.org/standard/core/PARSE
Usage Example:
DECIMAL CREATE FILENAME 32 ALLOT : GET-FILENAME BL PARSE FILENAME PLACE ;
"WORD" is the original parsing word in earlier Forth systems and is still in ANS/ISO 94 Forth, somewhat due to legacy reasons. WORD is deprecated in Forth 2012.
From: http://www.forth.org/svfig/Win32Forth/DPANS94.txt
WORD CORE
( char "<chars>ccc<char>" -- c-addr )
Skip leading delimiters. Parse characters ccc delimited by char. An ambiguous condition exists if the length of the parsed string is greater than the implementation-defined length of a counted string.
c-addr is the address of a transient region containing the parsed word as a counted string. If the parse area was empty or contained no characters other than the delimiter, the resulting string has a zero length. A space, not included in the length, follows the string. A program may replace characters within the string.
Note:
The requirement to follow the string with a space is obsolescent and is included as a concession to existing programs that use CONVERT. A program shall not depend on the existence of the space
This revision created on Sun, 24 Mar 2024 02:29:46 by sierra (add code blocks around code)