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