Tweaked PIE (got rid of some parsing conflicts)

This commit is contained in:
chris moran 2020-07-27 14:15:38 -04:00
parent 771bf78576
commit e7ca6c16ff
No known key found for this signature in database
GPG Key ID: 7E303019E6BB02D7
3 changed files with 21 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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