Tokenization

Names of procedures, variables, and property lists are case-insensitive. So are the special words END, TRUE, and FALSE. Case of letters is preserved in everything you type, however.

Within square brackets, words are delimited only by spaces and square brackets. [2+3] is a list containing one word.

A word not after a quotation mark or inside square brackets is delimited by a space, a bracket, a parenthesis, or an infix operator +-*/=<>. Words that follow colons are also in this category. Note that quote and colon are not delimiters.

A word consisting of a question mark followed by a number (e.g., ?3), is parsed as if it were the sequence

(? 3)

making the number an input to the ? procedure. (See the section on Template-Based Iteration). This special treatment does not apply to words read as data, to words with a non-number following the question mark, or if the question mark is backslashed.

Semicolon has no special meaning in data lines read by READLIST or READWORD, but such a line can later be reparsed using RUNPARSE and then comments will be recognized.

To include an otherwise delimiting character (including semicolon or tilde) in a word, precede it with backslash (\). If the last character of a line is a backslash, then the newline character following the backslash is part of the last word on the line, and the line continues onto the following line. To include a backslash in a word, use two backslashes: \\. All of this applies to data lines read with READLIST or READWORD as well as to instruction lines.

FMSLogo translates \n (a backslash followed by a lowercase en) into a newline character.

Example:

PRINT "Hello\ how\ are\ you?\nI'm\ fine,\ thank\ you.
Hello how are you?
I'm fine, thank you.

A character entered with backslash is EQUALP to the same character without the backslash, but can be distinguished by the BACKSLASHEDP predicate. Backslashing is effective only on characters for which it is necessary: whitespace, parentheses, brackets, infix operators, backslash, vertical bar, tilde, quote, question mark, colon, and semicolon.

An alternative notation to include otherwise delimiting characters in words is to enclose a group of characters in vertical bars (|). All characters between vertical bars are treated as if they were letters. In data read with READWORD the vertical bars are preserved in the resulting word. In data read with READLIST (or resulting from a PARSE or RUNPARSE of a word) the vertical bars do not appear explicitly; all potentially delimiting characters (including spaces, brackets, parentheses, and infix operators) appear as though entered with a backslash. Within vertical bars, backslash may still be used, but the only characters which must be backslashed in this context are the backslash and the vertical bar. Within vertical bars, the sequence \n is translated to a newline character.

Example:

PRINT "|Hello how are you?\nI'm fine, thank you.|
Hello how are you?
I'm fine, thank you.

Characters entered between vertical bars are forever special, even if the word or list containing them is later reparsed with PARSE or RUNPARSE. The same is true of a character typed after a backslash, except that when a quoted word containing a backslashed character is runparsed, the backslashed character loses its special quality and acts thereafter as if typed normally. This distinction is important only if you are building a Logo expression out of parts, to be RUN later, and you want to use parentheses. For example,

PRINT RUN (SENTENCE "\( 2 "+ 3 "\))

prints 5, but

RUN (SENTENCE "MAKE ""|(| 2)

creates a variable whose name is open-parenthesis. (Each example would fail if vertical bars and backslashes were interchanged.)


SourceForge.net Logo