如何泛化此解析规则以包含此 UML 方言的任何动词?

发布于 2024-09-09 16:27:07 字数 1213 浏览 4 评论 0原文

我想制定一个解析规则(use-rule)来包含几个动词:ConnectUseList显示等。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情痴 2024-09-16 16:27:07

我宁愿编写一个函数,将所有动词作为输入并为您生成解析规则,而不是这样做。因此,如果有新动词,您只需将其添加到动词列表中,而不用修改规则。这也可以避免错误......您的倒数第二个解析规则是错误吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文