mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Merge pull request #63 from vijay40/master
New grammar will allow statements ending without semicolon as disccused in Issue #38
This commit is contained in:
@@ -120,13 +120,20 @@
|
|||||||
|
|
||||||
expressions
|
expressions
|
||||||
: graphConfig statements EOF
|
: graphConfig statements EOF
|
||||||
|
| graphConfig statements
|
||||||
| graphConfig spaceListNewline statements EOF
|
| graphConfig spaceListNewline statements EOF
|
||||||
{$$=$1;}
|
{$$=$1;}
|
||||||
|
| graphConfig spaceListNewline statements
|
||||||
|
{$$=$1;}
|
||||||
;
|
;
|
||||||
|
|
||||||
graphConfig
|
graphConfig
|
||||||
: GRAPH SPACE DIR SEMI
|
: GRAPH SPACE DIR SEMI
|
||||||
{ yy.setDirection($3);$$ = $3;}
|
{ yy.setDirection($3);$$ = $3;}
|
||||||
|
| GRAPH SPACE DIR NEWLINE
|
||||||
|
{ yy.setDirection($3);$$ = $3;}
|
||||||
|
| GRAPH SPACE DIR spaceList NEWLINE
|
||||||
|
{ yy.setDirection($3);$$ = $3;}
|
||||||
;
|
;
|
||||||
|
|
||||||
statements
|
statements
|
||||||
@@ -152,11 +159,23 @@ statement
|
|||||||
: commentStatement NEWLINE
|
: commentStatement NEWLINE
|
||||||
{$$='Comment';}
|
{$$='Comment';}
|
||||||
| verticeStatement SEMI
|
| verticeStatement SEMI
|
||||||
|
| verticeStatement NEWLINE
|
||||||
|
| verticeStatement EOF
|
||||||
| styleStatement SEMI
|
| styleStatement SEMI
|
||||||
|
| styleStatement NEWLINE
|
||||||
|
| styleStatement EOF
|
||||||
| linkStyleStatement SEMI
|
| linkStyleStatement SEMI
|
||||||
|
| linkStyleStatement NEWLINE
|
||||||
|
| linkStyleStatement EOF
|
||||||
| classDefStatement SEMI
|
| classDefStatement SEMI
|
||||||
|
| classDefStatement NEWLINE
|
||||||
|
| classDefStatement EOF
|
||||||
| classStatement SEMI
|
| classStatement SEMI
|
||||||
|
| classStatement NEWLINE
|
||||||
|
| classStatement EOF
|
||||||
| clickStatement SEMI
|
| clickStatement SEMI
|
||||||
|
| clickStatement NEWLINE
|
||||||
|
| clickStatement EOF
|
||||||
;
|
;
|
||||||
|
|
||||||
verticeStatement:
|
verticeStatement:
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -46,6 +46,22 @@ describe('when parsing ',function(){
|
|||||||
expect(edges[0].text).toBe('');
|
expect(edges[0].text).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle a nodes and edges, a space between link and node and each line ending without semicolon',function(){
|
||||||
|
var res = flow.parser.parse('graph TD\nA --> B\n style e red');
|
||||||
|
|
||||||
|
|
||||||
|
var vert = flow.parser.yy.getVertices();
|
||||||
|
var edges = flow.parser.yy.getEdges();
|
||||||
|
|
||||||
|
expect(vert['A'].id).toBe('A');
|
||||||
|
expect(vert['B'].id).toBe('B');
|
||||||
|
expect(edges.length).toBe(1);
|
||||||
|
expect(edges[0].start).toBe('A');
|
||||||
|
expect(edges[0].end).toBe('B');
|
||||||
|
expect(edges[0].type).toBe('arrow');
|
||||||
|
expect(edges[0].text).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle a comments',function(){
|
it('should handle a comments',function(){
|
||||||
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');
|
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user