@@ -78,20 +78,20 @@ protected function getInstructionFromToken($token)
7878 }
7979 }
8080
81- protected function getValueFromToken ($ token )
81+ protected function getValueFromToken ($ token, $ previousToken = null , $ applicant = null )
8282 {
8383 $ value = $ this ->getInitialValue ($ token );
8484 if ($ value ) {
85- $ this ->appendFunctionsCalls ($ value );
85+ $ this ->appendFunctionsCalls ($ value, $ previousToken , $ applicant );
8686 }
8787
8888 return $ value ;
8989 }
9090
91- protected function handleOptionalValue ($ keyword , $ afterKeyword )
91+ protected function handleOptionalValue ($ keyword , $ afterKeyword, $ applicant )
9292 {
9393 if (!$ afterKeyword ->is ('; ' )) {
94- $ value = $ this ->expectValue ($ this ->next ());
94+ $ value = $ this ->expectValue ($ this ->next (), $ keyword , $ applicant );
9595 $ keyword ->setValue ($ value );
9696 }
9797 }
@@ -131,7 +131,7 @@ protected function getInitialValue($token)
131131 }
132132 }
133133
134- protected function appendFunctionsCalls (&$ value )
134+ protected function appendFunctionsCalls (&$ value, $ previousToken = null , $ applicant = null )
135135 {
136136 while ($ token = $ this ->get (0 )) {
137137 if ($ token ->is ('{ ' ) || $ token ->expectNoLeftMember ()) {
@@ -145,8 +145,7 @@ protected function appendFunctionsCalls(&$value)
145145 }
146146 if ($ token ->is ('( ' )) {
147147 $ this ->skip ();
148- $ arguments = array ();
149- $ value = new FunctionCall ($ value , $ this ->parseParentheses ()->nodes );
148+ $ value = new FunctionCall ($ value , $ this ->parseParentheses ()->nodes , $ applicant );
150149
151150 continue ;
152151 }
@@ -158,17 +157,16 @@ protected function appendFunctionsCalls(&$value)
158157 }
159158 if ($ token ->isAssignation ()) {
160159 $ this ->skip ();
161- $ arguments = array ();
162- $ valueToAssign = $ this ->expectValue ($ this ->next ());
160+ $ valueToAssign = $ this ->expectValue ($ this ->next (), $ previousToken );
163161 $ value = new Assignation ($ token ->type , $ value , $ valueToAssign );
164162
165163 continue ;
166164 }
167165
168166 $ this ->skip ();
169- $ nextValue = $ this ->expectValue ($ this ->next ());
167+ $ nextValue = $ this ->expectValue ($ this ->next (), $ previousToken );
170168 $ value = new Dyiade ($ token ->type , $ value , $ nextValue );
171- $ token = $ this ->get (0 );
169+ $ this ->get (0 );
172170
173171 continue ;
174172 }
@@ -177,15 +175,15 @@ protected function appendFunctionsCalls(&$value)
177175 }
178176 }
179177
180- protected function expectValue ($ next , $ token = null )
178+ protected function expectValue ($ next , $ token = null , $ applicant = null )
181179 {
182180 if (!$ next ) {
183181 if ($ token ) {
184182 throw $ this ->unexpected ($ token );
185183 }
186184 throw new Exception ('Value expected after ' . $ this ->exceptionInfos (), 20 );
187185 }
188- $ value = $ this ->getValueFromToken ($ next );
186+ $ value = $ this ->getValueFromToken ($ next, $ token , $ applicant );
189187 if (!$ value ) {
190188 throw $ this ->unexpected ($ next );
191189 }
0 commit comments