Allow node ids with keywords as suffixes

I've extracted alpha and punctuation characters from the huge regex and
made multiple occurences of alpha characters be recognised as a single
ALPHA token.

This way everything should work just like before, with the
difference that alpha strings will swallow keywords, ie. `spend` is
`ALPHA`, while previously it would have been `ALPHA ALPHA end`.
This commit is contained in:
Tomasz Szczęśniak-Szlagowski
2015-10-24 22:25:13 +01:00
parent 841aea9d97
commit 30149df88e
3 changed files with 45 additions and 27 deletions

View File

@@ -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;');