Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"'(error mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"')
mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767890] Wed, 12 July 2017 04:21 Go to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
index.php/fa/29933/0/
This is the text editor



This is my grammar.
index.php/fa/29934/0/


I get an error of
mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"'


Is there any way to define double quote in terminal id ?
Please help me with this.

Thanks.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767891 is a reply to message #1767890] Wed, 12 July 2017 04:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
do you inherit from terminals? that defines string. and that might conflict with your ID
since lexing is done first and context free

if yes why not reusing that e.g.

IDORSTRING: STRING | ID;



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767893 is a reply to message #1767891] Wed, 12 July 2017 04:54 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Yes, I inherit from terminal.
But is it possible to write the grammar as below:

NamespaceStatement:
'namespace'
'"' uri=STRINGARG4 '"'
';';
//(prefix+=PrefixStatement);

PrefixStatement:
'prefix' name=STRINGARG';' ;


and delete it from the terminal ID.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767894 is a reply to message #1767893] Wed, 12 July 2017 04:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you please share a complete but minimal reproducing grammar and a bunch of unit tests?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767896 is a reply to message #1767894] Wed, 12 July 2017 05:13 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
This is new grammar.

index.php/fa/29937/0/


This is the text editor.

index.php/fa/29938/0/


index.php/fa/29939/0/
I want this output in my xtext editor.

I havent done any unit testing.

I am new in xtext/ xtend grammar developmnt.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767897 is a reply to message #1767896] Wed, 12 July 2017 05:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
screenshots are not useable

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767898 is a reply to message #1767897] Wed, 12 July 2017 05:18 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Xtext Grammar:

grammar org.xtext.yang.samplemib.SampleMib with org.eclipse.xtext.common.Terminals

generate sampleMib "http://www.xtext.org/yang/samplemib/SampleMib"

Model:
	Module;
	
Module:
	'module' name=STRINGARG
	'{'
	(statements += Statement)*
	'}'
;

Statement:
	( NamespaceStatement 
	| PrefixStatement 
		
		//| ImportStatement
	);

NamespaceStatement:
	'namespace' 
	 '"' uri=STRINGARG4 '"'
	';'; 
	//(prefix+=PrefixStatement);

PrefixStatement:
	'prefix' name=STRINGARG';' ;
	
//ImportStatement:
	//'import' importURI =STRINGARG '{'
		//(prefix += PrefixStatement)
	//'}'';';
STRINGARG:
	(ID | CUSTOMSTRING | 'default')+;

STRINGARG4:
	(((ID+':'ID) + (':' +ID)+)| (':'+KEY_IDENTIFIER)+);

CUSTOMSTRING:
	(STRING (';' STRING));
	
@Override 
terminal ID:
    ('^')?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9')*; 
	
KEY_IDENTIFIER:
	(=>'value' | =>'status' | =>'namespace' | =>'notification' |=> 'path'  |=> 'description' |=> 'string' |
		 =>'error-message' | =>'config' |=>'range' | =>'revision' | =>'type' | =>'boolean' | =>'prefix' | 
		 =>'range' | => 'key' | =>'fraction-digits')+;




Xtext Editor:


module SNMPv2-MIB {
	namespace "urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB";
	
	
	}



This is my code.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767902 is a reply to message #1767898] Wed, 12 July 2017 05:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

there a a problem. as i said lexers are context free.
=> if something can be parsed as a STRING, it will be parsed as a STRING
you would have to write a custom lexer for that and this is not a trivial task

what you could do instead:

- using STRING and write a check in the MyDslValidator that checks the format
- using a datatype rule on STRING and a custom Value converter that checks the format

maybe you can try to rearrange your grammar as well,
but you need to check how this conflicts with the places you exect a string

NamespaceStatement:
'namespace'
uri=STRINGARG4
';';

terminal STRINGARG4:
'"' (((ID+':'ID) + (':' +ID)+)| (':'+KEY_IDENTIFIER)+) '"';

terminal KEY_IDENTIFIER:
('value' | 'status' | 'namespace' | 'notification' | 'path' | 'description' | 'string' |
'error-message' | 'config' |'range' | 'revision' | 'type' | 'boolean' | 'prefix' |
'key' | 'fraction-digits')+;


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767909 is a reply to message #1767902] Wed, 12 July 2017 06:40 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Can i use below import statement in my code for DSL modeling?

import "http://www.eclipse.org/emf/2002/Ecore" as ecore


Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767914 is a reply to message #1767909] Wed, 12 July 2017 06:56 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
NamespaceStatement:		 
	'namespace' uri=(STRINGARG | STRINGARG4)
	(';' 
	|'{' (namespaceunknownstatements+=UnknownStatement)* '}');


This one works using below import statement,

import "http://www.eclipse.org/emf/2002/Ecore" as ecore


Thanks Christian.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767915 is a reply to message #1767909] Wed, 12 July 2017 06:56 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
NamespaceStatement:		 
	'namespace' uri=(STRINGARG | STRINGARG4)
	(';' 
	|'{' (namespaceunknownstatements+=UnknownStatement)* '}');


This one works using below import statement,

import "http://www.eclipse.org/emf/2002/Ecore" as ecore


Thanks Christian.
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1767917 is a reply to message #1767915] Wed, 12 July 2017 07:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
something like

uri=STRINGARGORSTRINGARG4 ...


STRINGARGORSTRINGARG4 returns ecore::EString: STRINGARG | STRINGARG4;

is what i have thought of


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: mismatched input '"urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB"' expecting '"' [message #1768019 is a reply to message #1767917] Thu, 13 July 2017 04:02 Go to previous message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
EMF - The core EMF framework includes a meta model (Ecore) for describing models and runtime support for the models including change notification, persistence support with default XMI serialization, and a very efficient reflective API for manipulating EMF objects generically.

https://www.eclipse.org/modeling/emf
Previous Topic:Accessing DSL statement in generator class
Next Topic:Grammar Mixins/Library vs. Tycho/Maven build
Goto Forum:
  


Current Time: Sat Apr 20 02:38:57 GMT 2024

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

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

Back to the top