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 7923039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:10:23+00:00 2026-06-03T17:10:23+00:00

I have a parse tree that parses out a stack of a stack of

  • 0

I have a parse tree that parses out a stack of a stack of char (stack<stack<char>>). This gets the characters into a parse tree. My question is how would I convert this parse tree into a AST in order to evaluate it?

I have the evaluator working for a AST I just need to convert the tree into the syntax in order to evaluate it.

Any help would be appreciated.

Here is a picture of what I am trying to accomplish

  • 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-06-03T17:10:24+00:00Added an answer on June 3, 2026 at 5:10 pm

    I was able to convert them using a Tree Traversal Algorithm

    Using Pre Order Traversal

    preorder(node)
      if node == null then return
      print node.value
      preorder(node.left) 
      preorder(node.right)
    

    Using a stack to store the leaf nodes I added the values onto them and was able to transverse the stack and change into lea nodes.

    A example for 10 + 4

    the parse tree leafs using preorder would give me a stack of [+ 10 4]

    Using a helper function I could convert this into a

    Make_Plus(Make_Int(10), Make_Int(4)) by using recursion

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

Sidebar

Related Questions

I have a tree of data that I would like to present to the
I have a parse tree for my compiler, and i was wondering what traversal
I have my parse tree with me, now I have traversed in order on
After creating the parse tree, i have to populate symbol table now. I have
Ok I have to parse out a SOAP request and in the request some
I'm using Irony.net for generating a parse tree out of the source. Essentially I'm
I have an xml file that looks like this: <!DOCTYPE ROOT SYSTEM zombie.dtd> <ROOT>
A simple question I'm sure, but I can't figure it out. I have some
Does there exist a parser that generates an AST/parse tree at runtime? Kind of
I have a lexer built that streams out tokens from in input but I'm

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.