我想制作PARSE规则(use-rule
)以包含多个动词:连接,使用,列表,< strong>显示等
use-rule: [
some [
copy Actor to 'Connect
thru 'Connect 'to
copy UseCase to end (
append output rejoin ["[" Actor "]-(" "Connect to " UseCase ")"]
)
]
|
[
copy Actor to 'Use
thru 'Use
copy UseCase to end (
append output rejoin ["[" Actor "]-(" "Use " UseCase ")"]
)
]
|
[
copy Actor to 'List
thru 'List
copy UseCase to end (
append output rejoin ["[" Actor "]-(" "List " UseCase ")"]
)
]
|
;; ...
;; same for Show, Search, Select, Checkout, Pay, Delete, Modify, Add, Manage
;; ...
]
我怎样才能使它成为通用的,所以它接受任何动词?类似的东西:
[
copy Actor to 'Any-Verb
thru 'Any-Verb copy UseCase to end (
append output rejoin ["[" Actor "]-(" "Any-Verb " UseCase ")"]
)
]
这样我每次需要新动词时都不需要在规则中添加新的部分吗?
(注意:该规则是此处使用的全局解析规则的一部分http://askuml.com/blog/e-commerce/)
答案 0 :(得分:0)
我宁愿编写一个以所有动词作为输入并为您生成解析规则的函数,而不是这样做。因此,如果有一个新动词,您只需将其添加到动词列表中,而不是修改规则。这也可以避免错误......你的倒数第二个解析规则是错误的吗?