Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parse logical expression string in qt

Parse logical expression string in qt

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tushar jambhekar
    wrote on last edited by
    #1

    In my application, my application needs to take some action based on result of expression string provided by the application user

    the expression may include

    1. some variables already used in my application
    2. Boolean and numeric constants
    3. logical and arithmetic(+-*/) operators

    e.g. expression string might be !((var1&var2)|Var3)
    in which var1, var2 and var3 are the variables already declared in my application

    if any standard scripting language is supported then i can use it and syntax of expression can be changed as per requirements.

    I need some guidance or tutorial which can help me to get started

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      ECMAScript is supported by Qt (JavaScript).
      Have a look at http://qt-project.org/doc/qt-4.8/scripting.html

      However this of course might be much too powerful than necessary (or even desirable) in your situation. A parser for such simple expressions can be written from scratch quite quickly. Recurse bracket-wise and decompose into operand-operator-operand blocks, which finally create a tree structure. Then just execute the logic of the tree, the value of the root is the result.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved