Skip to main content



      Home
Home » Eclipse Projects » Eclipse Titan » Abstract syntax tree of ttcn(AST of ttcn types)
Abstract syntax tree of ttcn [message #1851357] Mon, 04 April 2022 01:09 Go to next message
Eclipse UserFriend
Hi,

Is there a way to dump the abstract syntax tree of the ttcn modules or types? I want to do some code generation to convert one type to another. One option is to log the ttcn type to json or xml and analyze its structure. But for this an initial variable with valid values need to be created. Is there a way to simply dump the full structure of a ttcn type in json/xml without filling all the data.

I am new to ttcn and titan. Appreciate all your valuable suggestions.

Thanks,
Bipin
Re: Abstract syntax tree of ttcn [message #1851384 is a reply to message #1851357] Mon, 04 April 2022 10:43 Go to previous messageGo to next message
Eclipse UserFriend
See the Chapter 4.26.4. Converting TTCN-3 and ASN.1 types to a JSON schema of the Programmers' Technical Reference Guide

Re: Abstract syntax tree of ttcn [message #1851410 is a reply to message #1851384] Tue, 05 April 2022 03:45 Go to previous messageGo to next message
Eclipse UserFriend
Thanks. I get an error when running compiler --ttcn2json

type record PDU_NAS_EPS
{
  BIT4                 protocolDiscriminator,
  EPS_messages         ePS_messages
} with { variant  (ePS_messages) "RAW". "CROSSTAG(
                          ePS_SessionManagement,  protocolDiscriminator='0010'B;
                          ePS_MobilityManagement, protocolDiscriminator='0111'B;
                          )"
};

} 
with { encode "RAW"; encode "JSON"; } // End of module


This results in the error:

NAS_EPS_Types.ttcn:3382.1-3386.1: In type definition `PDU_NAS_EPS':
     NAS_EPS_Types.ttcn:3386.10-3389.28: error: Invalid attribute format. Dot notation is only allowed for variant attributes when using the new codec handling.


The original code is from : https://gitlab.eclipse.org/eclipse/titan/titan.ProtocolModules.NAS_EPS_15.2.0.1
Re: Abstract syntax tree of ttcn [message #1854202 is a reply to message #1851410] Sat, 06 August 2022 04:26 Go to previous message
Eclipse UserFriend
I recently wrote a generic ttcn3 code generator, which does no checks, yet. There is no documentation, because it's still an experiment. But we use it at Nokia and you can use it to convert types, too.
If you are interested you need to install Go and then install the ttcn3 tool:
go install github.com/nokia/ntt@latest


Per default it dumps the AST to stdout. But you can specify your own tools to receive the tree via stdin. For example create an executable python script named ntt-gen-foobar in a reachable location.
When you call "ntt compile -G foobar" your python script will automatically get started.

[Updated on: Sun, 11 September 2022 04:46] by Moderator

Previous Topic:Cross level indicates whether the optional field exists
Next Topic:Reserved keywords on Table A.5 of the core specs
Goto Forum:
  


Current Time: Sat Jul 12 04:39:31 EDT 2025

Powered by FUDForum. Page generated in 0.10318 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top