7

Sprache モナディック パーサーを使用して DSL を解析しています。

これは私の文法のスニペットです:

public static readonly Parser<IExpression> TerminatedStatement =
    from exp in Parse.Ref(() => Expression)
    from _ in Parse.Char(';').Token()
    select exp;

public static readonly Parser<IExpression> Statement =
    Parse.Ref(() => TerminatedStatement)
    .Or(Parse.Ref(() => InvocationStatement));

public static readonly Parser<Statements> Statements =
    from statements in Statement.Many()
    select new Statements(statements);

それを使用するとStatements.Parse(" ")、予期しない入力の終わりがあったという例外が発生します。

AFAIKが0-nの結果をもたらす演算子をStatements使用する場合、どうすればよいでしょうか。Many

" "Statements0 ステートメントを含むインスタンスを返す必要があります。

では、パーサーは、予期しない入力の終わりがあることをどのように訴えることができるのでしょうか? そこには声明がないと結論付けるべきではありませんか?(ステートメントを構成するさまざまな表現がどんなファンキーなものであっても)

4

0 に答える 0