Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with number sign(Problem with number sign)
Problem with number sign [message #1730362] Mon, 25 April 2016 10:01 Go to next message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
Hi Christian,

I have single line comment like

# gfadgfhdfghsg

In the above comment line starting should be #.

And I have concatenation operator ## like

test1 = "test2" ## "test3"

HashComment :{HashComment}'#' jplId+=JPLID*;

Concatenation returns Expression:
Primary ({Concatenation.left=current} '##' right=Primary)*

Case 1 is working fine but case 2 not working. How can I handle # comment ## concatenation operator
Re: Problem with number sign [message #1730365 is a reply to message #1730362] Mon, 25 April 2016 10:17 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Think it runs on a "first fit" base,
so try to place the Concatenation rule before the HashComment rule.
Re: Problem with number sign [message #1730366 is a reply to message #1730362] Mon, 25 April 2016 10:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please share everything needed to reproduce

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730368 is a reply to message #1730365] Mon, 25 April 2016 10:45 Go to previous messageGo to next message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
Hi Christian,

In my editor single line comment is starts with # but it should not contain any characters before #.

If I put # rule in SL_COMMENT it works everywhere like:
vars a #test
but it is invalid in my case. I don't want anthing before hash..

Next I have an operator ## which concats to operands like:

b1134p_msg1 = 'Could not find or open input file "'##b1134p_dat_file##'" for processing date "'##b1134p_date##'" in BPS1134P.'

When I am using '#' rule in SL_COMMENT the above expression becoming comment where '#' starts.
Re: Problem with number sign [message #1730369 is a reply to message #1730368] Mon, 25 April 2016 10:48 Go to previous messageGo to next message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
One more question:

Is there any way that terminal rule starts at the beginning of the line not at middle or end. I mean I don't want terminal rule to work if it is not at starting of the like
Re: Problem with number sign [message #1730372 is a reply to message #1730369] Mon, 25 April 2016 11:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
is hash comment a terminal or a parser rule.
you contradict on this in your posts


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730373 is a reply to message #1730372] Mon, 25 April 2016 11:01 Go to previous messageGo to next message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
At present I am trying with parser rule because with parser rule only with can validate whether it is starting with '#' or not?
Re: Problem with number sign [message #1730374 is a reply to message #1730373] Mon, 25 April 2016 11:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
with a parser rule there should no be a problem.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730375 is a reply to message #1730374] Mon, 25 April 2016 11:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
=> please share all needed

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730376 is a reply to message #1730374] Mon, 25 April 2016 11:07 Go to previous messageGo to next message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
This is my parser rule
HashComment :{HashComment}'#' jplId+=ID*;

But when I use like
############################
# Date
# Name
###########################

in my editor it is showing error because I have a concatenation operator '##' like

Expression:
LogicalOr
;

LogicalOr returns Expression:
BitwiseOr ({LogicalOr.left=current} '||' right=BitwiseOr)*
;
BitwiseOr returns Expression:
LogicalAnd ({BitwiseOr.left=current} '|' right=LogicalAnd)*
;
LogicalAnd returns Expression:
BitwiseAnd ({LogicalAnd.left=current} '&&' right=BitwiseAnd)*
;
BitwiseAnd returns Expression:
Equivalency ({BitwiseAnd.left=current} '&' right=Equivalency)*
;
/*Changes*********** */
Equivalency returns Expression:
Relational ({Equivalency.left=current} ('=='|'!='|'=') right=Relational)*
;
Relational returns Expression:
PlusMinus ({Relational.left=current} ('>='|'<='|'>'|'<') right=PlusMinus)*
;
PlusMinus returns Expression:
DivMult ({PlusMinus.left=current} ('+'|'-') right=DivMult)*
;
DivMult returns Expression:
LogicalNot ({DivMult.left=current} ('/'|'*') right=LogicalNot)*
;
LogicalNot returns Expression:
OnesComplement ({LogicalNot.left=current} '!' right=OnesComplement)*
;
OnesComplement returns Expression:
Exponentiation ({OnesComplement.left=current} ('~') right=Exponentiation)*
;
Exponentiation returns Expression:
Concatenation ({Exponentialtion.left=current} '^' right=Concatenation)*
;
Concatenation returns Expression:
Primary ({Concatenation.left=current} '##' right=Primary)*
;
Primary returns Expression:
value=NUMBER | value=JPLString | JPLID | '(' LogicalOr ')' | jplId=JPLID'[' maxOccurs=NUMBER ']'
;
Re: Problem with number sign [message #1730377 is a reply to message #1730375] Mon, 25 April 2016 11:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Model:
things+=Thing*;

Thing:
a=INT "##" b=INT
;

terminal HASH_COMMENT : '#' !('#'|'\n'|'\r')+ ('\r'? '\n')?;

works fine for me


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730378 is a reply to message #1730377] Mon, 25 April 2016 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
or

terminal HASH_COMMENT : ('#' !('#'|'\n'|'\r')+ ('\r'? '\n')?) |
(('#''#''#') !('\n'|'\r')+ ('\r'? '\n')?)
;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem with number sign [message #1730405 is a reply to message #1730378] Mon, 25 April 2016 13:52 Go to previous message
RamaRao Nandamuri is currently offline RamaRao NandamuriFriend
Messages: 120
Registered: April 2016
Senior Member
Thanks a lot sir..

It's working great!!!!!!
Previous Topic:Syntax Highlighting in Xtext
Next Topic:CDT-like Hovers
Goto Forum:
  


Current Time: Fri Apr 19 01:23:15 GMT 2024

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

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

Back to the top