Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Equals Sign does not lex #536

Closed
padfoot9445 opened this issue Feb 17, 2025 · 5 comments
Closed

Single Equals Sign does not lex #536

padfoot9445 opened this issue Feb 17, 2025 · 5 comments

Comments

@padfoot9445
Copy link

 public override IEnumerable<IToken> Scan()
    {
        ILexer<SmallTT> lexer = LexerBuilder.BuildLexer<SmallTT>().Result;
        var tokenss = lexer.Tokenize(input);
        var tokensd = tokenss.Tokens;
        var x = tokensd.GetEnumerator();
        var tokens = tokensd.ToList();
        return [];
    }
using sly.lexer;

namespace SmallLang;
enum SmallTT
{
    EOF,
    [Sugar("=")]
    Equals,
    [Sugar("-")]
    Plus
}

setting input = "=" results in a lexer error. input = "-" works fine.

@padfoot9445
Copy link
Author

Debugging further, it seems that for some reason it does not recognize the [Sugar("=")] attribute as I am getting the error message
"token Equals in lexer definition SmallLang.SmallTT does not have Lexeme" during lexer instantiation. This is not an issue of it being the first lexemed enum, or being under EOF, as a non-trivial token-type example places equals in a spot which has neither of these properties. It is also not an issue of the enum type not being public as, as mentioned, a non-trivial token-type example exists and that is public.

@b3b00
Copy link
Owner

b3b00 commented Feb 18, 2025

Hello @padfoot9445 , thanks for reporting. this is definitly an issue. Lexer instanciation should succeed. I am looking at it right now.

@b3b00
Copy link
Owner

b3b00 commented Feb 18, 2025

Hello @padfoot9445 , i've got it : Equals is a method that is available on any enum. So it can't be used. Renaming it to says Eq makes it work.
I will nevertheless investigate to see if we can allow those special cases.

b3b00 added a commit that referenced this issue Feb 18, 2025
@b3b00 b3b00 closed this as completed in a5f169d Feb 18, 2025
@b3b00
Copy link
Owner

b3b00 commented Feb 18, 2025

@padfoot9445 , I've found a way to fix it. You can now try the 3.5.3 nuget and keep the Equals name which I admit is better than Eq.
Thanks again for reporting and helping

@b3b00
Copy link
Owner

b3b00 commented Feb 18, 2025

fix with PR #537 and release 3.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants