3

For our CMIS server side implementation, I am looking to build a parser that will parse query statements provided as input to the query method. CMIS defines a BNF grammar for the query statements. I was wondering what would be the best way to generate this BNF parser?

Our implementation is in C#. CMIS queries are based on SQL syntax plus some predicates defined by CMIS.

5
  • There is some info on parsing in C# here stackoverflow.com/questions/7377344/…
    – Lee Meador
    Jan 22, 2013 at 15:40
  • SQL in general is a pretty complicated langauge. The most straightforward answer is, "get a parser generator with an existing grammar for SQL" so you don't have to replicate that. But, morst parser generators build, well, parsers. However, parsing is generally a means to an end, not a goal itself. A more interesting question is what do intend to do after parsing? That may change the answer a lot.
    – Ira Baxter
    Jan 22, 2013 at 17:44
  • @IraBaxter - The grammar I will have to use is defined by CMIS which is based on SQL plus some predicate defined by CMIS standard. So the queries will be like "SELECT * FROM cmis:document WHERE IN_FOLDER(10230)". Once the parser validates and classifies a query I can then call appropriate code according to predicates within the query.
    – Mandar
    Jan 23, 2013 at 11:44
  • "Call appropriate code"... that doesn't answer the question about what you want to acheive. What do the appropriate code do? Does it execute the entire CMIS SQL query? What I'm trying to find out is how much analysis of the SQL query you have do on top of parsing.
    – Ira Baxter
    Jan 23, 2013 at 14:19
  • @IraBaxter - As I said, CMIS SQL queries are different than plain SQL. So I can't really execute those as is. The table names, column names too would be different than our internal tables. So we need to translate that as well. A query like "SELECT cmis:name FROM cmis:document" would need such translation. For another query like "SELECT * FROM cmis:document WHERE In_TREE(folder_id)", we have to write code to return all documents in the tree of specified folder. Also a query like "SELECT SCORE() FROM cmis:document WHERE CONTAINS('some text')" will need us to use our full-text search capability.
    – Mandar
    Jan 23, 2013 at 15:04

1 Answer 1

2

Apache Chemistry OpenCMIS uses Antlr on the server side to parse, validate and interpret the cmisQL syntax. You can try to reuse Antlr grammar defined in the Apache Chemistry OpenCMIS implementation for generating your own C# parser with antlr3

OpenCMIS grammar files are available here (under the Apache Licence)

1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.