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

  • Home
  • SEARCH
  • 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 7935955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:04:16+00:00 2026-06-03T22:04:16+00:00

Recently, I had to implement an Abstract Query Tree for a research project. The

  • 0

Recently, I had to implement an Abstract Query Tree for a research project. The base object is an ASTNode, but the actual tree nodes were derived classes: expression nodes, comparison nodes, operand nodes, etc. Each type of node has its own members, such as operand node(s), lists of arguments, and so forth.

The parsing functions that recursively generate this tree need to return ASTNode types, since they just return a pointer regardless of what type of node sits at the root of the generated tree.

This means that the functions that parse the tree need to query, for each node in the tree, what type it is, before operating on it. This can be done with dynamic casts or typeid, but SO and the Google style guidelines would get angry over my violation of the Liskov substitution principle and all the run-type type checks in general.

I can’t put the functions that operate on the nodes in the node sub-classes themselves, since the trees can be used in several different ways in different parts of the application. Is there a better way to structure my trees?

  • 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-03T22:04:18+00:00Added an answer on June 3, 2026 at 10:04 pm

    This looks like a good fit for the visitor pattern.

    How to write the Visitor Pattern for Abstract Syntax Tree in Python?

    http://en.wikipedia.org/wiki/Visitor_pattern

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

Sidebar

Related Questions

Recently, I've had a request to implement logging for all of the Controller classes
I recently had to implement a small check for any variables that might have
I had never tried Continuum as a build server until recently when a project
Recently, I had to implement a stream library, libstream , for one of my
Recently I implemented an interface which had some 130 members that i should implement
Recently in an interview I was asked to write a query where I had
I've recently had to implement XML messaging with two large entities that required us
Current project is an Mvc4 application, I had Ioc working and recently it just
I recently had a discussion with a colleague about serialization of byte data over
I recently had an idea to create my own String class to make using

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.