Initial OHM grammar for extends tag

OHM is a PEG-based grammar parser generator which seems to be more
compatible with the Jinja language. We are not making use of their
automatic space handling since in Jinja whitespace is significant.
This commit is contained in:
Kevin 2024-05-22 11:25:40 -04:00
parent 8710cabd4f
commit 72ab9b5015

34
grammar/jinja.ohm Normal file
View File

@ -0,0 +1,34 @@
Jinja {
Template
= expressions
expressions
= expression*
expression
= inlineStatement
inlineStatement
= statementOpen sp? inlineStatementContent sp? statementClose
inlineStatementContent
= statement_extends
statement_extends
= statementId_extends sp stringLiteral
statementOpen = "{%"
statementClose = "%}"
statementId_extends = "extends"
stringLiteral = stringLiteral_single | stringLiteral_double
stringLiteral_single = quote_single (~quote_single any)* quote_single
stringLiteral_double = quote_double (~quote_double any)* quote_double
quote_single = "'"
quote_double = "\""
sp = (" " | "\t")+
}