# # Context free grammar for the Emerald language. # Emerald: a preprocessor for html5. # grammar Emerald include Tokens include Scopes include Variables rule main (scope / pair_list / value_list / nested / line / comment)+ end rule nested tag_statement newline lbrace newline main rbrace newline end rule scope fn:scope_fn lbrace newline body:main rbrace newline end rule line (tag_statement / comment) newline end rule value_list keyword:special_keyword newline lbrace newline list_items:(literal:inline_literal_string newline)+ rbrace newline end rule pair_list keyword:base_keyword newline lbrace newline list_items:(pairs:(attr:attr space+ literal:inline_literal_string space*)+ newline)+ rbrace newline end rule comment space* '*' space* text_content end rule text_content multiline_literal / multiline_templateless_literal / inline_literal end rule multiline_literal "->" space* newline body:(variable / escaped / !'$' .)* "$" end rule multiline_templateless_literal ("=>" / "~>") space* newline body:(escaped / !'$' .)* "$" end rule inline_literal body:( variable / escaped / !lparen !newline . )* end rule inline_literal_string '"' body:( variable / escaped / !'"' . )* '"' end rule escaped "\\" . end rule tag_statement tag identifier:id_name? classes:class_name* space* body:text_content? attributes:attr_list? end rule id_name '#' name:([a-zA-Z_\-]+) end rule class_name '.' name:([a-zA-Z_\-]+) end rule attr_list lparen newline lbrace newline attributes rbrace newline rparen end rule attributes attribute* end rule attribute attr space* inline_literal_string newline end end