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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:00:29+00:00 2026-06-07T14:00:29+00:00

How do I go about evaluating logical expression like VERB1 OR (VERB2 AND VERB3)

  • 0

How do I go about evaluating logical expression like “VERB1 OR (VERB2 AND VERB3) OR (VERB4)” entered at runtime. VERB* are placeholder to evaluate certain conditions. For example, VERB1 might mean check for the existence of a record in database.

In expression “VERB1 OR (VERB2 AND VERB3) OR (VERB4)”, other verbs should not be executed if VERB1 is true

EDIT: Example described at http://www.alittlemadness.com/2006/06/05/antlr-by-example-part-1-the-language/ seems very similar to what I am trying to do. However, the optimization step (other verbs should not be executed if VERB1 is true) doesn’t seem to be there.

  • 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-07T14:00:31+00:00Added an answer on June 7, 2026 at 2:00 pm

    If you can use || and && in place of AND and OR, you can just use groovy’s missing property methods and the GroovyShell base class setting like so:

    import org.codehaus.groovy.control.CompilerConfiguration
    
    // The command to be executes
    def command = "VERB1 || (VERB2 && VERB3) || (VERB4)"
    
    // Set a base class for the GroovyShell
    new CompilerConfiguration().with { compiler ->
      compiler.scriptBaseClass = 'VerbHandlingBaseClass'
      new GroovyShell( this.class.classLoader, new Binding(), compiler ).with { shell ->
        // and evaluate the command
        shell.evaluate( command )
      }
    }
    
    abstract class VerbHandlingBaseClass extends Script {
      boolean VERB1() {
        System.out.println( 'CHECK THE DATABASE, RETURN FALSE' )
        false
      }
    
      boolean VERB2() {
        System.out.println( 'WRITE A LOG ENTRY RETURN TRUE' )
        true
      }
    
      boolean VERB3() {
        System.out.println( 'VALIDATE SOMETHING, RETURN TRUE' )
        true
      }
    
      boolean VERB4() {
        System.out.println( 'THIS WONT BE REACHED, AS VERB2 && VERB3 == true' )
        true
      }
    
      def propertyMissing( String name ) {
        "$name"()
      }
    }
    

    That should print:

    CHECK THE DATABASE, RETURN FALSE
    WRITE A LOG ENTRY RETURN TRUE
    VALIDATE SOMETHING, RETURN TRUE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently evaluating Dreamweaver CS 5.5. I like much of it - but wondering about
I am curious about the runtime performance of an infinite list like the one
Possible Duplicate: Is Chrome's JavaScript console lazy about evaluating arrays? I have the following
Have spend quite some time to learn Sencha touch, just like an evaluation about
I've seen this pretty funny screencast yesterday about some oddities in languages like Ruby
Possible Duplicate: Is Chrome's JavaScript console lazy about evaluating arrays? I write next js
I'm evaluating http://github.com/janl/mustache.js and I'm thinking about how it will work in general over
I am evaluating a subversion repository. There are about 250 users. I wanted to
I'm evaluating whether or not certain variables match expected values. The variables are set
I'm about to start developing a product (in .NET), and I'm evaluating open source

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.