Search code examples
programming-languagesantlrbison

creating simple programming language that returns matched rows from database or files


Since I've never encountered this kind of problem I thought about making language parser that will implement this. Of course, I'm open to suggestions or totally different approach to this problem. I need general guidelines or advices how to make this happen.

TABLERULE col1 TYPE (STRING) == "string" 
(AND|OR|NOT) col2 TYPE (INT) >= 12 ...

STRINGRULE "stringregex" (AND|OR|NOT) "string2regex" ...

so this little language should have

  1. syntax for recognizing rules that are applied to database tables

  2. syntax for recognizing rules that are applied to bunch of strings (text files)

  3. chaining of rules

  4. TABLERULE should have type of col (string,integer) so it knows which kind of comparisons it can use, ==,!= for strings, >,<,== for integers

  5. programming language output should be array of matched database rows or string lines

Language parser or similar method needs to be compatible with java,C,python


Solution

  • Can't SQL do this? Every table has a schema saved in the database too, so you could look up the info about specific columns in the schema table and based on that information, select actual rows of results.