Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » parse php code contain YieldExpression
parse php code contain YieldExpression [message #1408321] Thu, 14 August 2014 19:30 Go to next message
Laleh m is currently offline Laleh mFriend
Messages: 9
Registered: May 2013
Junior Member
Hello,

Have any one tried to parse a php code contains "YieldExpression"?

I am using org.eclipse.php.core_3.3.0 and org.eclipse.php.core.parser_3.3.0 to parse and build ast. They I just write the ast structure in a text file. So for a very simple example:

function gen_one_to_three() {
for ($i = 1; $i <= 3; $i++) {
// Note that $i is preserved between yields.
yield $i;
}
}

It generates this tree:
<Program start='0' length='148'>
<Statements>
<FunctionDeclaration start='6' length='142' isReference='false'>
<FunctionName>
<Identifier start='15' length='16' name='gen_one_to_three'/>
</FunctionName>
<FormalParameters>
</FormalParameters>
<FunctionBody>
<Block start='34' length='114' isCurly='true'>
<ForStatement start='40' length='106'>
<Initializations>
<Assignment start='45' length='6' operator='='>
<Variable start='45' length='2' isDollared='true'>
<Identifier start='46' length='1' name='i'/>
</Variable>
<Value>
<Scalar start='50' length='1' type='int' value='1'/>
</Value>
</Assignment>
</Initializations>
<Conditions>
<InfixExpression start='53' length='7' operator='&lt;='>
<Variable start='53' length='2' isDollared='true'>
<Identifier start='54' length='1' name='i'/>
</Variable>
<Scalar start='59' length='1' type='int' value='3'/>
</InfixExpression>
</Conditions>
<Increasements>
<PostfixExpression start='62' length='4' operator='++'>
<Variable start='62' length='2' isDollared='true'>
<Identifier start='63' length='1' name='i'/>
</Variable>
</PostfixExpression>
</Increasements>
<Block start='68' length='78' isCurly='true'>
<AstError start='131' length='5'/>
<ExpressionStatement start='137' length='3'>
<Variable start='137' length='2' isDollared='true'>
<Identifier start='138' length='1' name='i'/>
</Variable>
</ExpressionStatement>
</Block>
</ForStatement>
</Block>
</FunctionBody>
</FunctionDeclaration>
</Statements>
<Comments>
<Comment start='78' length='45' commentType='singleLine'/>
</Comments>
</Program>


check the <AstError start='131' length='5'/> when reaching to the Yeild expression.


Any clue why this happening?
Re: parse php code contain YieldExpression [message #1409645 is a reply to message #1408321] Mon, 18 August 2014 15:59 Go to previous message
Dawid Pakula is currently offline Dawid PakulaFriend
Messages: 290
Registered: March 2013
Senior Member
I checked on latest dev snapshot (nothing changed with YieldExpression parsing since release) and everything works correctly.

Are you using PHPVersion.PHP5_5 ?


Previous Topic:Error munmap_chunk with Ubuntu 14.04
Next Topic:XDebug stops at first line, but not breakpoints in 64-bit
Goto Forum:
  


Current Time: Wed Oct 09 20:20:06 GMT 2024

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

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

Back to the top