Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Some questions.
Some questions. [message #1858007] Fri, 10 March 2023 16:09 Go to next message
Frank Behr is currently offline Frank BehrFriend
Messages: 5
Registered: March 2023
Junior Member
I defined this grammar.

grammar org.xtext.dataformat.swiftbankingdsl.SwiftBankingDSL // hidden(WS, ML_COMMENT, SL_COMMENT)

generate swiftBankingDSL "http://www.xtext.org/dataformat/swiftbankingdsl/SwiftBankingDSL"

import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model:
    SWSyntax += Syntaxitem+;

Syntaxitem: 
    OPEN | FILLER | MULTIROWINDICATOR | SimpleSyntax | CLOSE;
    
SimpleSyntax:
    (FIELDLENGTH FIXEDLENGTHINDICATOR? ALPHACHARACTERSET) | 
    (NEGATIVESIGN? FIELDLENGTH FIXEDLENGTHINDICATOR? NUMCHARACTERSET);

terminal FILLER: ('/'|':');
terminal MULTIROWINDICATOR: ('2'..'9')('1'..'9')* ('*');
terminal FIELDLENGTH : ('1'..'9')('1'..'9')*; 
terminal FIXEDLENGTHINDICATOR: "!";
terminal ALPHACHARACTERSET: ( 'a' | 'x' );
terminal NUMCHARACTERSET: ( 'n' | 'd' );  
terminal NEGATIVESIGN: "[N]";
terminal OPEN: "[";
terminal CLOSE: "]"; 


It is part of the grammar used to exchange Swift messages. I programmed this in Delphi many years ago. Because I'm curious, I want to try it this way now. :-)
I now have some questions.

1. How can I output something in the XText editor when a terminal or nonterminal has been matched? So basically an event on a rule.
2. How do I translate the expressions of my grammar.
The grammar allows expressions like:

6!n6!n16x/1!a3!a15d or 4*1!n/33x

5!a means e.g. [A-Z]{5}
5a means [A-Z]{1,5}

For example, there are the following translation rules:
OPEN -> (
CLOSE -> )?
'a' -> [A-Z]
'n' -> [0-9]
MULTIROWINDICATOR -> (<the_whole_thing>\n){1,x}

Where can I program such rules?

I care more about understanding. Less about the fact that a productive system is created.

Thanks very much. :-)
Re: Some questions. [message #1858016 is a reply to message #1858007] Sat, 11 March 2023 08:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
hi, am not sure if i can sort you anyway on the "journey to Xtext" line

i would propose to do the tutorials first and then have a look at the examples that ship with Xtext

from what you wrote:

- your grammar does not produce an ast. Without an ast it is hard to do anything. You should create assignments for attributes and children
- what do you mean by "output in the editor" you may have a look at the interpreter on enter as its done in the arithmetics example or at the code minings in the domain model example
- what do you man by "translate the expressions"?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 11 March 2023 16:20]

Report message to a moderator

Re: Some questions. [message #1858019 is a reply to message #1858016] Sat, 11 March 2023 10:16 Go to previous message
Frank Behr is currently offline Frank BehrFriend
Messages: 5
Registered: March 2023
Junior Member
OK. I feared that. I'll look at the examples again. Thanks for the feedback.
Previous Topic:How to replace DefaultFoldingRegionProvider
Next Topic:Invalid plugin configuration: sourceRoots
Goto Forum:
  


Current Time: Tue Sep 24 17:27:20 GMT 2024

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

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

Back to the top