On 7/21/2013 12:28 PM, John Carlson wrote:
Hmm. I've been thinking about creating a macro language written in
JSON that operates on JSON structures. Has someone done similar
work? Should I just create a JavaScript AST in JSON? Or should I
create an AST specifically for JSON manipulation?
my scripting language mostly uses S-Expressions for its AST format.
my C frontend mostly used an XML variant.
I had a few times considered a hybrid, essentially like XML with a more
compact syntax (*1).
in the future, most likely I would just use S-Expressions.
while S-Exps are slightly more effort in some cases to extend, they are
generally faster than manipulating XML, and are easier to work with.
JSON could work, but its syntax is slightly more than what is needed for
something like this, and its data representation isn't necessarily ideal.
EDN looks ok.
*1:
node := '<' tag (key'='value)* node* '>'
<tag key=value <tag2 key2=val2> <tag3>>
where value was a literal value with one of several types, IIRC:
integer type;
floating-point type;
string.
note that there were no free-floating raw values.
a free-floating value would instead be wrapped in a node.
had also considered using square braces:
[array [int val=1234] [real val=3.14] [string val="string"] [symbol
val="symbol"]]
the allowed forms would otherwise have been fairly constrained.
the constrained structure would be mostly for sake of performance and
similar.
note:
the XML variant used by my C frontend also ended up (quietly) adding
support for raw numeric values, mostly because of the added overhead of
converting between strings and numbers.
Thanks,
John
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc