Check for newline between statements in blocks
This commit is contained in:
parent
f4dee58f03
commit
4d3ea3f73e
2
ast.c
2
ast.c
@ -97,7 +97,7 @@ CORD ast_to_xml(ast_t *ast)
|
|||||||
T(Unknown, "<Unknown>")
|
T(Unknown, "<Unknown>")
|
||||||
T(Nil, "<Nil>%r</Nil>", type_ast_to_xml(data.type))
|
T(Nil, "<Nil>%r</Nil>", type_ast_to_xml(data.type))
|
||||||
T(Bool, "<Bool value=\"%s\" />", data.b ? "yes" : "no")
|
T(Bool, "<Bool value=\"%s\" />", data.b ? "yes" : "no")
|
||||||
T(Var, "%s", data.name)
|
T(Var, "<Var>%s</Var>", data.name)
|
||||||
T(Int, "<Int bits=\"%ld\">%ld</Int>", data.bits, data.i)
|
T(Int, "<Int bits=\"%ld\">%ld</Int>", data.bits, data.i)
|
||||||
T(Num, "<Num bits=\"%ld\">%g</Num>", data.bits, data.n)
|
T(Num, "<Num bits=\"%ld\">%g</Num>", data.bits, data.n)
|
||||||
T(TextLiteral, "%r", xml_escape(data.cord))
|
T(TextLiteral, "%r", xml_escape(data.cord))
|
||||||
|
11
parse.c
11
parse.c
@ -1619,7 +1619,16 @@ PARSER(parse_block) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
statements = new(ast_list_t, .ast=stmt, .next=statements);
|
statements = new(ast_list_t, .ast=stmt, .next=statements);
|
||||||
whitespace(&pos); // TODO: check for newline
|
whitespace(&pos);
|
||||||
|
|
||||||
|
// Guard against having two valid statements on the same line, separated by spaces (but no newlines):
|
||||||
|
if (!memchr(stmt->end, '\n', (size_t)(pos - stmt->end))) {
|
||||||
|
if (*pos)
|
||||||
|
parser_err(ctx, pos, strchrnul(pos, '\n'), "I don't know how to parse the rest of this line");
|
||||||
|
pos = stmt->end;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_indent(ctx, pos) != block_indent) {
|
if (get_indent(ctx, pos) != block_indent) {
|
||||||
pos = stmt->end; // backtrack
|
pos = stmt->end; // backtrack
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user