ei.unescapeString(getText(), 1) [message #25331] |
Sun, 04 January 2009 17:41  |
Eclipse User |
|
|
|
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 #25706 is a reply to message #25677] |
Sat, 10 January 2009 12:45   |
Eclipse User |
|
|
|
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 18:54  |
Eclipse User |
|
|
|
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 {}
|
|
|
Powered by
FUDForum. Page generated in 0.03868 seconds