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

Can you please help me understand the tree structure generated ? #14

Closed
ahumblenerd opened this issue Nov 16, 2014 · 1 comment
Closed

Comments

@ahumblenerd
Copy link

Hi ,

First of all thank you for that an awesome tutorial and the library. I have reached the polish evaluation portion and i did the evaluation with the grammar
expr : |'(' +')’;

Now i want to change the grammar to this.
expr : | +;

But I am getting confused or I am unable to visualise how the AST will look like. I am unable to understand the tree structure generated.

  • (+ 2 3)(+ 2 3) <- For the first grammar
    -> lispy|>
    regex
    operator|char:1:1 '*'
    expr|>
    char:1:3 '('
    operator|char:1:5 '+'
    expr|number|regex:1:7 '2'
    expr|number|regex:1:9 '3'
    char:1:10 ')'
    expr|>
    char:1:12 '('
    operator|char:1:13 '+'
    expr|number|regex:1:15 '2'
    expr|number|regex:1:17 '3'
    char:1:18 ')'
    regex

    • 2 3 + 2 3 <- for the second grammar.

    lispy|>
    regex
    operator|char:1:1 '*'
    expr|>
    operator|char:1:3 '+'
    expr|number|regex:1:5 '2'
    expr|number|regex:1:7 '3'
    expr|>
    operator|char:1:9 '+'
    expr|number|regex:1:11 '2'
    expr|number|regex:1:13 '3'
    regex

Hoping that you will help me .

@orangeduck
Copy link
Owner

Hey I've answered in e-mail.

  • Dan

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