title: Parsing nested structures in PHP with preg_match
body: <p>Hello I want to make something like a meta language which gets parsed and cached to be more performant. So I need to be able to parse the meta code into objects or arrays.</p>
  
  <p>Startidentifier: {</p>
  
  <p>Endidentifier: }</p>
  
  <p>You can navigate through objects with a dot(.) but you can also do arithmetic/logic/relational operations.</p>
  
  <p>Here is an example of what the meta language looks like:</p>
  
  <ul>
  <li>{mySelf.mother.job.jobName}</li>
  </ul>
  
  <p>or nested</p>
  
  <ul>
  <li>{mySelf.{myObj.{keys["ObjProps"][0]}.personAttribute.first}.size}</li>
  </ul>
  
  <p>or with operations</p>
  
  <ul>
  <li>{obj.val * (otherObj.intVal + myObj.longVal) == 1200}</li>
  </ul>
  
  <p>or more logical</p>
  
  <ul>
  <li>{obj.condition == !myObj.otherCondition}</li>
  </ul>
  
  <p>I think most of you already understood what i want. At the moment I can do only simple operations(without nesting and with only 2 values) but nesting for getting values with dynamic property names works fine. also the text concatination works fine </p>
  
  <p>e.g. "Hello {myObj.name}! How are you {myObj.type}?".</p>
  
  <p>Also the possibility to make short if like (condition) ? (true-case) : (false-case) would be nice but I have no idea how to parse all that stuff. I am working with loops with some regex at the moment but it would be probably faster and even more maintainable if I had more in regex.</p>
  
  <p>So could anyone give me some hints or want to help me? Maybe visit the project site to understand what I need that for: <a href="http://sourceforge.net/projects/blazeframework/" rel="nofollow noreferrer">http://sourceforge.net/projects/blazeframework/</a></p>
  
  <p>Thanks in advance!</p>