Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » String Literal Problem
String Literal Problem [message #21281] Tue, 01 May 2007 18:11 Go to next message
Eclipse UserFriend
Originally posted by: mike.aol.com

I need to use regular expression string literals in OCL, but the parser
barfs on escaped characters.

For example: '\[' causes
1:1:1:4 "'\[' unexpected token(s)"

But '\\[' evaluates to "\\["

What does it want?

Thanks,
Mike Gering
Re: String Literal Problem [message #21302 is a reply to message #21281] Tue, 01 May 2007 18:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Mike,

You have most curious timing. I was just investigating a question of how to
escape single-quotes ("'") within strings literals -- something for which
the OCL specification makes no provision -- and discovered that the lexer
grammar definition has rules for Java-style backslash escapes that are not
compliant with the spec. The grammar understands "\\" as an escaped
backslash, but the parser does not process the escapes when constructing
the Java string representations.

This is a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=184948

I will see about fixing it for the 1.1 release by removing the backslash
rules (since they didn't work, anyway, nobody will miss them). For OCL
1.0.x, you can avoid using string literals for these cases by defining
"global variables" and injecting them into the environment, as you
indicated that you were doing with rule bindings a few days ago.

Cheers,

Christian


Mike Gering wrote:

> I need to use regular expression string literals in OCL, but the parser
> barfs on escaped characters.
>
> For example: '\[' causes
> 1:1:1:4 "'\[' unexpected token(s)"
>
> But '\\[' evaluates to "\\["
>
> What does it want?
>
> Thanks,
> Mike Gering
Re: String Literal Problem [message #21552 is a reply to message #21302] Tue, 01 May 2007 19:15 Go to previous message
Eclipse UserFriend
Originally posted by: mike.aol.com

Christian,

Thanks, and I'll use the global variable approach as a workaround.

Do you want to tell me the next bug I'll find, or should I tell you the
next one you'll find? :-)

Mike
Previous Topic:OCL Type Conformance Error
Next Topic:parsing OCL def: statements in an .ocl file
Goto Forum:
  


Current Time: Fri Sep 20 17:01:42 GMT 2024

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

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

Back to the top