Titanium JIRA Archive
Alloy (ALOY)

[ALOY-272] Grammar for TSS files

GitHub Issuen/a
Resolution Date2013-01-08T16:29:22.000+0000
Affected Version/s2012 Sprint 20
Fix Version/sAlloy 0.3.5, 2013 Sprint 02
LabelsGA-candidate, notable
ReporterTony Lukasavage



Our current parsers rely on the style being able to be parsed by the uglifyjs AST parser. Removing the commas breaks this first initial step before we pass it to the JSON parser. It shows us a larger problem in that we should probably have a complete parsing expression grammar for TSS files. This will allow us to account for more than just commas, but also comments and things like that. We should attempt to use [pegjs](http://pegjs.majda.cz/) to create the grammar as it can then be run through Alloy's node scripts. After that it can be incorporated into Alloy, replacing the current method of using the uglifyjs AST parsing, followed by JSON.parse.


* We may need to drop expr() syntax to keep the grammar from needing to understand all of Javascript as well, which is not a small grammar as you might imagine. I think dropping expr() is fine as it was a catch-all before we had device queries and will be made further obsolete with the introduction of dynamic styles in ALOY-210. * Grammar will allow us to add comments, which we can't do with the current method. * This will make our styles more flexibile in the future if we need further changes


  1. Tony Lukasavage 2012-09-15

    Initial grammar here: https://github.com/appcelerator/alloy/blob/master/Alloy/grammar/tss.pegjs
  2. Tony Lukasavage 2013-01-08

    Grammar-based parser now being used for TSS parsing. All unit tests are passing. Additionally the Codestrong app also parses all of its styles correctly.

JSON Source