]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Initial OHM grammar for extends tag
authorKevin <github@kevin-brown.com>
Wed, 22 May 2024 15:25:40 +0000 (11:25 -0400)
committerKevin <github@kevin-brown.com>
Wed, 22 May 2024 15:25:40 +0000 (11:25 -0400)
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.

grammar/jinja.ohm [new file with mode: 0644]

diff --git a/grammar/jinja.ohm b/grammar/jinja.ohm
new file mode 100644 (file)
index 0000000..0b72ea0
--- /dev/null
@@ -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")+
+}
\ No newline at end of file