Skip to content
forked from cuichaox/dml

Diagram Make Language for common lisp

License

Notifications You must be signed in to change notification settings

08723764028/dml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Diagram Make Language for Common Lisp.You can look DML as Domain Specific Language for drawing UML.

我国同学,请参考一个更详细的中文说明

Install

DML is added to quicklisp, quicklisp automatically download it to local disk on the first loading.

(ql:quickload :dml)

Quick start by examples

To run examples, load dml system and change current package to ‘dml’.

(ql:quickload :dml)
(use-package :dml) ;; or (in-package :dml)

Quick Start for Sequence Diagram

Call macro dml-create-sequence to create a sequnce diagram:

(dml-create-sequence "<diagram name>" (<attribute>...) <messages>

A synchronous message & retrun in a formated string :

"==><object name>.<message label>/<return label>"

A asynchronous message in a formated string:

"--><object name>.<message label>"

A new message in a fromated string :

"n-><object name>.<mesasge label>"

Any object name begin with ‘!’ is a active object, that has a active bar at beginning.

A sequence list of messages in macro ‘&prog’

(&prog <message 1> <message 2> <message 3> ...)

A message with follwing sub-messages in mcaro ‘&chain’

(&chain <message> <sub-message> <sub-sub-message> ...)

A optional/alternative frame with guard condtion and messages in macro ‘&if’

(&if "<guard label(condtion)>" <then-message> [<else-message>]) 

A loop frame with guard and message in macro ‘&loop’

(&loop "<gurad label(conditon)>" <message in loop> )

Any macro (‘&prog’ ,’&chain’, ‘&opt’, ‘&if’ and ‘&loop’) return a messages, so it can be nested in each other

Evaluate follwing expression:

(dml-create-sequence "legend" ()
  (&prog "==>ObjectA.SyncMsg1()/ret1" 
         (&chain "==>ObjectA.SyncMsg2()/ret2"
                 "==>ObjectB.SyncMsg2.1()/ret2.1"
                 "-->!ActiveObjectC.AsyMesg2.2()")))

Wil output image(legend.ps and legend.png):

demo/legend.png

Evaluate Expression:

(dml-create-sequence "nested" ()
  (&chain "==>aComputer.play()/"
          (&prog (&chain "==>emacs.run()/"
                         "==>slime.load()/")
                 (&chain "==>slime.Hacking()/"
                         (&chain "==>slime.LookupHyperSpec()"
                                 (&prog "==>chrome:Explorer.Start()/"
                                        "==>chrome:Explorer.OpenSpec()/"))))))

Output image:

demo/nested.png

Evalate Expression:

(dml-create-sequence "control" ()
  (&chain "==>:PersonFile.LoadAllGoodMan()/"
          (&loop "[ hasNext ]"
                 (&prog "==>:PersonFile.readNext()/"
                        (&if "[ Is Good Man ]"
                             (&prog "n=>aManObj.new"
                                    "==>manPool.register()/"))))))

Output image:

demo/control.png

Quick Start for Graph Diargam

Call macro dml-create-graph to create a graph diagram:

(dml-create-graph "<diagram name>" (<attribute>...) <node or edge>

Define nodes by call functions (node type as function name).:’full-class’, ‘simp-class’, ‘actor’, ‘pack’, ‘ucas’, ‘comp’

(<node type>  <node name>  [options])
  1. Define Graph by edges that linked nodes, define edges by functions (edge type as function name): ‘-dep-‘, ‘-com-‘, ‘-agg-‘, ‘-gen-by-‘.
    (-<edge type>- <src node> <dest node>) ; link one-to-one
    (-<edge type>-* <src node> <dest node 1> <dest node 2> ...); link one-to-manny
    (-<edge type>-- <1st node> <2nd node> <3rd node> ...); link one-by-one
        
  2. Reference Predefined node by name ‘@name’.
    (@name <node name>)
        

Evaluate expression:

(dml-create-graph "dml-component" (:rankdir :LR)
  (-dep-- "use"
          (comp "DML")
          (comp "donuts")
          (comp "Graphviz")))

Output image:

demo/dml-component.png

Evalate expression:

(dml-create-graph "os-class" ()
  (with-method ("+ play () : Love" "+ work () : Hate")
    (-genby-*
     (full-class "OS"
                 "abstract"
                 (attributes "- name : String"
                             "- born : Date"))
     (full-class "Linux")
     (full-class "Android")
     (full-class "Apple")
     (full-class "Windows"))
    (-dep- "from"
           (@name "Android")
           (@name"Linux"))))

Output Image:

demo/os-class.png

Evaluate expression:

(dml-create-graph "coder-case" (:rankdir :LR)
  (-point-* 
       (actor "coder")
       (ucas "Use Emacs")
       (ucas "Programing")
       (ucas "Play game"))
  (-dep- "extend"
         (@name "Programing")
         (@name "Use Emacs")))

Output image:

demo/coder-case.png

Evaluate expression:

(dml-create-graph "dom" ()
  (with-method ("+ calcPrice(): BigDecimal"
                "+ toJson(): String"
                "+ getValue(name:String) : Object")
    (-genby-* (full-class "TreeNode"
                          "Abstract"
                          nil
                          (methods "+ getParent(): TreeNode"
                                   "+ addChild(:TreeNode)"))
              (full-class "PriceCache" "Decorator"
                          (attributes "- theNode : TreeNode"))
              (full-class "Case")
              (full-class "Plan")
              (full-class "Categorization"
                          nil
                          (attributes "- fromAge : integer"
                                      "- toAge : integer"
                                      "- isSheBao : boolean"
                                      "- count : integer"))))
  (-dep- "Create"
         (full-class "CaseBuilder"
                     "Factory"
                     nil (methods "+ parseJson(: String) : Case"))                                  
         (@name "Case"))
  (-agg- (@name "TreeNode")
         (@name "TreeNode"))
  (-com- (@name "PriceCache")
         (@name "TreeNode"))
  (-com- (@name "Case")
         (@name "Plan"))
  (-com- (@name "Plan")
         (@name "Categorization"))  
  (-dep- "Usage"
         (@name "Categorization")
         (full-class "Calculator"
                     "Utility"
                     nil
                     (methods "+ calc(arg : TreeNode) : BigDecimal"
                              "- log2db() :")))
  
  (with-method ("+ loadFromdb()"
                "+ lookUp()")
    (-com- (@name "Calculator")
           (full-class "ArgumentTable"))
    (-dep- "Call"
           (@name "Calculator")
           (@name "TreeNode"))  
    (-genby-* (@name "ArgumentTable")
              (full-class "ByAgeScope")
              (full-class "ByAge")
              (full-class "ByID"))
    (-dep- "Usage" (@name "ArgumentTable")
           (pack "JDBC"))))

Output image: demo/dom.png

Reference

Symbol for Sequence Diagram

Symbol nameTypeDescription
dml-create-sequnceMacroDump sequnce diagram to ps and png file
&progMacroDefine sequnce calls
&chainMacroDefine a call with sub calls
&ifMacroDefine two alternative calls with a guard condition
&loopMacroDefile a call in a loop with a guard condition

Symbol for Graph Diagram

Symbol nameTypeDescription
dml-create-graphMacroDump graph diagram to ps and png file.
full-classFunction (node type)Create a class node whih attributes and methods.
attributes, methodsFunctionDefine attribute/method list for the full-calss
simp-classFunction (node type)Return a class node with a simple name in the box.
with-methodMacroCreate to define share methods for classes.
actorFunction (node type)Create a stick man as actor.
packFunction (node type)Create a package node.
ucasFunction (node type)Create use case node.
compFunction (node type)Create component node
@nameFunctionReference pre-defined node by name
-point-, -point-*Function (edge type)Define a arrow edge: 1-to-1, 1-to-n
-dep-, -dep-*, -dep–Function (edge type)Define dependcy edge: 1-to-1, 1-to-n, 1-by-1
-com-, com-*Function (edge type)Define composition edge: 1-to-1, 1-to-n
-agg-, -agg-*Function (edge type)Define a aggregation edge: 1-to-1, 1-to-n
-genby-,genby-*Function (edge type)Define generalize edge: 1-to-1, 1-to-n

About

Diagram Make Language for common lisp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Common Lisp 100.0%