Skip to main content



      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] Thu, 28 June 2012 20:01 Go to next message
Eclipse UserFriend
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: Thu, 28 June 2012 20:02] by Moderator

Re: How to create non-printable ASCII chars as terminal rules? [message #892671 is a reply to message #892647] Fri, 29 June 2012 02:27 Go to previous messageGo to next message
Eclipse UserFriend
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 18:31 Go to previous message
Eclipse UserFriend
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: Sun Jul 27 08:13:52 EDT 2025

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

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

Back to the top