Parsing error for "label:@tag{children}".

This commit is contained in:
Miguel Lechon
2021-03-11 21:08:38 +01:00
parent 72b7e3b366
commit 34c48c84ff
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
label:@tag {1, 2, 3}
a /* unterminated comment
+13
View File
@@ -1678,6 +1678,19 @@ _MD_ParseOneNode(MD_ParseCtx *ctx)
_MD_ParseSetFlag_Implicit,
&result.node->first_child,
&result.node->last_child);
// NOTE(mal): Generate error for tags in positions such us "label:@tag {children}"
// in posi
MD_Node *fc = result.node->first_child;
if(fc == result.node->last_child && !MD_NodeIsNil(fc->first_tag) && // NOTE(mal): One child. Tagged.
fc->kind == MD_NodeKind_Label && fc->whole_string.size == 0) // NOTE(mal): Unlabeled set
{
MD_Node *tag = fc->first_tag;
// NOTE(mal): @rjf: I'm assuming that tag->string falls inside the ctx->file_contents string
// Can I do that? It's the easiest way to get the error offset.
MD_u8 *tag_at = tag->string.str;
_MD_Error(ctx, tag, tag_at, 0, "Invalid position for tag \"%.*s\"", MD_StringExpand(tag->string));
}
}
goto end_parse;
}