Skip to content

Commit

Permalink
Make sequenceDiagram terminal newline optional
Browse files Browse the repository at this point in the history
Fixes gh-229
  • Loading branch information
gibson042 committed Nov 6, 2015
1 parent 76130bc commit dbd63ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
\-[x] return 'SOLID_CROSS';
\-\-[x] return 'DOTTED_CROSS';
":"[^#\n;]+ return 'TXT';
<<EOF>> return 'EOF';
<<EOF>> return 'NL';
. return 'INVALID';

/lex
Expand All @@ -57,7 +57,7 @@
%% /* language grammar */

start
: SD document 'EOF' { yy.apply($2);return $2; }
: SD document { yy.apply($2);return $2; }
;

document
Expand All @@ -69,7 +69,6 @@ line
: SPACE statement { $$ = $2 }
| statement { $$ = $1 }
| NL { $$=[];}
| EOF { $$=[];}
;

statement
Expand Down
38 changes: 19 additions & 19 deletions src/diagrams/sequenceDiagram/sequenceDiagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('when parsing a sequenceDiagram',function() {
str = 'sequenceDiagram\n' +
'Alice->Bob:Hello Bob, how are you?\n' +
'Note right of Bob: Bob thinks\n' +
'Bob-->Alice: I am good thanks!\n';
'Bob-->Alice: I am good thanks!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -49,7 +49,7 @@ describe('when parsing a sequenceDiagram',function() {
it('it should space in actor names', function () {
str = 'sequenceDiagram\n' +
'Alice->Bob:Hello Bob, how are - you?\n' +
'Bob-->Alice: I am good thanks!\n';
'Bob-->Alice: I am good thanks!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -64,7 +64,7 @@ describe('when parsing a sequenceDiagram',function() {
});
it('it should handle in async messages', function () {
var str = 'sequenceDiagram\n' +
'Alice-xBob:Hello Bob, how are you?\n';
'Alice-xBob:Hello Bob, how are you?';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -78,7 +78,7 @@ describe('when parsing a sequenceDiagram',function() {
});
it('it should handle in async dotted messages', function () {
var str = 'sequenceDiagram\n' +
'Alice--xBob:Hello Bob, how are you?\n';
'Alice--xBob:Hello Bob, how are you?';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -92,7 +92,7 @@ describe('when parsing a sequenceDiagram',function() {
});
it('it should handle in arrow messages', function () {
var str = 'sequenceDiagram\n' +
'Alice->>Bob:Hello Bob, how are you?\n';
'Alice->>Bob:Hello Bob, how are you?';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -106,7 +106,7 @@ describe('when parsing a sequenceDiagram',function() {
});
it('it should handle in arrow messages', function () {
var str = 'sequenceDiagram\n' +
'Alice-->>Bob:Hello Bob, how are you?\n';
'Alice-->>Bob:Hello Bob, how are you?';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -123,7 +123,7 @@ describe('when parsing a sequenceDiagram',function() {
'Alice->Bob: Hello Bob, how are you?\n'+
'%% Comment\n' +
'Note right of Bob: Bob thinks\n' +
'Bob-->Alice: I am good thanks!\n';
'Bob-->Alice: I am good thanks!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('when parsing a sequenceDiagram',function() {
' Alice->Bob: Hello Bob, how are you?\n\n' +
'%% Comment\n' +
'Note right of Bob: Bob thinks\n' +
'Bob-->Alice: I am good thanks!\n';
'Bob-->Alice: I am good thanks!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -194,7 +194,7 @@ describe('when parsing a sequenceDiagram',function() {
' Alice->Bob: Hello Bob, how are you?\n\n' +
'%% Comment\n' +
'Note right of Bob: Bob thinks\n' +
'Bob-->Alice: I am good thanks!\n';
'Bob-->Alice: I am good thanks!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand All @@ -218,7 +218,7 @@ describe('when parsing a sequenceDiagram',function() {
'Note right of John: Rational thoughts<br/>prevail...\n'+
' John-->Alice: Great!\n'+
' John->Bob: How about you?\n'+
'Bob-->John: Jolly good!\n';
'Bob-->John: Jolly good!';

sq.parse(str);
var actors = sq.yy.getActors();
Expand Down Expand Up @@ -611,7 +611,7 @@ describe('when rendering a sequenceDiagram',function() {
it('it should handle one actor', function () {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'participant Alice\n';
'participant Alice';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -627,7 +627,7 @@ describe('when rendering a sequenceDiagram',function() {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'participant Alice\n' +
'Note left of Alice: Alice thinks\n';
'Note left of Alice: Alice thinks';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -643,7 +643,7 @@ describe('when rendering a sequenceDiagram',function() {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'participant Alice\n' +
'Note right of Alice: Alice thinks\n';
'Note right of Alice: Alice thinks';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -658,7 +658,7 @@ describe('when rendering a sequenceDiagram',function() {
it('it should handle two actors', function () {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'Alice->Bob: Hello Bob, how are you?\n';
'Alice->Bob: Hello Bob, how are you?';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -674,7 +674,7 @@ describe('when rendering a sequenceDiagram',function() {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'Alice->Bob: Hello Bob, how are you?\n'+
'Bob->Alice: Fine!\n';
'Bob->Alice: Fine!';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -691,7 +691,7 @@ describe('when rendering a sequenceDiagram',function() {
var str = 'sequenceDiagram\n' +
'Alice->Bob: Hello Bob, how are you?\n'+
'Note right of Bob: Bob thinks\n' +
'Bob->Alice: Fine!\n';
'Bob->Alice: Fine!';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -711,7 +711,7 @@ describe('when rendering a sequenceDiagram',function() {
var str = 'sequenceDiagram\n' +
'Alice->Bob: Hello Bob, how are you?\n'+
'Note left of Alice: Bob thinks\n' +
'Bob->Alice: Fine!\n';
'Bob->Alice: Fine!';

sq.parse(str);
sd.draw(str,'tst');
Expand All @@ -730,7 +730,7 @@ describe('when rendering a sequenceDiagram',function() {
'Alice->Bob: Hello Bob, how are you?\n'+
'loop Cheers\n' +
'Bob->Alice: Fine!\n' +
'end\n';
'end';
sq.parse(str);
sd.draw(str,'tst');

Expand Down Expand Up @@ -806,7 +806,7 @@ describe('when rendering a sequenceDiagram with actor mirror activated',function
it('it should handle one actor', function () {
sd.bounds.init();
var str = 'sequenceDiagram\n' +
'participant Alice\n';
'participant Alice';

sq.parse(str);
sd.draw(str,'tst');
Expand Down

0 comments on commit dbd63ff

Please sign in to comment.