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

How do you branch on complex names such as caseSensitiveLiteral!("let") (they get much more complicated) #329

Open
enjoysmath opened this issue Mar 18, 2023 · 1 comment

Comments

@enjoysmath
Copy link

So with the usual swith-case to handle the parse tree (do something with it), I'm having trouble seeing how to branch based on these long names. One solution I had was a pre-switch if-then statement that checked if "SomeText" is a substring of the name. I'm not liking this solution!

@veelo
Copy link
Collaborator

veelo commented Mar 21, 2023

You define a rule in your grammar for the keywords:

Basic:
  LET <- "let"
switch (p.name)
{
    case "Basic:LET":
        // ...
        break;
}

If you don't use grammar composition, I suppose you can do

switch (p.name[6..$])
{
    case "LET":
        // ...
        break;
}

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