Note that there are some explanatory texts on larger screens.

plurals
  1. POChange the multi-line comment characters in Xtext
    primarykey
    data
    text
    <p>I want a Xtext grammar that allows me to write MIME media types this way:</p> <pre><code>mediaType application/atom+xml specURL "http://www.rfc-editor.org/rfc/rfc4287.txt", </code></pre> <p>This is not a problem, but the following is:</p> <pre><code>mediaType application/* specURL "http://www.iana.org/assignments/media-types/application", </code></pre> <p>You can guess of the troubles ahead with the <code>/*</code> characters that usually define a multi-line comment. The terminal for it is defined in the default Terminals provided by Xtext, more specifically in the ML_COMMENT terminal:</p> <pre><code>terminal ML_COMMENT : '/*' -&gt; '*/'; </code></pre> <p>I customized it by copying the default terminals to a new one of my own, where the ML_COMMENT terminal is defined this way instead:</p> <pre><code>terminal ML_COMMENT : '"""' -&gt; '"""'; </code></pre> <p>This produces a more Pythonistic way to have multi-line comments. It works fine in the generated DSL. But the <code>/*</code> characters still pose problem when I try to define the media type for <code>application/*</code>, as shown above. I get an error message of <em>mismatched input '/*' expecting '}'</em> (the <code>}</code> character would specify the end of the media types listing). </p> <p>Even more troubling is that the content assist of the Xtext editor still auto-fill an ending <code>*/</code> multi-line comment characters when I type a (supposedly obsolete) <code>/*</code> combo characters. As I overrode the multi-line comment terminal, I am wondering why the auto-complete still flirts with the older ML_COMMENT definition. Do I need to override something else?</p> <p>Here are some fragments for the media type grammar: </p> <pre><code>MediaType returns restapi::MediaType: {restapi::MediaType} 'mediaType' name=MediaTypeQualifier ('specURL' specURL=EString)?; MediaTypeQualifier: MediaTypeFragment ('/' MediaTypeFragment)?(';' MediaTypeFragment'='MediaTypeFragment)*; MediaTypeFragment: (ID ( ('-'|'+'|'.') ID )* ) | '*' </code></pre> <p>I am using Xtext version 2.3.1 within Eclipse 4.2.2. Does anyone have experience with overriding the multi-line comment terminal? Is there something that I missed?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload