mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Tweaked PIE (got rid of some parsing conflicts)
This commit is contained in:
parent
771bf78576
commit
e7ca6c16ff
@ -526,7 +526,7 @@ This might need adjustment to match your locale and preferences
|
||||
|
||||
## journey
|
||||
|
||||
The object containing configurations specific for sequence diagrams
|
||||
The object containing configurations specific for journey diagrams
|
||||
|
||||
### diagramMarginX
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
[\n\r]+ return 'NEWLINE';
|
||||
\%\%[^\n]* /* do nothing */
|
||||
[\s]+ /* ignore */
|
||||
title { console.log('starting title');this.begin("title");return 'title'; }
|
||||
<title>([^(?:\n#;)]*) { this.popState(); return "title_value"; }
|
||||
title { this.begin("title");return 'title'; }
|
||||
<title>(?!\n|;|#)*[^\n]* { this.popState(); return "title_value"; }
|
||||
["] { this.begin("string"); }
|
||||
<string>["] { this.popState(); }
|
||||
<string>[^"]* { return "txt"; }
|
||||
@ -41,9 +41,9 @@ title { console.log('s
|
||||
%% /* language grammar */
|
||||
|
||||
start
|
||||
: eol start { console.warn('NEWLINE start'); }
|
||||
| directive start { console.warn('directive start'); }
|
||||
| PIE document EOF { console.warn('PIE document EOF'); }
|
||||
: eol start
|
||||
| directive start
|
||||
| PIE document
|
||||
;
|
||||
|
||||
document
|
||||
@ -52,14 +52,13 @@ document
|
||||
;
|
||||
|
||||
line
|
||||
: statement { $$ = $1 }
|
||||
| eol { $$=[]; }
|
||||
: statement eol { $$ = $1 }
|
||||
;
|
||||
|
||||
statement
|
||||
:
|
||||
| txt value { yy.addSection($1,yy.cleanupValue($2)); }
|
||||
| title title_value { $$=$2.trim();yy.setTitle($$); }
|
||||
| txt value { yy.addSection($1,yy.cleanupValue($2)); }
|
||||
| title title_value { $$=$2.trim();yy.setTitle($$); }
|
||||
| directive
|
||||
;
|
||||
|
||||
@ -69,10 +68,9 @@ directive
|
||||
;
|
||||
|
||||
eol
|
||||
:
|
||||
| SPACE eol
|
||||
| NEWLINE eol
|
||||
| ';' eol
|
||||
: NEWLINE
|
||||
| ';'
|
||||
| EOF
|
||||
;
|
||||
|
||||
openDirective
|
||||
|
@ -12,6 +12,15 @@ describe('when parsing pie', function() {
|
||||
pie.parser.yy = pieDb;
|
||||
pie.parser.yy.clear();
|
||||
});
|
||||
it('should handle very simple pie', function() {
|
||||
const res = pie.parser.parse(`pie
|
||||
"ash" : 100
|
||||
`);
|
||||
const sections = pieDb.getSections();
|
||||
console.log('sections: ', sections);
|
||||
const section1 = sections['ash'];
|
||||
expect(section1).toBe(100);
|
||||
});
|
||||
it('should handle simple pie', function() {
|
||||
const res = pie.parser.parse(`pie
|
||||
"ash" : 60
|
||||
|
Loading…
x
Reference in New Issue
Block a user