Left factorization and Index/Field Nodes

View: New views
1 Messages — Rating Filter:   Alert me  

Left factorization and Index/Field Nodes

by wuis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
I have the current grammar:

void UnaryExpression() #void : {}
{
  ( <OP_PLUS> | <OP_MINUS> ) UnaryExpression()  | <NOT> UnaryExpression()  |  PosFix()  
}

void PosFix() #void : {}
{
        ( PosFix() "[" Expression() "]" ) #indexNode
       
        |
       
        ( PosFix() "." Literal() ) #fieldNode
}

void PrimaryExpression() #void : {}
{
  <LPARENT> Expression() <RPARENT> | Literal()
}

how to do the left factorization in order to generate the indexNode and fieldNode in correct order?

exemple a tree:

    index
    /   \
   /  field
  /| | index
 / | |  /\
a[1].b[2]


thanx