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

LEXER: sign before POUND char like [-#"a"] is not recognized as a word and is misinterpreted #2319

Closed
Oldes opened this issue Sep 3, 2018 · 5 comments

Comments

@Oldes
Copy link

Oldes commented Sep 3, 2018

Actual behaviour

>> [-#"a"]
== [#"^""]
>> [-#"b"]
== [#"^""]

In Rebol2 it is also wrong, but with different result:

>> [#"a"-#"z"]
== [#"a" #"^@"]
>> [-#"z"]
== [#"^@"]
>> load {-#"z"}
== #"^@"
>>

Expected behaviour (like in Red)

>> [-#"a"]
== [- #"a"]
>> [-#"b"]
== [- #"b"]
>> load {-#"a"}
== [- #"a"]

Because I want to be able to write more compact charsets:

ch_base64: charset [#"a"-#"z" #"A"-#"Z" #"0"-#"9" #"/" #"+" #"="]

versus

ch_base64: charset [#"a" - #"z" #"A" - #"Z" #"0" - #"9" #"/" #"+" #"="]
@Oldes
Copy link
Author

Oldes commented Sep 3, 2018

Ren-C throws an error (but I prefer result like in Red)

>> [-#"a"]
ⓘ   Note: use WHY for error information
** Syntax Error: invalid "char" -- ""
** Where: transcode case load trap forever _
** Near: (line 1) [-#"a"]
** File: tmp-boot.r
** Line: 5173

@Oldes Oldes changed the title LEXER fails in cases like: [-#"a"] LEXER: sign before POUND char like [-#"a"] is not recognized as a word and is misinterpreted Sep 4, 2018
@Oldes
Copy link
Author

Oldes commented Sep 4, 2018

Related issues:

>> [-#[none]]
== [none]
>> [-#{AA}]
** Syntax error: invalid "binary" -- "-#{AA}"
** Near: (line 1) [-#{AA}]

@Oldes
Copy link
Author

Oldes commented Sep 4, 2018

Fixed in commit: Oldes/Rebol3@1a4c3a6

Oldes referenced this issue in Oldes/Rebol3 Sep 4, 2018
…recognized as a word and is misinterpreted

Before this fix:
```
>> [-#"a"]
== [#"^""]
>> [-#[none]]
== [none]
>> [-#{AA}]
** Syntax error: invalid "binary" -- "-#{AA}"
** Near: (line 1) [-#{AA}]
```

Now:
```
>> [-#"a"]
== [- #"a"]
>> [-#{AA}]
== [- #{AA}]
>> [-#[none]]
== [- none]
```
@Oldes
Copy link
Author

Oldes commented Sep 4, 2018

With the above fix it is consistent with cases like:

>> [-""]
== [- ""]

Oldes added a commit to Oldes/Rebol3 that referenced this issue Sep 4, 2018
@Oldes
Copy link
Author

Oldes commented Sep 4, 2018

Here is another case which was fixed now:

>> [-#hhh]
** Syntax error: invalid "integer" -- "-#hhh"
** Near: (line 1) [-#hhh]

Now:

== [- #hhh]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants