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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:33:57+00:00 2026-06-13T13:33:57+00:00

My goal is to write a function that will take a logical expression (eg:

  • 0

My goal is to write a function that will take a logical expression (eg: A OR NOT(B AND C)) and convert that into disjunctive normal form. (A OR NOT B OR NOT C)

I have written a grammar that will generate logical expressions

S => !S
S => (S)
S => S op S
S => W
op => AND | OR
W => A | B | C | ... | Z

This is my algorithm

  1. Given an expression S
  2. recursively parse the expression using the grammar above and build the corresponding parse tree
  3. Convert the expression to DNF by recursively “simplifying” any NOT operators on the tree.
  4. Recursively go through final parse tree and output the DNF logical expression.

With a parse tree I can simplify NOT operators by checking the current node’s parent, and pushing it down the tree or re-arranging the tree (in the case of NOT NOT). Then it is trivial to flatten the tree.

This works on paper, but now I’m stuck with the actual parser. How can I convert these rules into a parser class? I don’t want to use external libraries and want to write the parser from scratch.

  • 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-13T13:33:58+00:00Added an answer on June 13, 2026 at 1:33 pm

    Have a look at Treetop, which might do what you want. http://treetop.rubyforge.org/

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

Sidebar

Related Questions

My goal is to write the more concise/effective function to convert a value to
My goal is create a graph that will hide and show a series depending
Is it possible to write a method that takes a stringstream and have it
My goal is to create a time zone converter that will compare two different
My goal is to make a module that will make a grid on a
I'm trying to write a program that will allow me to give it a
I'm trying to write a javascript that will toggle the class of a table
I'm learning how to write a scriptable ActiveX control. My goal is to have
My final goal is to write the program which can run on the Unix
Goal is to make a dialog that appears on menu_key pressed, but it keeps

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.