Grammar by kind
Each statement occupies one line. A { ... } body may share the line.
Component diagrams
diagram component ["Title"]
direction (right | down)
package <name> [as <alias>] [<<stereotype>>] [{ ... }]
component <name> [as <alias>] [<<stereotype>>] [{ ... }]
provides <interface> [, <interface>]...
requires <interface> [, <interface>]...
port <name> [left | right | top | bottom] [provides <i> | requires <i>]...
<ref> (--> | ..> | -- | .. | <-- | <..) <ref> [: <label>]
note <element>: <text>
align <element> <element>...
<element> (left-of | right-of | above | below) <element>
A <name> is a bare word or a "quoted string". Bare words may contain letters,
digits, _, and single - or . between them.
An element is referenced by its alias, or by its name when it has no alias.
A <ref> is an element, a unique port name, or <element>.<port>.
Rules
provides,requiresandportbelong inside a component.- A package may be nested inside a component (it is one of its packaged elements).
- A connector needs two different components.
- A requirer and a provider of the same interface name are wired automatically. See Interface.
- Declarations may come after the connectors that use them.
Package diagrams
diagram package ["Title"]
direction right|down
package <name> [as <alias>] [<<stereotype>>] [{ ... }]
class|interface|enum <name> [as <alias>] [<<stereotype>>]
a ..> b [: label] a --> b a -- b a .. b a --|> b a ..|> b a +-- b
note <target>: text
a left-of|right-of|above|below b
align a b c
Statements can be separated with ; as well as newlines. See
Package diagrams.
Sequence diagrams
diagram sequence ["Title"]
actor|participant <name> [as <alias>] [<<stereotype>>]
<a> (-> | ->> | -->) <b> [: label] [{ ... }]
<a> -> new <name> [as <alias>] [<<stereotype>>] [: label] [{ ... }]
create <name> [as <alias>] [<<stereotype>>] [: label] [{ ... }] inside a block
[-> <a> [: label] [{ ... }] found <a> ->] [: label] lost
return [text] inside a block
destroy <a>
alt ["guard"] { ... } [else ["guard"] { ... }]...
par ["guard"] { ... } [and ["guard"] { ... }]...
opt|loop|break|critical|neg ["guard"] { ... }
ref over <a>[, <b>]... : <name>
note over <a>[, <b>]... : text note left of <a>: text note right of <a>: text
Participants must be declared before use. ; separates statements outside labels. A label
extends to the end of the line, except for a comment after whitespace (# or //) or a
space-separated { or }; quote a label to keep these as text. See
Sequence diagrams.
State diagrams
diagram state ["Title"]
direction right|down
state <name> [as <alias>] [<<stereotype>>] [{ ... }]
region ["name"] { ... } inside a state
entry|do|exit [/ expression] inside a state, one per line
trigger {, trigger} [guard] / effect internal transition, one per line
[*] --> a a --> [*] a --> b [: label] b <-- a
[H] [H*] Name[H] Name[H*] shallow and deep history
choice|junction|fork|join|terminate <name>
entrypoint|exitpoint <name> inside a state
note <target>: text
a left-of|right-of|above|below b
align a b c
A transition label has the form trigger {, trigger} [guard] / effect, with every part
optional. ; separates statements except internal behaviour lines and labels. A label extends
to the end of the line, except for a comment after whitespace. See
State diagrams.
Activity diagrams
diagram activity ["Title"]
start first statement of the flow
action|send|accept|object "name"
if "guard" { ... } [else if "guard" { ... }]... [else ["guard"] { ... }]
switch ["subject"] { case "guard" { ... } case "guard" { ... } ... }
while "guard" { ... }
repeat { ... } until "guard"
fork { ... } and { ... } [and { ... }]...
lane "name" { ... }
note: text
stop activity final
end flow final
A note attaches to the statement before it. Guards are written without brackets. In a diagram with lanes,
actions, signals and objects must be inside a lane block. See Activity diagrams.