Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:50:42+00:00 2026-05-22T20:50:42+00:00

I am unclear on the structure of abstract syntax trees. To go down (forward)

  • 0

I am unclear on the structure of abstract syntax trees. To go “down (forward)” in the source of the program that the AST represents, do you go right on the very top node, or do you go down? For instance, would the example program

a = 1
b = 2
c = 3
d = 4
e = 5

Result in an AST that looks like this:
enter image description here

or this:
enter image description here

Where in the first one, going “right” on the main node will advance you through the program, but in the second one simply following the next pointer on each node will do the same.

It seems like the second one would be more correct since you don’t need something like a special node type with a potentially extremely long array of pointers for the very first node. Although, I can see the second one becoming more complicated than the first when you get into for loops and if branches and more complicated things.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:50:43+00:00Added an answer on May 22, 2026 at 8:50 pm

    The first representation is the more typical one, though the second is compatible with the construction of a tree as a recursive data structure, as may be used when the implementation platform is functional rather than imperative.

    Consider:

    enter image description here

    This is your first example, except shortened and with the “main” node (a conceptual straw man) more appropriately named “block,” to reflect the common construct of a “block” containing a sequence of statements in an imperative programming language. Different kinds of nodes have different kinds of children, and sometimes those children include collections of subsidiary nodes whose order is important, as is the case with “block.” The same might arise from, say, an array initialization:

    int[] arr = {1, 2}
    

    Consider how this might be represented in a syntax tree:

    enter image description here

    Here, the array-literal-type node also has multiple children of the same type whose order is important.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have always been a bit unclear on the type of tasks that should
I want to have multiple path folder structure that contain same name views: /profile.aspx
here is queue implementation which gives me very unclear error #include<iostream> #include bool.h #include
I've seen this data structure talked about a lot, but I am unclear as
I am still unclear about which adapter to use in a situation that doesn't
It's unclear to me whether anyone has/is successfully connected to MSSQL from Haskell and
Some things are unclear to me: var myDiv = document.getElementById(myDiv); var computedStyle = window.getComputedStyle(myDiv);
Apologies for the somewhat unclear question - couldn't think of a better way of
I'm a little unclear on the difference between reflow + repaint (if there's any
Sorry for the unclear title, an example will clear things up: TABLE: Scenario_victories ID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.