Sprache を使用して、次のようなファイルのセクションを解析しています。
OneThing=Foo
AnotherThing=Bar
YetAnotherThing=Baz
3 つの行はすべて必須ですが、任意の順序で表示できます。次のような個々の行のパーサーがあります。
public static readonly Parser<string> OneThing = (
from open in Parse.String("OneThing=")
from rest in Parse.AnyChar.Except(Parse.LineTerminator).Many().Text()
from newLine in Parse.LineEnd
select rest
);
そして、次のように、それらを組み合わせてセクション全体を解析します。
public static readonly Parser<MyClass> Section = (
from oneThing in SectionGrammar.OneThing
from anaotherThing in SectionGrammar.AnotherThing
from yetAnotherThing in SectionGrammar.YetAnotherThing
select new MyClass(oneThing, anotherThing, yetAnotherThing)
);
ただし、これは行が OneThing、AnotherThing、YetAnotherThing の順序で表示される場合にのみ機能します。これを変更して、行を任意の順序で表示できるようにするにはどうすればよいですか?
どんな助けでも大歓迎です!ありがとう