Recognizing Words

Help Contents First Steps In Logo Recognizing Words
First Steps In Logo Types of things

Recognizing Words

When you read or write Logo programs you will intuitively understand what are the individual words that compose the programs.

But sometimes programming language differ from natural languages. That's is why you would need to know how the Logo recognizes your words. Here is a short list of the rules that Logo uses:

GENERAL RULE: A word is a continuous group of letters framed by spaces or individual symbols.
	'..' 
Inside a phrase the quote ' is written as two separate quotes ''.
	[, ], (, ), {, }, ;, :, ", +,
They are always one-letter words.

ODD LETTERS RULE: Odd letters are treated as individual only in some cases. For example a minus - is an individual only if it is not preceded by a space. A group of >, = or < is always one word, used alone each of these symbols is individual.

RULE FOR RULES: If two or more rules apply to the same letter, the one which applies to a longer group is considered.

As a beginning you can see the examples below and try to figure out whether you can easily recognize the individual words.

There is no need to understand what the instructions mean. You will learn this later. Just try to identify the words.

Let's now take one simple example:
	make "X :X+1
This instruction is split into words in this way (red vertical bars separate words):
	|make|"|X|:|X|+|1|
Note how individual characters like ", : and + are separate words. If in this case we have minus instead of plus then this minus will be a one-letter word too.

Here comes a longer example:
	if (bf :A)>'[Test]' [print :B(1)]
which is worded in this way:
	|if|(|bf|:|A|)|>|'[Test]'|[|print|:|B|(|1|)|]|
You can see there is one phrase there '[Test]', which is marked as a single word.

The last example is a short 3 lines long fragment.

Here it is:

to :A ? :B?
	print :A :B? -10 "AB?
end

The words in it are:

|to|:|A|?|:|B?|
	|print|:|A|:|B? |-10|"|AB?|
|end|

The interesting here is that the minus is glued to the number.

Pay attention to the question mark. Do you see why its first occurance is as a one-letter word?

First Steps In Logo Types of things