Skip to content

BeckmaR/pypusta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build

pypusta

Pusta is the Plant UML State diagram parser.

It is designed to parse the textual description of a PlantUML State Diagram and transform it into a semantic model of a statechart, consisting of a hierarchy of states and transitions. This "translational model" in turn could be transformed into another model, for example SCXML or C code (neither is implemented yet).

Parser

Unlike the original PlantUML parser which is implemented in Java and in regex, this project uses a custom-developed textX grammar.

Model

The PlantUML notation is not exactly ideal for transforming into another representation. It has to be traversed top-to-bottom (declaration order matters) and contains expressions that are highly irrelevant for the semantic meaning of the bottom, for example the width of the generated image or colors of states. This package turns this notation into a true tree-like model, stripped of anything that does not matter - colors, notes and other data is parseable but not present in the output. For example, the package turns something like this:

@startuml
state "Req(Id)" as ReqId
state "Minor(Id)" as MinorId
state "Major(Id)" as MajorId

state c <<choice>>

Idle --> ReqId
ReqId --> c
c --> MinorId : [Id <= 10]
c --> MajorId : [Id > 10]
@enduml

into a model structured like this:

Statechart:
    Choice c:
        Transition -> MinorId:
            Label:
                [Id <= 10]
        Transition -> MajorId:
            Label:
                [Id > 10]
    State Idle:
        Transition -> ReqId
    State MajorId
    State MinorId
    State ReqId:
        Transition -> c

Labels of states and transitions are copied verbatim into the resulting model, the parser itself makes no assumption about the inner syntax of these expressions. For more examples, see tests/test_transformation.py.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Languages