Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ei.unescapeString(getText(), 1)
ei.unescapeString(getText(), 1) [message #25331] Sun, 04 January 2009 22:41 Go to next message
J Rusk is currently offline J RuskFriend
Messages: 16
Registered: July 2009
Junior Member
Hi eclipse.modeling.tmf group.

I have some strings delimited with double-quotes (eg. "string") and some
strings delimited by leading underscore and double quotes (eg. _"string").

I can add ('_\"' | '\"') to the NAME rule so the lexer can recognize both
strings but then the ei.unescapeString(getText(), 1) is a problem because
sometimes I need to escape just the double quotes and other times the
underscore and double-quotes.

Can anyone let me know how the unescapeString(String, int) method works
and how it may be used here or suggest another function which may deal
with this?

Thanks,

Jeff
Re: ei.unescapeString(getText(), 1) [message #25371 is a reply to message #25331] Mon, 05 January 2009 08:00 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
I assume this question is dedicated to TCS, right?

Sven

J Rusk schrieb:
> Hi eclipse.modeling.tmf group.
>
> I have some strings delimited with double-quotes (eg. "string") and some
> strings delimited by leading underscore and double quotes (eg. _"string").
>
> I can add ('_\"' | '\"') to the NAME rule so the lexer can recognize
> both strings but then the ei.unescapeString(getText(), 1) is a problem
> because sometimes I need to escape just the double quotes and other
> times the underscore and double-quotes.
> Can anyone let me know how the unescapeString(String, int) method works
> and how it may be used here or suggest another function which may deal
> with this?
>
> Thanks,
>
> Jeff
>
[TCS] Re: ei.unescapeString(getText(), 1) [message #25412 is a reply to message #25371] Mon, 05 January 2009 16:48 Go to previous messageGo to next message
J Rusk is currently offline J RuskFriend
Messages: 16
Registered: July 2009
Junior Member
That is correct. Sorry, I forgot the [TCS] prefix.

Sven Efftinge wrote:

> I assume this question is dedicated to TCS, right?

> Sven

> J Rusk schrieb:
>> Hi eclipse.modeling.tmf group.
>>
>> I have some strings delimited with double-quotes (eg. "string") and some
>> strings delimited by leading underscore and double quotes (eg. _"string").
>>
>> I can add ('_"' | '"') to the NAME rule so the lexer can recognize
>> both strings but then the ei.unescapeString(getText(), 1) is a problem
>> because sometimes I need to escape just the double quotes and other
>> times the underscore and double-quotes.
>> Can anyone let me know how the unescapeString(String, int) method works
>> and how it may be used here or suggest another function which may deal
>> with this?
>>
>> Thanks,
>>
>> Jeff
>>
Re:[TCS] ei.unescapeString(getText(), 1) [message #25453 is a reply to message #25331] Tue, 06 January 2009 09:20 Go to previous messageGo to next message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
I can't tell you how the ei.unescapeString() function
works, but I don't think that you're trying to take the
correct approach.

As you have two different primitives, I think that you
need to declare two string primitiveTemplates. One of
these should be defined with the default keyword,
and will be called for most string type attributes in
your grammar. For string type attributes that need the
other syntax, use the "{as=xxx}" annotation on the
attribute name; where xxx is the name of your
non-default string primitiveTemplate.

I hope that this helps

Andy.

"J Rusk" <rusk@qiniq.com> wrote in message
news:8190d4c1599f5ad80a8260d6449b0b9a$1@www.eclipse.org...
> Hi eclipse.modeling.tmf group.
>
> I have some strings delimited with double-quotes (eg. "string") and some
> strings delimited by leading underscore and double quotes (eg. _"string").
>
> I can add ('_\"' | '\"') to the NAME rule so the lexer can recognize both
> strings but then the ei.unescapeString(getText(), 1) is a problem because
> sometimes I need to escape just the double quotes and other times the
> underscore and double-quotes.
> Can anyone let me know how the unescapeString(String, int) method works
> and how it may be used here or suggest another function which may deal
> with this?
>
> Thanks,
>
> Jeff
>
Re: [TCS] ei.unescapeString(getText(), 1) [message #25646 is a reply to message #25453] Tue, 06 January 2009 21:56 Go to previous messageGo to next message
J Rusk is currently offline J RuskFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks Andy. Very good point. I likely was heading in the wrong direction.

Would this work in situations where I do not know in advance which
primitiveTemplate would be required for a given attribute (i.e. could be
"string" or _"string" for a given attribute)?

Jeff

Andy Carpenter wrote:

> I can't tell you how the ei.unescapeString() function
> works, but I don't think that you're trying to take the
> correct approach.

> As you have two different primitives, I think that you
> need to declare two string primitiveTemplates. One of
> these should be defined with the default keyword,
> and will be called for most string type attributes in
> your grammar. For string type attributes that need the
> other syntax, use the "{as=xxx}" annotation on the
> attribute name; where xxx is the name of your
> non-default string primitiveTemplate.

> I hope that this helps

> Andy.
Re: [TCS] ei.unescapeString(getText(), 1) [message #25677 is a reply to message #25646] Fri, 09 January 2009 12:34 Go to previous messageGo to next message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
Jeff,

The way that I'd handle this is by making the model
reflect more syntax than ideal by having an attribute
for each of the possible types. I'd then do an m2m
transformation to convert the 'syntactic' model into
a 'purer' form.

Andy.


"J Rusk" <rusk@qiniq.com> wrote in message
news:cc1870b08f6247196a9c1a7403770c72$1@www.eclipse.org...
> Thanks Andy. Very good point. I likely was heading in the wrong
> direction.
>
> Would this work in situations where I do not know in advance which
> primitiveTemplate would be required for a given attribute (i.e. could be
> "string" or _"string" for a given attribute)?
>
> Jeff
>
> Andy Carpenter wrote:
>
>> I can't tell you how the ei.unescapeString() function
>> works, but I don't think that you're trying to take the
>> correct approach.
>
>> As you have two different primitives, I think that you
>> need to declare two string primitiveTemplates. One of
>> these should be defined with the default keyword,
>> and will be called for most string type attributes in
>> your grammar. For string type attributes that need the
>> other syntax, use the "{as=xxx}" annotation on the
>> attribute name; where xxx is the name of your
>> non-default string primitiveTemplate.
>
>> I hope that this helps
>
>> Andy.
>
>
>
Re: [TCS] ei.unescapeString(getText(), 1) [message #25706 is a reply to message #25677] Sat, 10 January 2009 17:45 Go to previous messageGo to next message
J Rusk is currently offline J RuskFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks. This was working for me just great - until I realized with an
example that the different syntaxes ("string", _"string", or just string)
can show up within the same attribute, please see example below:

importsOntology { GML#GML212Ontology, FilterEncoding#FilterEncoding,
_”http://www.swing-project.org/virtual” }

My basic problem is that any IRI can be abbreviated to a Compact URI. Full
IRI's are delimited with the symbols ' _" ' and ' " ' but Compact URI does
not require special delimiters.

I'm not sure where to go from here. Any thoughts?

Andy Carpenter wrote:

> Jeff,

> The way that I'd handle this is by making the model
> reflect more syntax than ideal by having an attribute
> for each of the possible types. I'd then do an m2m
> transformation to convert the 'syntactic' model into
> a 'purer' form.

> Andy.


> "J Rusk" <rusk@qiniq.com> wrote in message
> news:cc1870b08f6247196a9c1a7403770c72$1@www.eclipse.org...
>> Thanks Andy. Very good point. I likely was heading in the wrong
>> direction.
>>
>> Would this work in situations where I do not know in advance which
>> primitiveTemplate would be required for a given attribute (i.e. could be
>> "string" or _"string" for a given attribute)?
>>
>> Jeff
>>
>> Andy Carpenter wrote:
>>
>>> I can't tell you how the ei.unescapeString() function
>>> works, but I don't think that you're trying to take the
>>> correct approach.
>>
>>> As you have two different primitives, I think that you
>>> need to declare two string primitiveTemplates. One of
>>> these should be defined with the default keyword,
>>> and will be called for most string type attributes in
>>> your grammar. For string type attributes that need the
>>> other syntax, use the "{as=xxx}" annotation on the
>>> attribute name; where xxx is the name of your
>>> non-default string primitiveTemplate.
>>
>>> I hope that this helps
>>
>>> Andy.
>>
>>
>>
Re: [TCS] ei.unescapeString(getText(), 1) [message #25826 is a reply to message #25706] Sat, 10 January 2009 23:54 Go to previous message
J Rusk is currently offline J RuskFriend
Messages: 16
Registered: July 2009
Junior Member
Actually a colleague provided a hint which seems to do the trick.
Unfortunately, I'm usually oblivious to the simplest, most elegant
solution. Relevant additions to .tcs and .km3 below ...

In TCS:
template Full_IRI
: "_" <no_space> link
;


template Compact_IRI context
: link
;

template IRI abstract;

In KM3:
abstract class IRI extends LocatedElement {
attribute link : String;
}

class Full_IRI extends LocatedElement, IRI {}

class Compact_IRI extends LocatedElement, IRI {}
Previous Topic:Complex DSL
Next Topic:Dependency between eclipse plugins
Goto Forum:
  


Current Time: Tue Mar 19 05:36:17 GMT 2024

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

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

Back to the top