Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console interpretes '-<- as a lit-word ('-) and a word (<-) #5456

Open
PeterWAWood opened this issue Jan 1, 2024 · 2 comments
Open

Console interpretes '-<- as a lit-word ('-) and a word (<-) #5456

PeterWAWood opened this issue Jan 1, 2024 · 2 comments
Assignees
Labels
type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation.

Comments

@PeterWAWood
Copy link
Contributor

Describe the bug
The test lexer-test.red crashes with a script error:

>> do %lexer-test.red
~~~started test~~~ lexer
*** Script Error: --assert does not allow word! for its assertion argument
*** Where: --assert
*** Near :
*** Stack: do-file

The issue is caused by the fourth assertion in test #4562, line 1571

1565    ===start-group=== "issues"
1566                                                                                                                                         
1567         --test-- "#4562"
1568                 --assert [<< '<< <<: :<<] == transcode "<< '<< <<: :<<"                                                                 1569                 --assert ['=<= :=<= =<=:] == transcode "'=<= :=<= =<=:"
1570                 --assert word? transcode/one "=<="                                                                                      1571                 --assert '-<- == transcode/one "-<-"

To reproduce

>> '-=-
== -=-
>> '->-
== ->-
>> '-<-
*** Script Error: <- has no value
*** Where: catch
*** Near : <-
*** Stack:

>> <-: 1
== 1
>> '-<-
== 1

Expected behavior
-<- should be interpreted as a single lit-word not a lit-word and a word

Platform version

about/debug
-----------RED & PLATFORM VERSION-----------
RED: [ branch: "master" tag: #v0.6.4 ahead: 5075 date: 22-Dec-2023/9:07:34 commit: #6cb7d502bcbfae8b00630adee6561909eee2b478 ]
PLATFORM: [ name: "Raspbian GNU/Linux 11 (bullseye)" OS: 'Linux arch: 'aarch64 version: 6.1.21 build: "#1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023" ]


@PeterWAWood PeterWAWood added the type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation. label Jan 1, 2024
@dockimbel dockimbel self-assigned this Jan 6, 2024
@dockimbel
Copy link
Member

dockimbel commented Jan 10, 2024

The lexical rules for allowing < inside a word (or at the beginning of a word) are not precisely defined currently. This is not an easy task as it can easily conflict with the "sticky tag" rule, allowing a word sticking to a tag to be separated by the lexer and producing two values:

>> load "<p>text</p>"
== [<p> text </p>]

@greggirwin
Copy link
Contributor

Since all other bracketing chars break words lexically, < probably should too. That makes it non-orthogonal with > being allowed, but is otherwise consistent. Just need to shift < from one list to the other in https://github.com/red/docs/blob/master/en/datatypes/word.adoc#3-literal-syntax.

The argument for supporting it in words would be that you can make nifty arrow-like words that go in both directions, but you could still do that with Unicode chars, and is far less common than lexing data where they may be together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type.bug Ticket describes an abnormal behavior, not conforming to the specs or expectation.
Projects
None yet
Development

No branches or pull requests

3 participants