如何泛化此解析规则以包含此 UML 方言的任何动词?
我想制定一个解析规则(use-rule
)来包含几个动词:Connect、Use、List 、显示等。
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/)
I want to make a PARSE rule (use-rule
) for including several verbs: Connect, Use, List, Show, etc.
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
;; ...
]
How can I make it generic, so it accepts any verbs? Something like:
[
copy Actor to 'Any-Verb
thru 'Any-Verb copy UseCase to end (
append output rejoin ["[" Actor "]-(" "Any-Verb " UseCase ")"]
)
]
This way I'd not need to add a new section to the rule each time I need a new verb?
(Note: That rule is part of a global parse rule used here http://askuml.com/blog/e-commerce/)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我宁愿编写一个函数,将所有动词作为输入并为您生成解析规则,而不是这样做。因此,如果有新动词,您只需将其添加到动词列表中,而不用修改规则。这也可以避免错误......您的倒数第二个解析规则是错误吗?
Rather than do that I'd prefer to write a function that takes all the verbs as the input and to generate the parse rule for you. So, if there's a new verb, you just add it to the list of verbs rather than modify the rule. And that would avoid errors too ... is your 2nd to last parse rule an error?