public override CharFA ToFA(EbnfDocument parent, Cfg cfg) { string sym = ""; if (null != parent) { sym = parent.GetContainingIdForExpression(this); } if (null == Right) { if (null == Left) { return(null); } var fa = Left.ToFA(parent, cfg); fa.FirstAcceptingState.AcceptingSymbol = sym; return(fa); } else if (null == Left) { var fa = Right.ToFA(parent, cfg); fa.FirstAcceptingState.AcceptingSymbol = sym; return(fa); } return(CharFA.Concat(new CharFA[] { Left.ToFA(parent, cfg), Right.ToFA(parent, cfg) }, sym)); }
public override CharFA ToFA(EbnfDocument parent, Cfg cfg) { string sym = ""; if (null != parent) { sym = parent.GetContainingIdForExpression(this); } if (null == Right) { if (null == Left) { return(null); } return(CharFA.Optional(Left.ToFA(parent, cfg), sym)); } else if (null == Left) { return(CharFA.Optional(Right.ToFA(parent, cfg), sym)); } return(CharFA.Or(new CharFA[] { Left.ToFA(parent, cfg), Right.ToFA(parent, cfg) }, sym)); }
public override CharFA ToFA(EbnfDocument parent, Cfg cfg) { if (null == Expression) { return(null); } return(CharFA.Optional(Expression.ToFA(parent, cfg), (null == parent) ? "" : parent.GetContainingIdForExpression(this))); }
public override CharFA ToFA(EbnfDocument parent, Cfg cfg) { if (null == Expression) { return(null); } var result = CharFA.Repeat(Expression.ToFA(parent, cfg), (null == parent) ? "" : parent.GetContainingIdForExpression(this)); if (IsOptional) { result = CharFA.Optional(result); } return(result); }