mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 14:29:25 +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
|
||||
: graphConfig statements EOF
|
||||
| graphConfig statements
|
||||
| graphConfig spaceListNewline statements EOF
|
||||
{$$=$1;}
|
||||
| graphConfig spaceListNewline statements
|
||||
{$$=$1;}
|
||||
;
|
||||
|
||||
graphConfig
|
||||
: GRAPH SPACE DIR SEMI
|
||||
{ yy.setDirection($3);$$ = $3;}
|
||||
| GRAPH SPACE DIR NEWLINE
|
||||
{ yy.setDirection($3);$$ = $3;}
|
||||
| GRAPH SPACE DIR spaceList NEWLINE
|
||||
{ yy.setDirection($3);$$ = $3;}
|
||||
;
|
||||
|
||||
statements
|
||||
@@ -152,11 +159,23 @@ statement
|
||||
: commentStatement NEWLINE
|
||||
{$$='Comment';}
|
||||
| verticeStatement SEMI
|
||||
| verticeStatement NEWLINE
|
||||
| verticeStatement EOF
|
||||
| styleStatement SEMI
|
||||
| styleStatement NEWLINE
|
||||
| styleStatement EOF
|
||||
| linkStyleStatement SEMI
|
||||
| linkStyleStatement NEWLINE
|
||||
| linkStyleStatement EOF
|
||||
| classDefStatement SEMI
|
||||
| classDefStatement NEWLINE
|
||||
| classDefStatement EOF
|
||||
| classStatement SEMI
|
||||
| classStatement NEWLINE
|
||||
| classStatement EOF
|
||||
| clickStatement SEMI
|
||||
| clickStatement NEWLINE
|
||||
| clickStatement EOF
|
||||
;
|
||||
|
||||
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('');
|
||||
});
|
||||
|
||||
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(){
|
||||
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');
|
||||
|
||||
|
Reference in New Issue
Block a user