// creates dummy generic parser for expressions with matching braces allowing commas and semicolons by default protected internal virtual Parser <string> GenericExpressionCore(string forbidden = null) => from subExpressions in GenericNewExpression.Select(x => $" {x}") .Or(Parse.CharExcept("'/(){}[]" + forbidden).Except(GenericNewExpression).Many().Text().Token()) .Or(Parse.Char('/').Then(_ => Parse.Not(Parse.Chars('/', '*'))).Once().Return("/")) .Or(CommentParser.AnyComment.Return(string.Empty)) .Or(StringLiteral) .Or(GenericExpressionInBraces('(', ')').Select(x => $"({x})")) .Or(GenericExpressionInBraces('{', '}').Select(x => $"{{{x}}}")) .Or(GenericExpressionInBraces('[', ']').Select(x => $"[{x}]")) .Many() let expr = string.Join(string.Empty, subExpressions) where !string.IsNullOrWhiteSpace(expr) select expr;
// creates dummy generic parser for expressions with matching braces allowing commas and semicolons by default protected internal virtual Parser <string> GenericExpressionCore(string forbidden = null, bool allowCurlyBraces = true) { var subExpressionParser = GenericNewExpression.Select(x => $" {x}") .Or(Parse.CharExcept("'/(){}[]" + forbidden).Except(GenericNewExpression).Many().Text().Token()) .Or(Parse.Char('/').Then(_ => Parse.Not(Parse.Chars('/', '*'))).Once().Return("/")) .Or(CommentParser.AnyComment.Return(string.Empty)) .Or(StringLiteral) .Or(GenericExpressionInBraces('(', ')').Select(x => $"({x})")) .Or(GenericExpressionInBraces('[', ']').Select(x => $"[{x}]")); // optionally include support for curly braces if (allowCurlyBraces) { subExpressionParser = subExpressionParser .Or(GenericExpressionInBraces('{', '}').Select(x => $"{{{x}}}")); } return (from subExpressions in subExpressionParser.Many() let expr = string.Join(string.Empty, subExpressions) where !string.IsNullOrWhiteSpace(expr) select expr); }