2

We defined our own DSL for describing UIs which is JSON based.

{
    "widget": 
    {                            
        "type": "label",  
        "left": "30px",
        ...
    }
}

We do not support any parent child relationships, therefor the max depth of this tree is 1.

My task is that I have to check whether all mandatory properties have been set, that there are no duplicate properties etc. and transform this document into valid qml.

Our first idea was to use Bison and flex but we ran into the problems that we have to determine the type and then check conditionally based on the type which properties need to be set. Since Bison is an LF(1) parser I highly doubt that this is possible without some hacking, correct?

Can somebody provide me with some keywords or ideas how to tackle this task? The solution should be based on C++.

  • How JSON-like is your DSL? If it's always valid JSON, why not just use a regular JSON parser? – sepp2k Mar 15 '19 at 09:36
  • The DSL is 100% JSON. The idea behind using bison was that we could introduce our own structure, enforce it and hopefully easily extend it. Something like XSLT. – Ryan_Flames Mar 15 '19 at 09:44
  • I don't think bison will give you what you want then. Except possibly being able to leave out some features like arrays, the bison part of your grammar will almost certainly look the same as for a generic JSON parser and only the code in your actions and/or later phases will make use of your specific structure. So it probably won't save you any work over just using a JSON parser. – sepp2k Mar 15 '19 at 10:08

0 Answers0