创建简单的编程语言,从数据库或文件返回匹配的行
由于我从未遇到过此类问题,因此我考虑制作语言解析器来实现此问题。当然,我愿意接受建议或完全不同的方法来解决这个问题。我需要一般指导方针或建议如何实现这一目标。
TABLERULE col1 TYPE (STRING) == "string"
(AND|OR|NOT) col2 TYPE (INT) >= 12 ...
STRINGRULE "stringregex" (AND|OR|NOT) "string2regex" ...
所以这个小语言应该有
用于识别应用于数据库表的规则的语法
用于识别应用于一堆字符串(文本文件)的规则的语法)
规则链接
TABLERULE 应该具有 col 类型(字符串,整数),以便它知道它可以使用哪种类型的比较,==,!= 对于字符串,>,<,== 对于整数
编程语言输出应该是匹配的数据库行或字符串行的数组
语言解析器或类似方法需要兼容java、C、python
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
syntax for recognizing rules that are applied to database tables
syntax for recognizing rules that are applied to bunch of strings (text files)
chaining of rules
TABLERULE should have type of col (string,integer) so it knows which kind of comparisons it can use, ==,!= for strings, >,<,== for integers
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQL 不能做到这一点吗?每个表也在数据库中保存了一个模式,因此您可以查找有关模式表中特定列的信息,并根据该信息选择实际的结果行。
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.