This code generator is based on yUML.me and this tutorial "Easy UML Dialect for Mere Mortals".
How to test it: execute this code generator, then when asked copy the Use Case Orders below to the clipboard and validate:
[code]]czoxMzQ6XCINCiAgICAgIFdvcmRwcmVzcyBQcm9maWxlcw0KICAgICAgQmxvZ2dlciBpcyBhIFVzZXINCiAgICAgIEFkbWluIGlzIGF7WyYqJl19IEJsb2dnZXINCiAgICAgIEF1dGhvciBpcyBhIEJsb2dnZXINCiAgICAgIFN1YnNjcmliZXIgaXMgYSBVc2VyDQpcIjt7WyYqJl19[[/code]
Code Generator:
Rebol [
Name: "Yuml Robot"
Description: "Generate Yuml Syntax"
Version: 1.0.0
Change: ""
]
ROBOT: make object! [
output: copy ""
note-rule: [(color: "beige") some [
'note [
copy note-string to 'fond thru 'fond copy color to end
(append output rejoin ["note: " note-string "{" "bg:" color "}"])
|
copy note-string to end (append output rejoin ["note: " note-string "{" "bg:" color "}"])
]
]
| copy note-string to 'fond thru 'fond copy color to end
(append output rejoin ["note: " note-string "{" "bg:" color "}"])
|
copy note-string to end (append output rejoin ["note: " note-string "{" "bg:" color "}"])
]
actor-rule: [some [ [copy Actor to 'is thru 'is 'a 'Actor (append output rejoin ["[" Actor "]"])]
| [copy Actor to 'is thru 'is 'a copy Actor2 to end (append output rejoin ["[" Actor "]^[" Actor2 "]"])]
]
]
extend-rule: [some [copy UseCase2 to 'Extend thru 'Extend copy UseCase1 to end (append output rejoin ["(" UseCase1 ")<(" UseCase2 ")"])]
]
include-rule: [some [copy UseCase2 to 'Include thru 'Include copy UseCase1 to end (append output rejoin ["(" UseCase2 ")>(" UseCase1 ")"])]
]
use-rule: [some [copy Actor to 'Manage thru 'Manage copy UseCase to end (append output rejoin ["[" Actor "]-(" "Manage " UseCase ")"])]
]
yuml-rule: [(Actor: copy [] Actor2: copy []) actor-rule | extend-rule | include-rule | use-rule | note-rule ]
;task1 function
Generate: func [yuml-orders][
output: copy ""
block-orders-draft: parse/all yuml-orders "^/"
block-orders: copy []
foreach order block-orders-draft [
if (length? (order: trim/head/tail order)) > 0 [
append block-orders order
]
]
foreach order block-orders [
order-block: to-block order
parse order-block yuml-rule
append output newline
]
]
;task2 function
list: func [][
foreach Task Tasks-List [
print Task
]
]
;core engine
run: func [code]
[
Tasks-List: copy [] ; reset the list
output: copy ""
do bind code 'self
]
]
Worker: Make Robot[]
Yuml-Orders-list: [
{
Wordpress Profiles
Blogger is a User
Admin is a Blogger
Author is a Blogger
Subscriber is a User
}
{ Blogger Role
Blogger Manage Posts
}
{
Admin Roles
Admin Manage Site
Manage Site Include Manage Users
Manage Site Include Manage Themes
Manage Site Include Manage Plugins
}
]
Robot-Orders: [
Yuml-Output-List: copy []
Yuml-Orders-list: copy []
print "copy your command to clipboard ..."
input
user-command: read clipboard://
probe rejoin ["{" newline user-command newline "}"]
Append Yuml-Orders-list user-command
foreach Yuml-Orders Yuml-Orders-list [
Print ["Yuml-Orders: " Yuml-Orders " started ..." newline]
generate Yuml-Orders
Print output
Append Yuml-Output-List copy output
Print ["Yuml-Orders: " Yuml-Orders " done! " newline]
Print Newline
]
Probe Yuml-Output-List
result: mold/only Yuml-Output-List
head remove back tail (remove result)
write clipboard:// result
Print "Copied to clipboard..."
]
Worker/Run Robot-Orders
input
Example:
{
Wordpress Profiles
Blogger is a User
Admin is a Blogger
Author is a Blogger
Subscriber is a User
}
{ Blogger Role
Blogger Manage Posts
}
{
Admin Roles
Admin Manage Site
Manage Site Include Manage Users
Manage Site Include Manage Themes
Manage Site Include Manage Plugins
}