site.fabricate.prototype.read.grammar Namespace

Instaparse grammar for Fabricate's page templates.


The grammar definition

This Instaparse grammar defines the structure of Fabricate templates. Once parsed into an Instaparse parse tree, the read namespace walks the parsed template and evaluates the expressions embedded within it. The grammar, as defined, intentionally does not concern itself with whether the contents of the expressions in each template are syntactically valid Clojure forms; that task is left to the reader. Defining the grammar this way allows Clojure read errors to be caught and handled on a form-by-form basis instead of throwing an error for the whole page.

template = Īµ | (expr | txt | extended-form)*
initial = "āœ³"
terminal = "šŸ”š"
ctrl = "=" | "+" | "+="
expr =  !"//" ctrl? #"[^=+][^šŸ”š]*" !"//" 
txt = #"(\A[^āœ³šŸ”š]*+\Z)|([\S\s]*?(?=\Z|(?:[\]})]//šŸ”š|āœ³|šŸ”š)))"
form-contents = (expr | txt | extended-form)+
extended-form =  <"//"> "[" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents "]" <"//">  |  <"//"> "(" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents ")" <"//">  |  <"//"> "{" #"[^\nāœ³šŸ”š]*" <"\n"> form-contents "}" <"//"> 

For an informal guide to how these templates get used with examples, please see the page A Reference to Fabricate's Page Templates.

Constants


delimiters
Description
Type
clojure.lang.PersistentVector
template
Description
The formal grammar for Fabricate templates.
Type
instaparse.core.Parser