REBOL 3.0

Those tricky < and > characters

Carl Sassenrath, CTO
REBOL Technologies
6-Feb-2010 18:29 GMT

Article #0305
Main page || Index || Prior Article [0304] || Next Article [0306] || 3 Comments || Send feedback

A97 Fixes

Release A97 should fix most or all of these related issues. Please try it out.

In the REBOL lexicon, the < and > "arrow" characters are special, and must be scanned (lexically analyzed) in special ways.

To understand the situation, notice that arrows denote two datatypes, word! and tag!:

>> type? second [a < b]
== word!
>> type? second [a > b]
== word!
>> type? second [a <> b]
== word!
>> type? second [a <c> b]
== tag!

To avoid problems, we don't allow arrows to be part of most words. This avoids creating ambiguous lexical sequences such as:

a <c b d e>

Are those arrows as words or are they part of a tag?

To simplify such cases, we restrict the usage of arrows when used for words. We allow these words:

< <= << <> >> >= >

If you attempt to use arrows within words in general, you'll see an error:

>> a<
** Syntax error: invalid "word" -- "a<"
** Near: (line 1) a<

However, we do want to allow this common markup usage in a sensible way:

>> [<b>word</b>]
== [<b> word </b>]

So, that's even more tricky to scan.

Now, all this being said, we know there are a few minor bugs related to arrows in the scanner. They are listed in the R3 CureCode bug database, and they will be fixed.

For example, we need to allow lit-word quoting of arrow words:

>> if word = '< [...]
** Syntax error: invalid "word-lit" -- "'"
** Near: (line 1) if word = '< [...]

But, I simply wanted to point out this issue, so it is understood that arrows are not general-usage word characters.

3 Comments

REBOL 3.0
Updated 16-Apr-2024 - Edit - Copyright REBOL Technologies - REBOL.net