[antlr-interest] C++-Target - write AST as XML

Jost Baron Jost.Baron at gmx.de
Fri Aug 3 11:17:49 PDT 2012


HI Jimi,

i've got it working now. The way was to simply add a @init and @after 
action to each rule, which starts or ends a xml node. This wasn't much 
effort using the regex find/replace mechanism of eclipse. It only gives 
me a parse tree in XML format, but that's fine, XSLT will do the rest.

The C++-Target has potential, but it still needs some work - better 
documentation, working support for custom members and AST-support are 
the most pressing issues to my mind (maybe Gokul reads this?). I can 
provide details about bugs if wanted.

JOst

On 08/03/2012 07:19 PM, Jim Idle wrote:
> Looks like someone copied my C templates to make a Cpp target, but has not
> implemented AST generation. I did not even know we had release a Cpp
> target to be honest. You may be at a dead end unless you can find the Cpp
> author. However, there is no overall reason you need to use Cpp, you can
> compile the C target as C++/intermingle it with C++
>
>
> Jim
>
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> bounces at antlr.org] On Behalf Of Jost Baron
>> Sent: Thursday, August 02, 2012 12:53 PM
>> To: antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] C++-Target - write AST as XML
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi Jimi,
>>
>> I want some form of the input file in a XML representation. If its a
>> generic AST or something else, doesn't matter, its going to be
>> transformed by XSLT anyway.
>>
>> My current problem is to get the AST generation running with the
>> Cpp-Target: On setting "output=AST;", a ton of error messages is
>> generated at compiletime. These error messages look like this:
>>
>> error: TreeType doesn't name a type.
>> error: 'struct myParser_timeStamp_return' has no member named 'tree'
>> (a follow up of #1)
>> error: 'ADAPTOR' was not declared in this scope
>> error: 'INPUT' was not declared in this scope
>> error: 'EXCEPTION' was not declared in this scope
>>
>> Obviously, something is not included or a type not defined - any idea
>> how to solve this?
>>
>> Jost
>>
>> On 08/02/2012 06:27 PM, Jim Idle wrote:
>>> It isn't clear what you are trying to make in to XML. The input as a
>>> translation, or the AST itself?
>>>
>>> Either way, this should be a fairly trivial set of methods that
>>> recursively walk the AST manually just check what node they are
>>> seeing. Look at the source code for the dot transformer in the ANTLR
>>> runtime for a template.
>>>
>>> Jim
>>>
>>>> -----Original Message----- From: antlr-interest-bounces at antlr.org
>>>> [mailto:antlr-interest- bounces at antlr.org] On Behalf Of Jost Baron
>>>> Sent: Thursday, August 02, 2012 6:39 AM To:
>>>> antlr-interest at antlr.org Subject: [antlr-interest] C++-Target -
>> write
>>>> AST as XML
>>>>
>>> Hi!
>>>
>>> I've successfully created a grammar for some DSL, and now want to
>>> print an AST the input into XML format. As the grammar is quite large
>>> (several hundred rules), doing this manually would be slow and error
>>> prone.
>>>
>>> So my question is: Is there anything that could help me to at least
>>> partly automatize the xml generation?
>>>
>>> Thanks, Jost
>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>> Unsubscribe:
>>>> http://www.antlr.org/mailman/options/antlr-interest/your-
>>>> email-address
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe:
>>> http://www.antlr.org/mailman/options/antlr-interest/your-email-
>> address
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.11 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iQIcBAEBAgAGBQJQGtqhAAoJEG6HPMAgWtVzJggQAJVCzY7nzMBTS4HxTDTAyfDT
>> jwk/vWW/mN4w8SRek31R/tjqhwO/DHKUiz48KNT50hc7dE2ciinkTqHBkNoX7/R7
>> tzAV3mwJOvYwo2M5KAA6W9iiPtS/x3Al5w1cqiJzWC9ES0cMPaduylEYy14+Ee5y
>> APp0OVzNwyoGcCdAdsrYsCoVAaeWfu8lCCjVTgGGF1/JIhtGtwm2aqjRUpA6rqly
>> cosoZoX/FFfbJ8LueA2eqhAwPqk3CC/ZKAfQo1rWCeJXdV3c28745KSjGY0uZs5+
>> a2uWz7Ao1Rxmag20av07m0zsUNNPXZ7LW5JIfbt98T+5+m+ivn0foaD/vFJb+Etf
>> lTHN2GbbOvxLMmf00lGxVCF2VS6aeZMHs4Ae3F9aclZ5TujfgCWt5dJcci5DuafE
>> koSezMWASAUXBJzwgdM6NYaB9lc1Ia3r76IpwsknObEUjIVtfZ34g4kecEP7uXJJ
>> 3oyLJMI9B/dWskWjXGPhscNqM4BWYpRXVrjmHrRStg778JDTcFipmqHaMm+OJJVc
>> AFFEwzEV8HwNu7ChJY2QPqzdgx9V89G2FuPgh8+FBUSS4XUr+izNGwjg6bVYGdXB
>> +KsMtjpEa4WidLmaA2mOXk7r58uubtJ5KFc3pxkssYFNq65GHm2q3jzwxSRyO4IC
>> Vg94foGiloeosOjpZaLf
>> =2gAE
>> -----END PGP SIGNATURE-----
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
>> email-address
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list