Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parser jumps from rule to rule erratically
Parser jumps from rule to rule erratically [message #1463208] Thu, 06 November 2014 10:13
Pavel Sadovnikov is currently offline Pavel SadovnikovFriend
Messages: 8
Registered: July 2014
Junior Member
Hello everyone! I've ecountered a strange problem with Xtext. Parser begins to process one rule then enters into a subrule and exits out of this subrule in a comletely different rule sharing this subrule with the first one. Sounds a little messy so, please, look at ANTLR diagrams below. Of course, it produces collisions in grammar I'm trying to get rid of. Another bad thing that I couldn't reproduce this problem in simplier grammar, so this is a conflicting piece of my grammar

index.php/fa/19780/0/

index.php/fa/19781/0/

FullCommand:
	{FullCommand}
	(
	(label = [Label] ':')?
	(
			 (  (rep=RepN)?   lcp=LeftCommandPart 'with'   rcp=RightCommandPart )
			|(  (rep=RepN)? ->lcp=LeftCommandPart )
			|(( (rep=RepN)?   'nul'?   		    'with')? rcp=RightCommandPart )
		) 
		| (startrep = Repeat) 
		| (endrep   = EndRepeat ) 
		| (spec     = SpecialCommands)
	)
	';' lf=Linefeed
; 

RepN:
	{RepN}
	'rep' ((times = INT)|(const = ConstNameResolver ))
; 

//  *** *** *** FETCH VALUE 

FetchArgument:
	fa = (NonVectorRegister|AnyId|IntegerLookingNumericValue|AnyArrayElement)
; 

FetchOperation:
	lp = '[' 
	v = FetchArgument ( gbo = GetBiasOperation val = FetchArgument )?
	rp = ']'
; 

UnaryBiasInsideFetchOperation:
	lp = '[' 
	((val = NonVectorRegister uo = UnaryOperation)|(uo = UnaryOperation val = NonVectorRegister))
	rp = ']'
;

AnyValueFetchOperation:
	avfo = (FetchOperation|UnaryBiasInsideFetchOperation)
;

// *** *** *** *** *** *** *** *** *** ***
// *** LEFT COMMAND PART ***
// *** *** *** *** *** *** *** *** *** ***

LeftCommandPart:
	{LeftCommandPart}
	lcmd = ( MemoryReadCommand|MemoryWriteCommand|StackCommand|RegiserDirectModifying|ConditionalJump
			 |ConditionalSkip|ConditionalReturn|PswrModifying|FtwOrWtwOrBoth 
	) 
; //|RegisterVariableCopying|VariableRegisterCopying

MemoryReadCommand:
	(  rvreg += Register (',' rvreg += Register)? ) ( Equal avfo = AnyValueFetchOperation (',' ftwwtw = FtwOrWtwOrBoth)? )?
;
//Conflicts with RegiserDirectModifying ?eq=

MemoryWriteCommand:
	(lvfo = AnyValueFetchOperation) (Equal rvreg += Register (',' rvreg += Register)? (',' ftwwtw = FtwOrWtwOrBoth)? )?
; //eq=

RegiserDirectModifying:
	( rregs += NonVectorRegister (',' rregs += NonVectorRegister)? ) 
	Equal 
	(
		( lregs += NonVectorRegister (',' lregs += NonVectorRegister)? ) |
		( var = AnyId)|(arrelem = IntegerArrayElement)
	)
	('set'|'addr')?
; //eq=

// *** *** *** *** *** *** *** *** ***
// *** RIGHT COMMAND PARTS ***
// *** *** *** *** *** *** *** *** ***

RightCommandPart:
	rcmd = (EmptyCommand
			|ArithmeticCommandShortage|ArithmeticCommand|UnaryModificatedRegister|LogicalCommand
		    |ShiftOperation|ShiftOperationShortage
		    |MaskOperation|VsumOperation
		    |ResolverSingleActivatableVectorRegister|ResolverSingleLogicalNonVectorRegister|BinaryCommandWithNoOutput
		    |StoreVregs //|VectorLogicalCommand
	)
; 

// *** *** *** *** *** *** *** *** *** ***
// *** *** SCALAR REGISTER COMMANDS *** ***
// *** *** *** *** *** *** *** *** *** ***


ArithmeticCommandShortage:
	(lreg=NonVectorRegister) (sae=ShortageArithmeticEquals)
		rr1 = (NonVectorRegister|AnyId|AnyArrayElement|AnyNumericConstValue) 
		( 
			bo = BinaryArithmeticOperation 
		  	rr2 = (NonVectorRegister|AnyId|AnyArrayElement|AnyNumericConstValue) 
		)?
	(carryop=PlusOrMinus 'carry')? 'noflags'?
	//( ( shiftop=PlusOrMinus shift = (IntValue|HexValue))? carryop=PlusOrMinus 'carry')? 		'noflags'?
; //shift must be '-1' or '1' //(NonVectorRegister|IntValue|HexValue) rreg = (NonVectorRegister|AnyId|AnyArrayElement|AnyNumericConstValue) 
// TODO 30-10-14 diff. If conflicted try => 

ArithmeticCommand:
	(lreg = NonVectorRegister eq=Equal)?
			rr1 = (NonVectorRegister|AnyId|AnyArrayElement|AnyNumericConstValue) 
			bo = BinaryArithmeticOperation 
			rr2 = (NonVectorRegister|AnyId|AnyArrayElement|AnyNumericConstValue) 
	( 
		( shiftop=PlusOrMinus shift = (IntValue|HexValue) )? 
		carryop=PlusOrMinus 'carry'
	)? 
	'noflags'?
; // shift = (IntValue|HexValue)




Have anyone seen this behavior too?

UPD: Enabling backtracking eliminates the problem, but I consider this solution bad.
  • Attachment: alt1.jpg
    (Size: 429.43KB, Downloaded 430 times)
  • Attachment: alt2.jpg
    (Size: 381.67KB, Downloaded 313 times)

[Updated on: Thu, 06 November 2014 13:10]

Report message to a moderator

Previous Topic:Run mwe2 workflow using maven and fornax-oaw-m2-plugin
Next Topic:Request for 2.7.x feature documentation
Goto Forum:
  


Current Time: Fri Apr 26 02:34:59 GMT 2024

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

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

Back to the top