Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to create non-printable ASCII chars as terminal rules?
How to create non-printable ASCII chars as terminal rules? [message #892647] Fri, 29 June 2012 00:01 Go to next message
James Ma is currently offline James MaFriend
Messages: 3
Registered: June 2012
Location: United States
Junior Member
Hi, I'm currently using Xtext to develop a plugin for my custom data format very much like JSON. I would like to thank the Xtext team itemis for developing such a robust framework, it has indeed saved me lots of development time in developing my DSL!

However, I'm at a block. I want to allow non-printable ASCII chars '\u0000' to '\u0020' and '\u007F'.

I searched for ways to allow these characters but there is currently a limitation as Xtext uses XML markup language for grammar access fragments. Setting:

fragment = grammarAccess.GrammarAccessFragment {
   xmlVersion = "1.1"
}


doesn't solve this issue fully as XML 1.0 and 1.1 both restricts the use of some non-printable ASCII chars (e.g. '\u0000').

I've tried to see if I could hook my custom lexer syntax error messages to display as valid instead, but it looks like instances of IParserErrorContext and IValueConverterErrorContext are the only SyntaxErrorMessage that I can obtain with the method

SyntaxErrorMessage getSyntaxErrorMessage (...)


Is there any workaround to include non-printable ASCII chars in my terminal rules?

[Updated on: Fri, 29 June 2012 00:02]

Report message to a moderator

Re: How to create non-printable ASCII chars as terminal rules? [message #892671 is a reply to message #892647] Fri, 29 June 2012 06:27 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the default terminals grammar defines an ANY_OTHER rule that matches anything not covered by other terminals. You might try the following approach (no guarantee).

Define one or more datatype rules of the following kind (e.g. one for each of the characters).

SpecialCharacterX: ANY_OTHER;

Use that in your grammar whereever that non-printable character is allowed. Using value converters you can then throw excpeptions, if ANY_OTHER matched anything but the character you defined the rule for.

Alex
Re: How to create non-printable ASCII chars as terminal rules? [message #893402 is a reply to message #892671] Tue, 03 July 2012 22:31 Go to previous message
James Ma is currently offline James MaFriend
Messages: 3
Registered: June 2012
Location: United States
Junior Member
I'll try this out, thanks Alexander.
Previous Topic:Problem with scopes
Next Topic:How to display multiple errors for same objects used more than once
Goto Forum:
  


Current Time: Wed Feb 19 21:55:02 GMT 2020

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

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

Back to the top