From c9a5143b2aa9b92d1fbff4c804f058cf0e84f953 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Thu, 12 Mar 2020 21:45:18 +0100 Subject: add support for comments --- src/template.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'src/template.c') diff --git a/src/template.c b/src/template.c index f945b7e..51c9a77 100644 --- a/src/template.c +++ b/src/template.c @@ -72,23 +72,44 @@ mpc_parser_t *parser_init() { mpc_parser_t *Var = mpc_new("var"); mpc_parser_t *Block_Open = mpc_new("block_open"); mpc_parser_t *Block_Close = mpc_new("block_close"); + mpc_parser_t *Comment = mpc_new("comment"); + mpc_parser_t *Comment_Open = mpc_new("comment_open"); + mpc_parser_t *Comment_Close = mpc_new("comment_close"); mpc_parser_t *For = mpc_new("for"); mpc_parser_t *Body = mpc_new("body"); mpc_parser_t *Content = mpc_new("content"); mpc_parser_t *Template = mpc_new("template"); mpca_lang(MPCA_LANG_WHITESPACE_SENSITIVE, - " symbol : /[a-zA-Z_.]+/ ;" - " var_open : /\{{2} ?/ ;" - " var_close : / ?}{2}/ ;" - " var : ;" - " block_open: /\{\% ?/ ;" - " block_close: / ?\%}/ ;" - " for : \"for \" \" in \" \"endfor\" ;" - " text : /[^{][^{%]*/ ;" - " content : | | ;" - " body : * ;" - " template : /^/ /$/ ;", - Symbol, Symbols, Var_Open, Var_Close, Var, Block_Open, Block_Close, For, Text, Content, Body, Template, NULL); + " symbol : /[a-zA-Z_.]+/ ;" + " var_open : /\{{2} ?/ ;" + " var_close : / ?}{2}/ ;" + " var : ;" + " block_open: /\{\% ?/ ;" + " block_close: / ?\%}/ ;" + " comment_open : \"{#\" ;" + " comment_close : \"#}\" ;" + " comment : /[^#][^#}]*/ ;" + " for : \"for \" \" in \" \"endfor\" ;" + " text : /[^{][^{%]*/ ;" + " content : | | | ;" + " body : * ;" + " template : /^/ /$/ ;", + Symbol, + Symbols, + Var_Open, + Var_Close, + Var, + Block_Open, + Block_Close, + Comment_Open, + Comment_Close, + Comment, + For, + Text, + Content, + Body, + Template, + NULL); return Template; } -- cgit v1.2.3