Parse bangs

This commit is contained in:
Wilson Lin 2018-07-20 22:39:28 +12:00
parent 2c7992585a
commit 6080451453
2 changed files with 32 additions and 2 deletions

24
src/main/c/stream/bang.c Normal file
View File

@ -0,0 +1,24 @@
#ifndef _HDR_HYPERBUILD_STREAM_BANG
#define _HDR_HYPERBUILD_STREAM_BANG
#include "../util/hbchar.h"
#include "../util/pipe.c"
void hbs_bang(hbu_pipe_t pipe)
{
hbu_pipe_require_match(pipe, "<!");
while (1)
{
if (hbu_pipe_peek_offset(pipe, 1) == '>')
{
break;
}
hbu_pipe_skip(pipe);
}
hbu_pipe_skip(pipe);
}
#endif // _HDR_HYPERBUILD_STREAM_BANG

View File

@ -8,6 +8,7 @@
void hbs_content(hbu_pipe_t pipe);
#include "./tag.c"
#include "./bang.c"
void hbs_content(hbu_pipe_t pipe) {
while (1) {
@ -21,9 +22,14 @@ void hbs_content(hbu_pipe_t pipe) {
if (hbu_pipe_peek_offset(pipe, 2) == '/') {
// Callee is responsible for requiring close tag (or not, if root)
return;
}
hbs_tag(pipe);
} else if (hbu_pipe_peek_offset(pipe, 2) == '!') {
// Check after comment
hbs_bang(pipe);
} else {
hbs_tag(pipe);
}
break;
case '&':