I have these parsers as part of my grammar:
public static readonly Parser<string> SpaceOrTab =
Parse.Char(' ').Or(Parse.Char('\t')).Many().Text().Named("SpaceOrTab");
public static readonly Parser<string> NewLine = Parse.LineEnd;
public static readonly Parser<string> NewLineToken = Parse.LineEnd.Contained(SpaceOrTab, SpaceOrTab);
public static readonly Parser<string> NewLineSeparator = NewLineToken.AtLeastOnce().Select(x => string.Join("", x));
public static readonly Parser<string> CommaSeparator = Parse.String(",").Token().Text();
public static readonly Parser<string> Separator = NewLineSeparator.Or(CommaSeparator).Named("Separator");
I want to have a separator parser that is either "at least one LineEnd" or a comma.
so that I can parse things like:
1, 2 , 3 , 4
or
1
2
3
4
I have tried a lot of different options to define the NewLineSeparator but I'm obviously doing something wrong. delimiting by comma works fine, the newlineseparator parser seems to not get any matches.
Complete source is available here in case someone want to take a peek: https://github.com/rogeralsing/SpracheHocon/blob/master/SpracheHocon/Program.cs