silverbullet/common/template/template.grammar

36 lines
751 B
Plaintext

@top Template { TemplateElement* }
TemplateElement {
Text
| ExpressionDirective
| BlockDirective
}
BlockDirective {
BlockDirectiveOpenTagStart BlockName BlockDirectiveContent DirectiveTagEnd
TemplateElement*
BlockDirectiveCloseTagStart BlockName DirectiveTagEnd
}
ExpressionDirective {
ExpressionDirectiveOpenTag BlockDirectiveContent DirectiveTagEnd
}
@tokens {
@precedence { BlockDirectiveOpenTagStart, ExpressionDirectiveOpenTag, Text }
Text { (![{] | "{" ![{])+ }
BlockName { @asciiLetter+ }
BlockDirectiveContent { ( ![}] | "{" ![}]* "}" )+ }
ExpressionDirectiveOpenTag { "{{" }
BlockDirectiveOpenTagStart { "{{#" }
BlockDirectiveCloseTagStart { "{{/" }
DirectiveTagEnd { "}}" }
}