Проблема в том, что compose съедает все выражения в скобках. Вы счастливы, что он съел (на слово "/") , но вы серьезно не хотите, чтобы он съел (добавить выходной класс) , потому что он предназначен для разбирать диалект.
Вероятно, есть более умный подход, но он должен работать: удалите compose , выполнив lit-word вне правила синтаксического анализа ...
attribute: copy []
class: copy []
output: copy ""
fs: to-lit-word "/" ;; define a forward slash lit-word
definition-rule: [
some [set class word! (append output class) 'is 'defined 'by [
some [copy attribute to fs thru fs]
]
copy attribute to end]
]
parse [Customer is defined by First Name / Last Name / Email] definition-rule
== true
Я не совсем уверен, что вы пытаетесь сделать с этим кодом, но в конце вы хотите извлечь набор атрибутов, а затем рассмотрите это изменение:
attribute: copy []
attributes: copy []
class: copy []
output: copy ""
fs: to-lit-word "/" ;; define a forward slash lit-word
definition-rule: [
some [set class word! (append output class) 'is 'defined 'by [
some [copy attribute to fs thru fs (append/only attributes attribute)]
]
copy attribute to end (append/only attributes attribute)]
]
parse [Customer is defined by First Name / Last Name / Email] definition-rule
print ["==" class mold attributes]
== Customer [[First Name] [Last Name] [Email]]