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/)
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?
精彩评论