diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-27 00:10:26 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-27 00:10:26 -0300 |
commit | 5205db347cb9f56187c2ad5e767281a7a4016533 (patch) | |
tree | 946917c0bbcfd17a6cd02b3bc03fd7f37fdb6cc9 /src/template-parser.c | |
parent | 2dfa0fbac45122567988cb520e508f24897114fe (diff) | |
download | blogc-5205db347cb9f56187c2ad5e767281a7a4016533.tar.gz blogc-5205db347cb9f56187c2ad5e767281a7a4016533.tar.bz2 blogc-5205db347cb9f56187c2ad5e767281a7a4016533.zip |
added global variable support
Diffstat (limited to 'src/template-parser.c')
-rw-r--r-- | src/template-parser.c | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/src/template-parser.c b/src/template-parser.c index 69402cf..a91182f 100644 --- a/src/template-parser.c +++ b/src/template-parser.c @@ -143,36 +143,22 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err) break; } else if (0 == strncmp("if", src + start, current - start)) { - if (block_state == BLOCK_ENTRY || block_state == BLOCK_LISTING) { - state = TEMPLATE_BLOCK_IF_START; - type = BLOGC_TEMPLATE_IF_STMT; - start = current; - if_count++; - break; - } - *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, - src, src_len, current, - "'if' statements only allowed inside 'entry' and " - "'listing' blocks."); + state = TEMPLATE_BLOCK_IF_START; + type = BLOGC_TEMPLATE_IF_STMT; + start = current; + if_count++; break; } else if (0 == strncmp("endif", src + start, current - start)) { - if (block_state == BLOCK_ENTRY || block_state == BLOCK_LISTING) { - if (if_count > 0) { - state = TEMPLATE_BLOCK_END; - type = BLOGC_TEMPLATE_ENDIF_STMT; - if_count--; - break; - } - *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, - src, src_len, current, - "'endif' statement without an open 'if' statement."); + if (if_count > 0) { + state = TEMPLATE_BLOCK_END; + type = BLOGC_TEMPLATE_ENDIF_STMT; + if_count--; break; } *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, src, src_len, current, - "'endif' statements only allowed inside 'entry' " - "and 'listing' blocks."); + "'endif' statement without an open 'if' statement."); break; } } @@ -250,7 +236,6 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err) break; if (c == ' ') { if (0 == strncmp("not", src + start, current - start)) { - block_state = BLOCK_ENTRY; end = current; state = TEMPLATE_BLOCK_IF_START; type = BLOGC_TEMPLATE_IF_NOT_STMT; @@ -293,16 +278,9 @@ blogc_template_parse(const char *src, size_t src_len, blogc_error_t **err) if (c == ' ') break; if (c >= 'A' && c <= 'Z') { - if (block_state == BLOCK_ENTRY || block_state == BLOCK_LISTING) { - state = TEMPLATE_VARIABLE; - type = BLOGC_TEMPLATE_VARIABLE_STMT; - start = current; - break; - } - *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, - src, src_len, current, - "Variable statements only allowed inside 'entry' and " - "'listing' blocks."); + state = TEMPLATE_VARIABLE; + type = BLOGC_TEMPLATE_VARIABLE_STMT; + start = current; break; } *err = blogc_error_parser(BLOGC_ERROR_TEMPLATE_PARSER, src, |