Skip to content

Commit

Permalink
Merge pull request #235 from spect88/fix-keyword-suffix
Browse files Browse the repository at this point in the history
Allow keywords as suffixes of node ids
  • Loading branch information
knsv committed Oct 25, 2015
2 parents d68323d + 30149df commit cee2671
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 52 deletions.
16 changes: 11 additions & 5 deletions src/diagrams/example/parser/example.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/diagrams/flowchart/parser/dot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/diagrams/flowchart/parser/flow.jison
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
\% return 'PCT';
"=" return 'EQUALS';
\= return 'EQUALS';
[\u0021-\u0027\u002A-\u002E\u003F\u0041-\u005A\u005C\u005F-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|
[A-Za-z]+ return 'ALPHA';
[!"#$%&'*+,-.`?\\_/] return 'PUNCTUATION';
[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|
[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|
[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|
[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|
Expand Down Expand Up @@ -121,10 +123,10 @@
[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|
[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|
[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|
[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]]|
[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|
[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|
[\uFFD2-\uFFD7\uFFDA-\uFFDC_\/]
return 'ALPHA';
[\uFFD2-\uFFD7\uFFDA-\uFFDC]
return 'UNICODE_TEXT';
"|" return 'PIPE';
"(" return 'PS';
")" return 'PE';
Expand Down Expand Up @@ -429,7 +431,7 @@ textToken : textNoTagsToken | TAGSTART | TAGEND | '==' | '--' | PCT | DEFA

textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ;

alphaNumToken : ALPHA | NUM | COLON | COMMA | PLUS | EQUALS | MULT | DOT | BRKT ;
alphaNumToken : ALPHA | PUNCTUATION | UNICODE_TEXT | NUM | COLON | COMMA | PLUS | EQUALS | MULT | DOT | BRKT ;

graphCodeTokens: PIPE | PS | PE | SQS | SQE | DIAMOND_START | DIAMOND_STOP | TAG_START | TAG_END | ARROW_CROSS | ARROW_POINT | ARROW_CIRCLE | ARROW_OPEN | QUOTE | SEMI ;
%%
64 changes: 37 additions & 27 deletions src/diagrams/flowchart/parser/flow.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/diagrams/flowchart/parser/flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ describe('when parsing ',function(){
expect(edges[0].end).toBe('sender');
});

it('should handle node names ending with keywords',function(){
var res = flow.parser.parse('graph TD\nblend --> monograph');

var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();

expect(vert['blend'].id).toBe('blend');
expect(vert['monograph'].id).toBe('monograph');
expect(edges[0].start).toBe('blend');
expect(edges[0].end).toBe('monograph');
});

it('should handle open ended edges',function(){
var res = flow.parser.parse('graph TD;A---B;');

Expand Down
16 changes: 11 additions & 5 deletions src/diagrams/gantt/parser/gantt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/diagrams/sequenceDiagram/parser/sequenceDiagram.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cee2671

Please sign in to comment.