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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:34:12+00:00 2026-05-28T02:34:12+00:00

I am working on a PHP project that deals with storing a set of

  • 0

I am working on a PHP project that deals with storing a set of information in form of key value pair and retrieving them using a query. In this project the query to retrieve the information is of following type.

(color: 'red' & size: 'small') | (color: 'yellow' & weight: 'heavy')

This query indicates to select the pieces of information from my storage that describes color as red and also the size as small or color as yellow and also wheight as heavy. Once I parse this query and extract units out of it, I will form a mysql query and get the required information from the database.

I would like to know how do I parse the above string and get the units (I am not sure if it is called lexical units). Kindly let me know if there is a library available where we can have custom parsers.

  • 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-05-28T02:34:12+00:00Added an answer on May 28, 2026 at 2:34 am

    There’s no libraries available for PHP that are actively maintained and fixed. You could use YACC and it’s BNF-style grammar definition to get a C parser for your custom language. There is one in PEAR (PHP_ParserGenerator) but beware that it’s no longer maintained.

    You can check it out here.

    The BNF for your parser is:

    <rule>::=<rule>"|"<rule> |
             <rule>"&"<rule> |
             "("<rule>")"    |
             <attribute>":"<value>
    <attribute>::=[a-z0-9]
    <value>::="'"[a-z0-9]"'"
    

    But the parsing seems easy enough, once you encounter a ( token you look for it’s corresponding closing ) token and you parse that section recursively.

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

Sidebar

Related Questions

I am working on a php project that needs to store information about various
I am working on a project that pulls data from JMS queue using PHP
I'm working on a project for my company that uses a socket server (php)
So I have this PHP website that I am working on that using templates.
So I'm working on a PHP project that needs to allow the user to
Here's my situation: I'm working on a PHP project that uses a few functions
I am working on a PHP project, so I am not using Visual Studio,
I'm working on a PHP project and using Netbeans 7.0.1 and the last PHPUnit.
I'm working on a PHP project with solid unit-tests coverage. I've noticed, that last
Stupid question. I've got a project that I'm working on in PHP; it's a

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.