Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Generate TTCN-3 Code from Java
Generate TTCN-3 Code from Java [message #1779566] Tue, 09 January 2018 16:20 Go to next message
Alexander Kaiser is currently offline Alexander KaiserFriend
Messages: 28
Registered: May 2017
Junior Member
Hi *,

I would like to generate TTCN-3 code programmatically and preferably in Java. Unfortunately, this task is far from trivial.

I already tried to "abstract" TTCN-3 partially with POJOs and use the StringBuilder to generate the TTCN-3 code. IMHO this approach was quite simple in the beginning but appeared to be not feasible for more complex use cases.
So I moved on to ANTLR respectively Xtext, which seems to be the right way to go. Xtext utilizes ANTLR and builds a Lexer, Parser and Class Model for the AST and is even able to check the syntax and serialize the AST, exactly what I was looking for.
But describing the TTCN-3 grammar correctly in Xtext is even further from trivial. At least for me, as I don't have any experience with context-free grammars.
The next idea was to utilize Titan's code base for this task. Notably xsdconvert and titan.EclipsePlug-ins codegenerator seem to be promising. But I couldn't figure out whether the codegenerator is also able to produce TTCN-3 code or how I could utilize xsdconvert for this purpose.

Does anyone have any further ideas or suggestions?

Best regards,
Alexander




Re: Generate TTCN-3 Code from Java [message #1779575 is a reply to message #1779566] Tue, 09 January 2018 18:48 Go to previous messageGo to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 60
Registered: July 2015
Member
Hi Alexander,

First of all you will need to decide on the strength of the task at hand.
If you are "just" building TTCN-3 code, the simple appending strings approach might be ok.
If you wish to convert some data structure or FSM, you could still find a string appending approach useful ... although you will most probably use a visitor or some other pattern to traverse the data structures in the right order.
But if you have something way more complex at your hand, like translating Java to TTCN-3 ... than you will need to write a compiler (like Java/gcc/titan/etc..) which could mean several years of work even for people how have extensive experience in compiler construction.

To help with the problem at hand there are 2 things I don't understand based on your description.
1
If I understand correctly you wish to output TTCN-3 code from some other input.
In this case you do not need a lexer/parser/AST/etc.. for TTCN-3 since that is not the input you will parse.

For example the xsd converter parses XSD file to output TTCN-3 file, and both the compiler parses TTCN-3 files to output C++ files.
In both cases generating the output is basically just string concatenation, after all data is already processed.

2
Could you please give some information on you input?
I don't see if you have some data structure to process, or a program in some programming language as input.

Best Regards
Kristof
Re: Generate TTCN-3 Code from Java [message #1779620 is a reply to message #1779575] Wed, 10 January 2018 10:51 Go to previous message
Alexander Kaiser is currently offline Alexander KaiserFriend
Messages: 28
Registered: May 2017
Junior Member
Hi Kristof,

thank you for your response.

Actually, I don't really need a compiler/lexer because I will only need to generate TTCN-3 code. During my investigation on that topic, I stumbled over Xtext, which claims to make language engineering easy and was curious about that. However, I underestimated the complexity of TTCN-3.

My current project is quite similar to xsd2ttcn and Elemer's example, but the target will be something like swagger2ttcn. Accordingly, my inputs are Swagger files which I want to translate to TTCN-3 Template Definitions.

Thank you for your advice. I will proceed with appending string approach for now.

Best Regards
Alexander
Previous Topic:What's the difference between Titan AND RF(Robot Framework)?
Next Topic:Lego Bob strikes again
Goto Forum:
  


Current Time: Tue Apr 23 13:39:23 GMT 2024

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

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

Back to the top