LanguageDev / Yoakke

A collection of libraries for implementing compilers in .NET.
https://languagedev.github.io/Yoakke/
Apache License 2.0
143 stars 7 forks source link

There no way to use End inside rules #151

Open kant2002 opened 1 year ago

kant2002 commented 1 year ago

Describe the bug I try to declare language which is somewhat whitespace sensetive. For now I need only empty line as separator, definitions below.

public enum EngLangTokenType
{
    [Error] Error,
    [End] End,
    [Ignore] [Regex("([ \t]+((\r\n|\n|\r)[ \t]*)?|(\r\n|\n|\r))")] Whitespace,
    [Regex("(\r\n|\n|\r){2,}")] Multiline,
}

And now I'm in situation where that Multiline separator can be missing in the end of file, which lead to fact that some statements may go missing.I did try to do following

[Rule("paragraph : statement_list Multiline+")]
private static BlockStatement MakeParagraph(
    BlockStatement statement,
    IReadOnlyList<IToken<EngLangTokenType>> paragraphToken)
    => statement;

[Rule("paragraph : statement_list End")]
private static BlockStatement MakeParagraph(
    BlockStatement statement,
    IToken<EngLangTokenType> paragraphToken)
    => statement;

but if I add this rule, I have infinite bug. So I would like to hear what I can do about that.