6

I need to write something in C# that allows users to query data in a human-readable format. So in a textarea, they would type in this:

Students.Class, name, address, classid, grade

Which would result in:

Marcus, 11B Westbury Ave. 200718, A+

What the above should do is: Look in the students DB, joining on the class table, then retrieving the name, address, classid, grade.

I have tried writing my own parsing method, splitting the string into an array and then based on the data in the array, querying the database. However, the issue that I am now having is that some users are making mistakes with the syntax:

Students, name, address, classid, grade

(Missing out the .class bit). So I have to throw try/catch methods and present the User with error messages.

The simple method above works, but I am wondering if there are any libraries out there that will take my string data and do what I am after?

2
  • You basically want to convert a custom query language into SQL. Why would you think someone already implemented a converter for your custom language as a library? If your simple method works, then what's the problem? Commented May 7, 2017 at 10:54
  • friend dot forget prove the answer ;) thank you Commented May 8, 2017 at 16:34

1 Answer 1

1

you want create parse at this way you need to learn flex and bison but there is a links can help you to create that.

https://www.codeproject.com/Articles/220042/Easily-Create-Your-Own-Parser https://www.codeproject.com/Articles/664785/A-New-Parser-Generator-for-Csharp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.