Unavoidable space issue [message #990384] |
Wed, 12 December 2012 09:10 |
Thomas Haarhoff Messages: 8 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 )
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04755 seconds