Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Unavoidable space issue (The OneWhitespaceFormatter.java strikes again)
Unavoidable space issue [message #990384] Wed, 12 December 2012 04:10 Go to previous message
Thomas Haarhoff is currently offline Thomas Haarhoff
Messages: 3
Registered: December 2012
Location: Germany
Junior Member
Hello.
I'm developing a parser for a low level language.
I want to parse a bigger size the generated code and dont want to adjust this code.

My Problem is now the following (simplified):

Function:
'define' Return_Attributes? returnType=Type name=VAR_TYPE pl=ParameterList 'unnamed_addr'? Function_Attributes* ('section ' STRING)? body=FunctionBody;


If you see, this should parse a function with its header and body. For example:

define void @_ZN5StackC2Ev(@class.Stack* %this) unnamed_addr nounwind align 2 { ... }


The goal is, the resulting AST contains:
FunctionHeader:
-> returnType: void
-> name: @_ZN5StackC2Ev
-> ParameterList pl:
->-> params: List of TypeAndValue
-> FunctionBody body:
->-> InstructionList (not part of problem - this part is fine Smile )


But between the name and the parameterlist the parser wants to have a space.
The funny thing is, the parser does not want this space before the closing bracket.

Here the other rules of interest.

ParameterList:
'(' (params+=TypeAndValue (',' params+=TypeAndValue)*)? ')';

TypeAndValue:
(VAR_TYPE | Basic_Type )Type;

So the should be possible:
( )
( type value )
( type value, type value, type value )
but also:
(type value )
(type value, type value, type value )
but this is not possible, cause the parser wants the space after the bracket.

VAR_TYPE is the only a terminal rule. (Basic_Type and Type may have a structual content so they can't be terminal rules...)

Has now someone perhaps an idea how i can fix this issue?

-Thomas
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:Syntax Highlight of disconnected rules
Next Topic:Getting EReference from Node
Goto Forum:
  


Current Time: Wed May 22 04:27:32 EDT 2013

Powered by FUDForum. Page generated in 0.08011 seconds