Some questions. [message #1858007] |
Fri, 10 March 2023 11:09  |
Eclipse User |
|
|
|
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. :-)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03048 seconds