Red: `<]` inside `[<]` block is treated as an unclosed `tag!`

Created on 28 Aug 2017  路  3Comments  路  Source: red/red

```Red

[<]
* Syntax Error: invalid tag! at "<]"
Where: do
Stack: load
[ <]
Syntax Error: invalid tag! at "<]"
Where: do
*
Stack: load
[< ]
== [<]

status.built status.tested type.bug

Most helpful comment

@geekyi almost! I believe | #")" is needed too

>> (<)
*** Syntax Error: invalid tag! at "<)"
*** Where: do
*** Stack: load 
>> [(<)]
*** Syntax Error: invalid tag! at "<)]"
*** Where: do
*** Stack: load 

All 3 comments

>> [<]>]
== [<]>]
>> <]>
== <]>
>> <[>
[    ]     ; need to close `]` in interpreter
*** Syntax Error: invalid value at "]"
*** Where: do
*** Stack: load

What should it be interpreted as? 馃槈
I think this is a question of which of tag! or block! can contain each other? 馃

How to debug without looking at sources? 馃槤

>> [<]
*** Syntax Error: invalid tag! at "<]"
*** Where: do
*** Stack: load 
>> system/state/trace: 2
== 2
>> [<]
*** Syntax Error: invalid tag! at "<]"
*** Where: do
*** Stack: launch launch either run while eval-command if either switch either do-command if print = type? load set case transcode either if do 
>> load "[<]"
*** Syntax Error: invalid tag! at "<]"
*** Where: do
*** Stack: launch launch either run while eval-command if either switch either do-command unless case print type? try either = set catch load set case transcode either if do  

;; load set case transcode

>> find body-of :load 'case
== [case [
    part [system/lexer/transcode/part source out trap length] 
    next [set position system/le...

>> ? system/lexer/transcode
USAGE:
     SYSTEM/LEXER/TRANSCODE src dst trap...

>> a: [] system/lexer/transcode "<]" a off
*** Syntax Error: invalid tag! at "<]"
*** Where: do
*** Stack: launch launch either run while eval-command if either switch either do-command unless case print type? try either = set catch transcode either if do

>> find body-of :system/lexer/transcode 'either
== [
    either trap [
        reduce [stack/1 pos :err]
    ] [
        if error? :err [do :err]       ;; trace is here, but not so helpful in this case
       ...
>> find body-of :system/lexer/transcode 'tag
== none
>> find form body-of :system/lexer/transcode 'tag
== {tag-rule < not = | > | < | ws type tag! s some " thru " | ' thru ' | e > break | skip if e/1 <> > thro...

And this where I miss find/deep, and I have to resort to searching in the source:
https://github.com/red/red/blob/master/environment/lexer.red#L616

tag-rule: [
    #"<" not [#"=" | #">" | #"<" | ws] (type: tag!)         ; (1)
     s: some [#"^"" thru #"^"" | #"'" thru #"'" | e: #">" break | skip]
    (if e/1 <> #">" [throw-error [tag! back s]])
]

So, if this was to be fixed, (1) should include | #"]" whew! 馃槃

@geekyi almost! I believe | #")" is needed too

>> (<)
*** Syntax Error: invalid tag! at "<)"
*** Where: do
*** Stack: load 
>> [(<)]
*** Syntax Error: invalid tag! at "<)]"
*** Where: do
*** Stack: load 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiiamboris picture hiiamboris  路  5Comments

tmpbci picture tmpbci  路  8Comments

luis-lavaire picture luis-lavaire  路  4Comments

endo64 picture endo64  路  7Comments

loziniak picture loziniak  路  4Comments