mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
#945 Handling of fork statements
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
// Special states for recognizing aliases
|
// Special states for recognizing aliases
|
||||||
%x ID
|
%x ID
|
||||||
%x STATE
|
%x STATE
|
||||||
|
%x FORK_STATE
|
||||||
%x STATE_STRING
|
%x STATE_STRING
|
||||||
%x STATE_ID
|
%x STATE_ID
|
||||||
%x ALIAS
|
%x ALIAS
|
||||||
@@ -37,6 +38,8 @@
|
|||||||
<SCALE>\s+"width" {this.popState();}
|
<SCALE>\s+"width" {this.popState();}
|
||||||
|
|
||||||
<INITIAL,struct>"state"\s+ { this.pushState('STATE'); }
|
<INITIAL,struct>"state"\s+ { this.pushState('STATE'); }
|
||||||
|
<STATE>.*"<<fork>>" {this.popState();console.log('Fork: ',yytext);return 'FORK';}
|
||||||
|
<STATE>.*"<<join>>" {this.popState();console.log('Join: ',yytext);return 'JOIN';}
|
||||||
<STATE>["] this.begin("STATE_STRING");
|
<STATE>["] this.begin("STATE_STRING");
|
||||||
<STATE>"as"\s* {this.popState();this.pushState('STATE_ID');return "AS";}
|
<STATE>"as"\s* {this.popState();this.pushState('STATE_ID');return "AS";}
|
||||||
<STATE_ID>[^\n]* {this.popState();console.log('ID');return "ID";}
|
<STATE_ID>[^\n]* {this.popState();console.log('ID');return "ID";}
|
||||||
@@ -114,6 +117,8 @@ statement
|
|||||||
| scale WIDTH
|
| scale WIDTH
|
||||||
| COMPOSIT_STATE STRUCT_START document STRUCT_STOP
|
| COMPOSIT_STATE STRUCT_START document STRUCT_STOP
|
||||||
| STATE_DESCR AS ID
|
| STATE_DESCR AS ID
|
||||||
|
| FORK
|
||||||
|
| JOIN
|
||||||
;
|
;
|
||||||
|
|
||||||
idStatement
|
idStatement
|
||||||
|
@@ -151,23 +151,23 @@ describe('state diagram, ', function() {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
// it('should handle relation definitions', function() {
|
it('should handle fork statements', function() {
|
||||||
// const str = `stateDiagram\n
|
const str = `stateDiagram\n
|
||||||
// state fork_state <<fork>>
|
state fork_state <<fork>>
|
||||||
// [*] --> fork_state
|
[*] --> fork_state
|
||||||
// fork_state --> State2
|
fork_state --> State2
|
||||||
// fork_state --> State3
|
fork_state --> State3
|
||||||
|
|
||||||
// state join_state <<join>>
|
state join_state <<join>>
|
||||||
// State2 --> join_state
|
State2 --> join_state
|
||||||
// State3 --> join_state
|
State3 --> join_state
|
||||||
// join_state --> State4
|
join_state --> State4
|
||||||
// State4 --> [*]
|
State4 --> [*]
|
||||||
// `;
|
`;
|
||||||
|
|
||||||
// parser.parse(str);
|
parser.parse(str);
|
||||||
// });
|
});
|
||||||
// it('should handle relation definitions', function() {
|
// it('should handle concurrent state', function() {
|
||||||
// const str = `stateDiagram\n
|
// const str = `stateDiagram\n
|
||||||
// [*] --> Active
|
// [*] --> Active
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user