Changed grammar for states
This commit is contained in:
parent
bc458299dc
commit
c1c062b6cf
3 changed files with 13 additions and 13 deletions
18
README.md
18
README.md
|
@ -163,9 +163,9 @@ name it from the last path segment and add 'Response' to the end of the data typ
|
||||||
### State DSL
|
### State DSL
|
||||||
This is an example of a state file:
|
This is an example of a state file:
|
||||||
```
|
```
|
||||||
start -> middle: message,
|
start -> message -> middle ,
|
||||||
middle -> middle: selfmessage,
|
middle -> selfmessage -> middle,
|
||||||
middle -> end: endmessage
|
middle -> endmessage -> end
|
||||||
```
|
```
|
||||||
The file declares 3 transitions. The first line states: Transition from the 'start' state to the 'middle' state with
|
The file declares 3 transitions. The first line states: Transition from the 'start' state to the 'middle' state with
|
||||||
the message 'message'.
|
the message 'message'.
|
||||||
|
@ -178,18 +178,18 @@ Since the parser will extract datatypes it is possible to define the fields of t
|
||||||
complicated example:
|
complicated example:
|
||||||
|
|
||||||
```
|
```
|
||||||
start -> middle: message(a: String),
|
start -> message -> middle,
|
||||||
middle(bar:Bar) -> middle: selfmessage,
|
middle -> selfmessage -> middle(bar:bar),
|
||||||
middle -> end: endmessage
|
middle -> message -> end
|
||||||
```
|
```
|
||||||
The data type for `middle` will have a field declaration with the name `bar` and the type `Bar`.
|
The data type for `middle` will have a field declaration with the name `bar` and the type `Bar`.
|
||||||
|
|
||||||
Fields for the same state data type, or message data type, will be merged. Here is a complex example:
|
Fields for the same state data type, or message data type, will be merged. Here is a complex example:
|
||||||
|
|
||||||
```
|
```
|
||||||
start(s:S) -> middle(foo:foo): message(foo:foo),
|
start(s:S) -> message(foo:foo) -> middle(foo:foo) ,
|
||||||
middle -> middle(bar:bar): selfmessage(bar:bar),
|
middle -> selfmessage(bar:bar) -> middle(bar:bar),
|
||||||
middle -> end: message(bar:baz)
|
middle -> message(bar:baz) -> end
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that we can declare fields on both the `from` and `to` state declarations. The `middle` datat type will have field
|
Note that we can declare fields on both the `from` and `to` state declarations. The `middle` datat type will have field
|
||||||
|
|
|
@ -15,7 +15,7 @@ grammar States;
|
||||||
import Common;
|
import Common;
|
||||||
|
|
||||||
document : generatorconfig? transition (',' transition)* ;
|
document : generatorconfig? transition (',' transition)* ;
|
||||||
transition : from RIGHT_ARROW to COLON message ;
|
transition : from RIGHT_ARROW message RIGHT_ARROW to ;
|
||||||
from : state ;
|
from : state ;
|
||||||
to : state ;
|
to : state ;
|
||||||
message : typeName typeDeclaration? ;
|
message : typeName typeDeclaration? ;
|
||||||
|
|
|
@ -16,6 +16,6 @@
|
||||||
|
|
||||||
{ title: SomeNodes, package: nu.zoom.dsl.states }
|
{ title: SomeNodes, package: nu.zoom.dsl.states }
|
||||||
|
|
||||||
start(s:S) -> middle(foo:foo): message(foo:foo),
|
start(s:S) -> message(foo:foo) -> middle(foo:foo) ,
|
||||||
middle -> middle(bar:bar): selfmessage(bar:bar),
|
middle -> selfmessage(bar:bar) -> middle(bar:bar),
|
||||||
middle -> end: message(bar:baz)
|
middle -> message(bar:baz) -> end
|
||||||
|
|
Loading…
Add table
Reference in a new issue