[antlr-interest] CommonTree between target languages

Des Hartman des at deshartman.com
Fri Mar 20 13:12:29 PDT 2009


Jim,

thanks for the response. I think I might go with the toTreeString idea. That
will provide enough information to parse on the server.

In answer to the last question...I only process a subset of the data in
Actionscript and look for parsing and syntax errors there. Once the user has
entered all data, the server version parses the whole data file which has
millions of records.


Thanks
Des



2009/3/21 Jim Idle <jimi at temporal-wave.com>

>  Sam Barnett-Cormack wrote:
>
> Des Hartman wrote:
>
>
>  This is a question that I suspect the answer is No, but I thought I'd
> ask anyway.
>
> If I have two implementations of ANTLR in different languages;
> ActionScript and Java, Is there a way that I can share the AST Tree
> (CommonTree) Objects between them?
>
> Idea is I enter a formula in a Flex application and do the parsing to
> AST using Actionscript. Once done I send the CommonTree objects to the
> server and this is based on Java. Here the server uses the same AST to
> then repeat the calculations on a much greater dataset.
>
>
>  It's certainly possible in theory, but I don't know of any easy way.
> You'd probably need some degree of custom code for marshal/unmarshal of
> the the ActionScript objects in Java. If they were transmitted in some
> vaguely-standard format, like JSON or some form of XML, you might be
> able to use libraries to help with the Java handling, but direct
> object--object translation seems unlikely.
>
>
>
>  Depending on performance traits, the best way would be to create a
> serialization routine for the actions script produced AST and a
> de-serializer for Java. This should be simple to do manually as you can copy
> the code that does toStringTree() and make sure you delimit things in such a
> way that you can deserialize without another parser. The existing format for
> printing trees might even be very close. We should think about doing this in
> a generic way within ANTLR, not so much for inter language integration, but
> I can see that there might be some value in saving ASTs in general. Of
> course, once you add custom payloads and so on, all bets might be off, and
> you would lose information such as the original input string.
>
> One question I have though is if you have to ship it back to the server
> anyway, why not just ship the source string to a Java Web Service or AJAX
> routine? I prsuem that you have vlaid reasons such as propagation delays and
> so on.
>
> Jim
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090321/decb5c72/attachment.html 


More information about the antlr-interest mailing list