Error in creating fragment for STRING [message #1799725] |
Thu, 13 December 2018 03:09 |
P J Messages: 64 Registered: October 2018 |
Member |
|
|
Hi,
I have the below code for a DSL that I'm building using Xtext in Eclipse (I'm converting a .g4 file to Xetxt: -
Domainmodel:
elements+=projection_name elements+=projection_component elements+=layer_specification
elements+=description
;
projection_name
: keywords+=KEYWORD_projection model_name+=projection_name_model_name punctuations+=SEMICOLON
;
projection_name_model_name
: identifiers+=identifier2
;
projection_component
: keywords+=KEYWORD_component component_name+=projection_component_component_name punctuations+=SEMICOLON
;
projection_component_component_name
: identifier+=identifier2
;
layer_specification
: keywords+=KEYWORD_layer layer_name+=layer_specification_layer_name punctuations+=SEMICOLON
;
layer_specification_layer_name
: identifier+=identifier2
;
description
: keywords+=KEYWORD_description string+=STRING punctuations+=SEMICOLON
;
KEYWORD_component
: ( key='component' )
;
KEYWORD_description
: ( key='description' )
;
KEYWORD_layer
: ( key='layer' )
;
KEYWORD_projection
: ( key='projection' )
;
fragment STRING
: '"' ( ('\\'|'"') | ('\\'|'"'))* '"'
;
SEMICOLON
: symbol=';'
;
identifier2
: IDENTIFIER
;
projectionmainidentifier
: IDENTIFIER
;
offlineexpressionidentifier
: IDENTIFIER
| KEYWORD_description
| KEYWORD_projection
;
IDENTIFIER
: name=ID
;
Everything is fine except for the 'fragment STRING' definition. The word 'STRING' gets underlined in red and states "A datatype rule cannot override a terminal rule."
Could you please tell me how this should be corrected?
Regards.
[Updated on: Thu, 13 December 2018 03:30] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Error in creating fragment for STRING [message #1799747 is a reply to message #1799746] |
Thu, 13 December 2018 09:11 |
P J Messages: 64 Registered: October 2018 |
Member |
|
|
I tried this. But when I click on 'terminal STRING', what I get is:
TerminalRule STRING
ALERT_LINE_COMMENT : ( '//!' ('\r'|'\n')* ) ; QUESTION_LINE_COMMENT : ( '//?' ('\r'|'\n')* ) ; GOOD_LINE_COMMENT : ( '//=' ('\r'|'\n')* ) ; CHARACTER : ('\'') ('\'') ('\'') ; terminal TIME : ( ('0'..'9')+ ':' ('0'..'9')+ ) ;
This is, surprisingly, the syntax definitions (that are commented) I have mentioned above the terminal STRING rule!
The other thing I realized was that, when I removed the comments from the above said definitions, the default STRING is given just as 'TerminalRule STRING'. So I guess the definition I'm getting must be wrong, because whatever I put as comments above the terminal rule, will be displayed as its definition. Could you please help me with this problem?
[Updated on: Thu, 13 December 2018 09:21] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03480 seconds