Skip to content

Commit

Permalink
add atoms; remove useless subexpitem; remove < > from atoms; add test…
Browse files Browse the repository at this point in the history
…s for empty arrow descriptions and single item descriptions
  • Loading branch information
StoneCypher committed Jun 5, 2017
1 parent 687bbac commit 0676f1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/js/jssm-dot.peg
Expand Up @@ -11,9 +11,6 @@ TwoWayArrow "two way arrow"
Arrow
= ForwardArrow / TwoWayArrow

String "string"
= QuoteMark chars:Char* QuoteMark { return chars.join(""); }

HexDigit
= [0-9a-fA-F]

Expand All @@ -39,12 +36,18 @@ Escape = "\\"
QuoteMark = '"'
Unescaped = [\x20-\x21\x23-\x5B\x5D-\u10FFFF]

String "string"
= QuoteMark chars:Char* QuoteMark { return chars.join(""); }

Atom "atom"
= text:[0-9a-zA-Z\.\+\_\&\(\)\%\$\#\@\!\?\,\']+ { return text.join(''); }

Label "label"
= text:[0-9a-zA-Z\.\+\_\&\(\)\%\$\#\@\!\?\<\>\,\:\']+ { return text.join(''); }
/ text:String { return text.join(''); }
= atom:Atom
/ string:String

DescValue
= string:String
= label:Label

DescItem
= text:Label ":" value:DescValue ";"
Expand All @@ -64,9 +67,6 @@ Subexp
return {kind: arrow, to: label, se:(tail === [])? undefined: tail};
}

SubexpItem
= Subexp

Exp
= label:Label se:Subexp Whitespace ';' Whitespace {
return {from: label, se:(se === [])? undefined: se};
Expand Down
9 changes: 9 additions & 0 deletions src/js/tests/parse.js
Expand Up @@ -14,6 +14,15 @@ describe('parse/1', async it => {
it('a-> b;', t => t.deepEqual([0,1], jssm.parse('a-> b;') ));
it('a -> b;', t => t.deepEqual([0,1], jssm.parse('a -> b;') ));

it('a{}->b;', t => t.deepEqual([], jssm.parse('a{}->b;') ));
it('a->{}b;', t => t.deepEqual([0], jssm.parse('a->{}b;') ));
it('a{}->{}b;', t => t.deepEqual([0,1], jssm.parse('a{}->{}b;') ));

it('a{c:d}->b;', t => t.deepEqual([], jssm.parse('a{c:d}->b;') ));
it('a{c:"d"}->b;', t => t.deepEqual([], jssm.parse('a{c:"d"}->b;') ));
it('a{"c":d}->b;', t => t.deepEqual([], jssm.parse('a{"c":d}->b;') ));
it('a{"c":"d"}->b;', t => t.deepEqual([], jssm.parse('a{"c":"d"}->b;') ));

});

// stochable

0 comments on commit 0676f1f

Please sign in to comment.