Skip to content

Commit

Permalink
simplify ebnf grammar definition [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
marcioAlmada committed Apr 15, 2015
1 parent 9495bb9 commit 51aaf38
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Please refer to annotations bag public [API](#minimeannotationsreader) for more

## The Default Syntax

![@(<namespace><namespace-delimiter>)?<annotation-identifier> <type>? <value>?](https://dl.dropboxusercontent.com/u/49549530/annotations/grammar.png)
![@(<namespace><namespace-delimiter>)?<annotation-identifier> <type>? <value>?](https://dl.dropboxusercontent.com/u/49549530/annotations/grammar.png?v=c81e)

Which basically means that:

Expand Down
4 changes: 2 additions & 2 deletions spec/annotation.ebnf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
annotation ::= '@'(namespace delimiter)*(identifier) ((type |) value |)
annotation ::= '@'(namespace|)(identifier) ((type |) value |)
identifier ::= '[a-z] [A-Z] [0-9] _ -'
namespace ::= ('\' |)('[a-z] [A-Z] _ -'(delimiter))*
namespace ::= (delimiter|)(identifier(delimiter))+
delimiter ::= '.' | '\'
type ::= 'json' | 'string' | 'integer' | 'float' | '->'
value ::= 'any unicode characters including \n'
79 changes: 38 additions & 41 deletions spec/annotation.ebnf_grammar/all.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
<!DOCTYPE html>
<html>
<body>
<svg width="912" height="204" viewBox="-8 -86 912 204 " xmlns="http://www.w3.org/2000/svg" version="1.1">
<svg width="758" height="176" viewBox="-8 -58 758 176 " xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs><style type="text/css">.terminal_rect{fill:rgb(206,255,206);stroke:black;stroke-width:2;}.terminal_text{fill:black;font-family:Verdana,Sans-serif;text-anchor:middle;font-size:14px;}.symbol_rect{fill:rgb(206,255,206);stroke:black;stroke-width:2;}.symbol_text{fill:black;font-family:Verdana,Sans-serif;font-weight:bold;font-style:italic;text-anchor:middle;font-size:14px;}.path{fill:none;stroke:black;stroke-width:2;}.rule_text{fill:black;font-family:Verdana,Sans-serif;font-weight:bold;font-size:14px;}.rule_path_edge{fill:none;stroke:black;stroke-width:3;}</style></defs>
<text class="rule_text" x="0" y="-64" >annotation:</text>
<text class="rule_text" x="0" y="-36" >annotation:</text>
<rect class="terminal_rect" x="30" y="-14" width="26" height="28" rx="28" />
<text class="terminal_text" x="43" y="4" >@</text>
<rect class="symbol_rect" x="128" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="181" y="4" >namespace</text>
<rect class="symbol_rect" x="258" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="311" y="4" >delimiter</text>
<path class="path" d="M234 0 L258 0" />
<path class="path" d="M128 0 L104 0 M116 0 Q104 0 104 -12 L104 -36 Q104 -48 116 -48 L376 -48 Q388 -48 388 -36 L388 -12 Q388 0 376 0 L364 0 L388 0" />
<path class="path" d="M128 0 L80 0 Q92 0 92 12 L92 24 Q92 36 104 36 L388 36 Q400 36 400 24 L400 12 Q400 0 412 0 L364 0 M80 0 L104 0 M388 0 L412 0" />
<rect class="symbol_rect" x="436" y="-14" width="116" height="28" rx="1" />
<text class="symbol_text" x="494" y="4" >identifier</text>
<rect class="symbol_rect" x="648" y="-14" width="56" height="28" rx="1" />
<text class="symbol_text" x="676" y="4" >type</text>
<path class="path" d="M648 44 L664 44" />
<path class="path" d="M612 0 L648 0 M612 0 Q624 0 624 12 M740 0 L704 0 M740 0 Q728 0 728 12" />
<path class="path" d="M636 44 L648 44 M636 44 Q624 44 624 32 L624 12 M716 44 L664 44 M716 44 Q728 44 728 32 L728 12" />
<rect class="symbol_rect" x="764" y="-14" width="66" height="28" rx="1" />
<text class="symbol_text" x="797" y="4" >value</text>
<path class="path" d="M740 0 L764 0" />
<path class="path" d="M612 88 L628 88" />
<path class="path" d="M576 0 L612 0 M576 0 Q588 0 588 12 M866 0 L830 0 M866 0 Q854 0 854 12" />
<path class="path" d="M600 88 L612 88 M600 88 Q588 88 588 76 L588 12 M842 88 L628 88 M842 88 Q854 88 854 76 L854 12" />
<rect class="symbol_rect" x="116" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="169" y="4" >namespace</text>
<path class="path" d="M116 44 L132 44" />
<path class="path" d="M80 0 L116 0 M80 0 Q92 0 92 12 M258 0 L222 0 M258 0 Q246 0 246 12" />
<path class="path" d="M104 44 L116 44 M104 44 Q92 44 92 32 L92 12 M234 44 L132 44 M234 44 Q246 44 246 32 L246 12" />
<rect class="symbol_rect" x="282" y="-14" width="116" height="28" rx="1" />
<text class="symbol_text" x="340" y="4" >identifier</text>
<rect class="symbol_rect" x="494" y="-14" width="56" height="28" rx="1" />
<text class="symbol_text" x="522" y="4" >type</text>
<path class="path" d="M494 44 L510 44" />
<path class="path" d="M458 0 L494 0 M458 0 Q470 0 470 12 M586 0 L550 0 M586 0 Q574 0 574 12" />
<path class="path" d="M482 44 L494 44 M482 44 Q470 44 470 32 L470 12 M562 44 L510 44 M562 44 Q574 44 574 32 L574 12" />
<rect class="symbol_rect" x="610" y="-14" width="66" height="28" rx="1" />
<text class="symbol_text" x="643" y="4" >value</text>
<path class="path" d="M586 0 L610 0" />
<path class="path" d="M458 88 L474 88" />
<path class="path" d="M422 0 L458 0 M422 0 Q434 0 434 12 M712 0 L676 0 M712 0 Q700 0 700 12" />
<path class="path" d="M446 88 L458 88 M446 88 Q434 88 434 76 L434 12 M688 88 L474 88 M688 88 Q700 88 700 76 L700 12" />
<path class="path" d="M56 0 L80 0" />
<path class="path" d="M412 0 L436 0" />
<path class="path" d="M552 0 L576 0" />
<path class="path" d="M0 0 L30 0 M896 0 L866 0" />
<path class="rule_path_edge" d="M0 -6 L0 6 M896 -6 L896 6" />
<path class="path" d="M258 0 L282 0" />
<path class="path" d="M398 0 L422 0" />
<path class="path" d="M0 0 L30 0 M742 0 L712 0" />
<path class="rule_path_edge" d="M0 -6 L0 6 M742 -6 L742 6" />
</svg>
<br />
<br />
Expand All @@ -44,24 +42,23 @@
</svg>
<br />
<br />
<svg width="590" height="160" viewBox="-8 -86 590 160 " xmlns="http://www.w3.org/2000/svg" version="1.1">
<svg width="572" height="160" viewBox="-8 -86 572 160 " xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs><style type="text/css">.terminal_rect{fill:rgb(206,255,206);stroke:black;stroke-width:2;}.terminal_text{fill:black;font-family:Verdana,Sans-serif;text-anchor:middle;font-size:14px;}.symbol_rect{fill:rgb(206,255,206);stroke:black;stroke-width:2;}.symbol_text{fill:black;font-family:Verdana,Sans-serif;font-weight:bold;font-style:italic;text-anchor:middle;font-size:14px;}.path{fill:none;stroke:black;stroke-width:2;}.rule_text{fill:black;font-family:Verdana,Sans-serif;font-weight:bold;font-size:14px;}.rule_path_edge{fill:none;stroke:black;stroke-width:3;}</style></defs>
<text class="rule_text" x="0" y="-64" >namespace:</text>
<rect class="terminal_rect" x="66" y="-14" width="26" height="28" rx="28" />
<text class="terminal_text" x="79" y="4" >\</text>
<rect class="symbol_rect" x="66" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="119" y="4" >delimiter</text>
<path class="path" d="M66 44 L82 44" />
<path class="path" d="M30 0 L66 0 M30 0 Q42 0 42 12 M128 0 L92 0 M128 0 Q116 0 116 12" />
<path class="path" d="M54 44 L66 44 M54 44 Q42 44 42 32 L42 12 M104 44 L82 44 M104 44 Q116 44 116 32 L116 12" />
<rect class="terminal_rect" x="200" y="-14" width="166" height="28" rx="28" />
<text class="terminal_text" x="283" y="4" >[a-z] [A-Z] _ -</text>
<rect class="symbol_rect" x="390" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="443" y="4" >delimiter</text>
<path class="path" d="M366 0 L390 0" />
<path class="path" d="M200 0 L176 0 M188 0 Q176 0 176 -12 L176 -36 Q176 -48 188 -48 L508 -48 Q520 -48 520 -36 L520 -12 Q520 0 508 0 L496 0 L520 0" />
<path class="path" d="M200 0 L152 0 Q164 0 164 12 L164 24 Q164 36 176 36 L520 36 Q532 36 532 24 L532 12 Q532 0 544 0 L496 0 M152 0 L176 0 M520 0 L544 0" />
<path class="path" d="M128 0 L152 0" />
<path class="path" d="M0 0 L30 0 M574 0 L544 0" />
<path class="rule_path_edge" d="M0 -6 L0 6 M574 -6 L574 6" />
<path class="path" d="M30 0 L66 0 M30 0 Q42 0 42 12 M208 0 L172 0 M208 0 Q196 0 196 12" />
<path class="path" d="M54 44 L66 44 M54 44 Q42 44 42 32 L42 12 M184 44 L82 44 M184 44 Q196 44 196 32 L196 12" />
<rect class="symbol_rect" x="256" y="-14" width="116" height="28" rx="1" />
<text class="symbol_text" x="314" y="4" >identifier</text>
<rect class="symbol_rect" x="396" y="-14" width="106" height="28" rx="1" />
<text class="symbol_text" x="449" y="4" >delimiter</text>
<path class="path" d="M372 0 L396 0" />
<path class="path" d="M256 0 L232 0 M244 0 Q232 0 232 -12 L232 -36 Q232 -48 244 -48 L514 -48 Q526 -48 526 -36 L526 -12 Q526 0 514 0 L502 0 L526 0" />
<path class="path" d="M208 0 L232 0" />
<path class="path" d="M0 0 L30 0 M556 0 L526 0" />
<path class="rule_path_edge" d="M0 -6 L0 6 M556 -6 L556 6" />
</svg>
<br />
<br />
Expand Down
50 changes: 24 additions & 26 deletions spec/annotation.ebnf_grammar/annotation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 14 additions & 15 deletions spec/annotation.ebnf_grammar/namespace.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 51aaf38

Please sign in to comment.