Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Derived Type in xtext for Yang
Derived Type in xtext for Yang [message #1768570] Thu, 20 July 2017 06:41
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 71
Registered: June 2017
Member
Hello Experts,

I am generating yang definition using Xtext grammar. I am using Derived type for modules in same file. It works perfectly. but if i use the same grammar for two different files. It doesn't work.

Derived Types in yang is:

typedef counter32 {
     type uint32;
     description
      "The counter32 type represents a non-negative integer
       that monotonically increases until it reaches a
       maximum value of 2^32-1 (4294967295 decimal), when it
       wraps around and starts increasing again from zero.

typedef zero-based-counter32 {
     type yang:counter32;
     default "0";
     description
      "The zero-based-counter32 type represents a counter32
       that has the defined 'initial' value zero.

       A schema node of this type will be set to zero (0) on creation
       and will thereafter increase monotonically until it reaches
       a maximum value of 2^32-1 (4294967295 decimal), when it
       wraps around and starts increasing again from zero.


I can use this derived types in same file.
But I get an error if i use the same grammar for two different files:
for example:
i define typedef
"counter32"
and i can also use it for type of another module.

But I can't use it in another file as a type.


My grammar is as below:

TypedefStatement:
	'typedef' name=(STRINGARG|KEY_IDENTIFIER)
	'{' (typedefsubstatemnet+=TypedefSubstatement)* '}';	
TypedefSubstatement:
	(TypeStatement
	|DescriptionStatement
	|ReferenceStatement
	|DefaultStatement
	|StatusStatement
	)
	;

//The crossreference must be done in diferent blocks
//identifier-ref-arg-str 
//[TypedefStatement]

TypeStatement:
	'type' (type=BuiltInType | (pre=STRINGARG':') ? importtype=[TypedefStatement])
	(';' 
	|'{' (typesubstatements+=TypeSubStatement)* '}');    

TypeSubStatement:
	(
	DefaultStatement
	|EnumStatement
	|LengthStatement
	|PatternStatement
	|RangeStatement
	|TypeStatement
	)
	;
Previous Topic:Qualify EReference before switching from Local to Global Scope
Next Topic:Both Eclipse support + LSP with a single project
Goto Forum:
  


Current Time: Wed Nov 22 18:47:55 GMT 2017

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

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