Commit bbe6769f authored by Kenton Varda's avatar Kenton Varda

Allow 'group' and 'union' to have preceding colon, and fix a bug.

parent 7c6c617d
......@@ -364,7 +364,7 @@ public:
} else {
uint newSize = kj::max(lgSizeUsed, lgSize) + 1;
if (tryExpandUsage(group, location, newSize)) {
uint result = holes.assertHoleAndAllocate(lgSize);
uint result = KJ_ASSERT_NONNULL(holes.tryAllocate(lgSize));
uint locationOffset = location.offset << (location.lgSize - lgSize);
return locationOffset + result;
} else {
......
......@@ -693,15 +693,17 @@ CapnpParser::CapnpParser(Orphanage orphanageParam, const ErrorReporter& errorRep
// name and ordinal.
p::oneOf(
p::sequence(
p::optional(identifier), p::optional(parsers.ordinal), keyword("union"),
p::many(parsers.annotation)),
p::optional(identifier), p::optional(parsers.ordinal),
p::optional(op(":")), keyword("union"), p::many(parsers.annotation)),
p::sequence(
keyword("union"),
p::optional([](ParserInput&) -> kj::Maybe<Located<Text::Reader>> { return nullptr; }),
p::optional([](ParserInput&) -> kj::Maybe<Orphan<LocatedInteger>> {return nullptr; }),
p::optional([](ParserInput&) -> kj::Maybe<Orphan<LocatedInteger>>{ return nullptr; }),
p::optional([](ParserInput&) -> kj::Maybe<kj::Tuple<>> { return nullptr; }),
p::many(parsers.annotation))),
[this](kj::Maybe<Located<Text::Reader>>&& name,
kj::Maybe<Orphan<LocatedInteger>>&& ordinal,
kj::Maybe<kj::Tuple<>>&&,
kj::Array<Orphan<Declaration::AnnotationApplication>>&& annotations)
-> DeclParserResult {
auto decl = orphanage.newOrphan<Declaration>();
......@@ -723,8 +725,9 @@ CapnpParser::CapnpParser(Orphanage orphanageParam, const ErrorReporter& errorRep
}));
parsers.groupDecl = arena.copy(p::transform(
p::sequence(identifier, keyword("group"), p::many(parsers.annotation)),
p::sequence(identifier, p::optional(op(":")), keyword("group"), p::many(parsers.annotation)),
[this](Located<Text::Reader>&& name,
kj::Maybe<kj::Tuple<>>&&,
kj::Array<Orphan<Declaration::AnnotationApplication>>&& annotations)
-> DeclParserResult {
auto decl = orphanage.newOrphan<Declaration>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment