grammar for ignore string [message #1855515] |
Wed, 19 October 2022 07:49  |
Eclipse User |
|
|
|
FeatureList:
(elements+=Feature)*;
Feature:
name= ID';' selection=BooleanConstant ';' *;
BooleanConstant:
val=BooleanValue;
enum BooleanValue:
FALSE='FALSE' | TRUE='TRUE';
this is my grammar to parse a file where format is
ActSrv;TRUE;123;
xyz;TRUE;12av;
xyz1;TRUE;abc12;
xyz2;FALSE;123abc;34gh;
xyz3;FALSE;@cb98;xyp;
xyz4;TRUE;;
my requirement is to ignore all string after 2nd ';' or end the matcher and start from new row. but with the current code if there is anything after second column start with string getting stored in new name variable
|
|
|
Re: grammar for ignore string [message #1855546 is a reply to message #1855515] |
Thu, 20 October 2022 07:17   |
Eclipse User |
|
|
|
Hi
Surely this is easily handled by emulating the single line comment?
terminal SL_COMMENT:
'--' !('\n' | '\r')* ('\r'? '\n')?;
You can just use ';' as the comment character.
Regards
Ed Willink
|
|
|
Re: grammar for ignore string [message #1855639 is a reply to message #1855546] |
Tue, 25 October 2022 07:03   |
Eclipse User |
|
|
|
Hi
thanks for your reply . with the single comment logic its commenting the 2nd column too.
1st column : ActSrv;
2nd column: TRUE;
if i mention ";" as comment character it will comment 2nd column( True) too . but i need to comment every thing after TRUE.
[Updated on: Tue, 25 October 2022 07:03] by Moderator Report message to a moderator
|
|
|
Re: grammar for ignore string [message #1855651 is a reply to message #1855639] |
Tue, 25 October 2022 18:29   |
Eclipse User |
|
|
|
Hi
It should work, but since you don't share your code with us we cannot see if you have done something stupid.
I suggest debugging the traditional SL_COMMENT which works and gradually evolve it to what you want.
Regards
Ed Willink
|
|
|
|
Re: grammar for ignore string [message #1855664 is a reply to message #1855663] |
Wed, 26 October 2022 04:59  |
Eclipse User |
|
|
|
Hi
Firstly, since you are replacing SL_COMMENT, you must replace it else run the risk of allowing Xtext's built-in functionality to confuse.
Secondly, the traditional SL_COMMENT as shown in terminal is hidden. As a non-hidden token there may be a different whitespace interaction.
You should start by copying and pasting Terminais.xtext at the top of your grammar, then change the grammar name, then adjust the SL_COMMENT..
Regards
Ed Willink
[Updated on: Wed, 26 October 2022 05:11] by Moderator Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04636 seconds