aboutsummaryrefslogtreecommitdiff
path: root/src/stem.c
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-10 16:36:53 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-10 16:36:53 -0800
commit4ada155b930cb5fb96493dff3a5af8809da3b214 (patch)
treedb723cecb55c51e08b4ae6f865046d892d720304 /src/stem.c
parentf4252fb4c1b12e4318f98e4a1936842e8b691ce0 (diff)
add comments in both stem and also in my c code
Diffstat (limited to 'src/stem.c')
-rw-r--r--src/stem.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/stem.c b/src/stem.c
index d2204f9..b9e0a16 100644
--- a/src/stem.c
+++ b/src/stem.c
@@ -161,6 +161,25 @@ void parser_reset(parser_t *p, char *source) {
p->c = source[0];
}
+parser_t *parser_pp(char *s) {
+ parser_t *p = init_parser(s);
+ string_t *rstr = init_string(NULL);
+ while (p->c != '\0') {
+ if (p->c == '#') {
+ while (p->c != '\n' && p->c != '\0') {
+ parser_move(p);
+ }
+ } else {
+ string_append(rstr, p->c);
+ parser_move(p);
+ }
+ }
+ free(p->source);
+ parser_reset(p, rstr->value);
+ free(rstr);
+ return p;
+}
+
void parser_move(parser_t *p) {
if (p->i < strlen(p->source) && p->c != '\0') {
p->i++;