rebol:如何创建规则来解析大括号?

Reb*_*ial 1 rebol

我真的不掌握Parse规则了:)

我该如何解析这个?

to-parse: [entity Person {
    String name
    String lastName
    Address home
    Address business
}]
Run Code Online (Sandbox Code Playgroud)

这不起作用:

entity-rule: ['entity word! #"{" to end]
>> parse to-parse entity-rule
== false
>>
Run Code Online (Sandbox Code Playgroud)

小智 5

的解析块中的第三个元素不是char {.它是一个字符串 - REBOL字符串可以描述为"......"{...}

type? to-parse/3
== string!
to-parse/3
{
   String name
   String lastName
   Address home
   Address business
}
Run Code Online (Sandbox Code Playgroud)

要成功解析块,您需要查找字符串:

entity-rule: ['entity word! string! to end]
parse to-parse entity-rule
== true
Run Code Online (Sandbox Code Playgroud)


小智 5

to-parse: [entity Person {
    String name
    String lastName
    Address home
    Address business
}]

person-rule: [  
    thru "String " copy name to newline (append names name) thru newline |
    thru "Address " copy address to newline (append addresses address) thru newline |
    skip end
]

parse to-parse [ 
    'entity 'person 
    set details string! (
        names: copy [] addresses: copy []
        parse details [ some person-rule ]
    )
]
Run Code Online (Sandbox Code Playgroud)

将名称收集到块名称中,并将地址收集到块地址中.但这个答案在Rebol3中不起作用.不知道为什么不.