spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.57k stars 615 forks source link

Design statemachine dsl language #463

Open jvalkeal opened 6 years ago

jvalkeal commented 6 years ago

What comes for a dsl itself is still a bit of an open question, but i.e. what plantuml have done looks relatively nice. We might want to something similar which would suit our needs better.

jvalkeal commented 6 years ago

Current drafting for this is happening in my branch https://github.com/jvalkeal/spring-statemachine/tree/dsl-work1/spring-statemachine-dsl.

spring-statemachine-dsl-common provides base facilities for generic dsl abstractions to parse a dsl and report error and ambiguities, etc. Other base abstractions planned is to abstract away things like context assist(not yet drafted). Ultimate goal would be able to provide DSLs with integration to Language Server Protocol similarly what was done in https://typefox.io/how-to-embed-a-monaco-editor-in-a-browser-as-a-part-of-my-first-task-at-typefox.

spring-statemachine-dsl-ssml is a take on SSML (Spring StateMachine Language) which takes influence from DOT language.

state S1 {
  initial
}
state S2 {}
state S3 {
  end
}
transition T1 {
  source S1
  target S2
  event E1
}
transition T2 {
  source S2
  target S3
  event E2
}

Other interesting dsl type would be a plain yaml format.

states
  - state: S1
    kind: initial
  - state: S2
  - state: S3
    kind: end

transitions:
  - source: S1
    target: S2
    event: E1
  - source: S2
    target: S3
    event: E2