Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Hexcode terminal vs Named Colors terminal. Terminal structuring problem.
Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699413] Wed, 24 June 2015 07:46 Go to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
In my language, I want to be able to describe a color both as a name, and as a Hexcode. For example:

I have both
terminal COLOR: 'AliceBlue'|'Aqua'|'Beige'|'Coral' ...

and so on, as well as

terminal HEXCODE: ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9')
.

These are going to be used to put a color on a participant in a diagram. For example, i want to be able to write both

Participant Bob #F912AAA
as well as
Participant Bob #Beige
in my DSL.

How would I go about structuring this? I have tried to do something like this in the participant rule:
Participant: 'Participant' ID '#' (COLOR|HEXCODE) ;


but it throws me a lot of errors with
Decision can match input such as "NumberSign OliveDrab" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input


Can anyone help me?
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699424 is a reply to message #1699413] Wed, 24 June 2015 09:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

there must be something else in your grammar that causes this. please show us a complete but minimal grammar that causes this.
and you should always assign stuff

Participant: 'Participant' name=ID '#' color=(COLOR|HEXCODE) ;



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699440 is a reply to message #1699424] Wed, 24 June 2015 10:53 Go to previous messageGo to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
This is what I currently have, somewhat minimized.

http://pastebin.com/z7VNwLJA

The DSL is planned to be used for syntax checking and colorization for the PlantUML plugin for eclipse. The syntax is available here: http://plantuml.sourceforge.net/sequence.html

I am guessing my grammar looks like crap, but it is my first time working with Xtext, so please bear with me. Smile
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699441 is a reply to message #1699413] Wed, 24 June 2015 11:11 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Perhaps you should include the # as part of the terminal, or else a
Hexcode may start grabbing other input?

Hallvard

On 24.06.15 09:46, Anton Bergman wrote:
> In my language, I want to be able to describe a color both as a name,
> and as a Hexcode. For example:
>
> I have both terminal COLOR: 'AliceBlue'|'Aqua'|'Beige'|'Coral' ...
> and so on, as well as
>
> terminal HEXCODE: ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9')
> ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' .. '9') ('A' .. 'F' | '0' ..
> '9') ('A' .. 'F' | '0' .. '9').
>
> These are going to be used to put a color on a participant in a diagram.
> For example, i want to be able to write both
> Participant Bob #F912AAA as well as Participant Bob #Beige in my DSL.
>
> How would I go about structuring this? I have tried to do something like
> this in the participant rule:
> Participant: 'Participant' ID '#' (COLOR|HEXCODE) ;
>
> but it throws me a lot of errors with Decision can match input such as
> "NumberSign OliveDrab" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
>
> Can anyone help me?
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699442 is a reply to message #1699441] Wed, 24 June 2015 11:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

the grammar generates fine. what is the actual problem you get?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699445 is a reply to message #1699442] Wed, 24 June 2015 11:24 Go to previous messageGo to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
That is the strangest thing. I have been banging my head against this problem for hours. I did some cleaning of the code before putting it in the pastebin, and now it suddently just works...
Could it perhaps have been the order of the terminals that were the problem?
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699446 is a reply to message #1699445] Wed, 24 June 2015 11:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
yes or other other (unused) rules

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699473 is a reply to message #1699446] Wed, 24 June 2015 13:48 Go to previous messageGo to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
On an unrelated note: With the grammar that I currently have, is there some easy way which I could extend my ID-terminal to also accept special characters, like #!"#!)&)=?
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699477 is a reply to message #1699473] Wed, 24 June 2015 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
no, not easy. simpy overriding does not work?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699478 is a reply to message #1699477] Wed, 24 June 2015 14:20 Go to previous messageGo to next message
Anton Bergman is currently offline Anton BergmanFriend
Messages: 34
Registered: June 2015
Member
What I ment with the question was: how would I write it?

Is there a way of covering a range of special characters? Similar to '1' ...'9' or 'A' .. 'B'

[Updated on: Wed, 24 June 2015 14:21]

Report message to a moderator

Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699486 is a reply to message #1699478] Wed, 24 June 2015 14:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
sry cannot help you with that

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hexcode terminal vs Named Colors terminal. Terminal structuring problem. [message #1699487 is a reply to message #1699486] Wed, 24 June 2015 14:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
and seasy solution would be to introduce a datatype rule

MyID: (ID|'#')+; and use that one


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Includes, global constants in DSL files
Next Topic:Autoformat: The comment preceding an element is not indented correctly.
Goto Forum:
  


Current Time: Mon Sep 23 09:17:06 GMT 2024

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

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

Back to the top