For following EBNF:
box = (apple | orange)?
I generate three classes in Language Designer:
class Box : AstNodeBase
{
public IList<AbstractFBlock> Apples { ... }
public IList<AbstractFBlock> Oranges { ... }
}
class Apple : AstNodeBase
{
}
class Orange : AstNodeBase
{
}
How to define production for Box?I'm not sure that is a correct way...
box = (apple | orange)?
I generate three classes in Language Designer:
class Box : AstNodeBase
{
public IList<AbstractFBlock> Apples { ... }
public IList<AbstractFBlock> Oranges { ... }
}
class Apple : AstNodeBase
{
}
class Orange : AstNodeBase
{
}
How to define production for Box?
boxDefinition.Production =
(appleDefenition["apple"] > Ast<Apple>()).OnErrorContinue().SetLabel("apples")
|(orangeDefenition["orange"] > Ast<Orange>()).OnErrorContinue().SetLabel("oranges"))
> Ast<Box>()
.AddToCollectionProperty(s => s.Apples, AstChildrenFrom("apples"))
.AddToCollectionProperty(s => s.Oranges, AstChildrenFrom("apples"));