Lines Matching defs:token

269 	  throw new Exception("Invalid token at position: $i");
274 function ebnf_check_token($token, $type, $value) {
275 return $token['type']==$type && $token['value']==$value;
283 $i = 0; $token = $tokens[$i++];
284 if ($token['type'] == EBNF_LITERAL_TOKEN) {
286 stripcslashes(substr($token['value'], 1, strlen($token['value'])-2 )));
287 $token = $tokens[$i++];
289 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '{') )
290 throw new Exception("Syntax must start with '{': {$token['pos']}");
291 $token = $tokens[$i];
292 while ($i < count($tokens) && $token['type'] == EBNF_IDENTIFIER_TOKEN) {
294 if ($i<count($tokens)) $token = $tokens[$i];
295 } $i++; if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '}'))
298 $token = $tokens[$i];
299 if ($token['type'] == EBNF_LITERAL_TOKEN) {
301 stripcslashes(substr($token['value'], 1, strlen($token['value'])-2 )));
308 $token = $tokens[$i++];
309 if ($token['type']!=EBNF_IDENTIFIER_TOKEN)
310 throw new Exception("Production must start with an identifier'{': {$token['pos']}");
312 $production->setAttribute('name', $token['value']);
313 $token = $tokens[$i++];
314 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, "="))
315 throw new Exception("Identifier must be followed by '=': {$token['pos']}");
317 $token = $tokens[$i++];
318 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '.')
319 && !ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ';'))
320 throw new Exception("Rule must end with '.' or ';' : {$token['pos']}");
327 $token=$tokens[$i]; $mul = false;
328 while (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '|')) {
331 $token=$tokens[$i]; $mul = true;
339 $token=$tokens[$i]; $mul = false;
340 while ($token['value']!='.' && $token['value']!='=' && $token['value']!='|'
341 && $token['value']!=')' && $token['value']!=']' && $token['value']!='}') {
343 $token=$tokens[$i]; $mul = true;
348 $token = $tokens[$i++];
349 if ($token['type']==EBNF_IDENTIFIER_TOKEN) {
351 $identifier->setAttribute('value', $token['value']);
353 } if ($token['type']==EBNF_LITERAL_TOKEN){
355 $literal->setAttribute('value', stripcslashes(substr($token['value'], 1, strlen($token['value'])-2 )));
357 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '(')) {
359 $token = $tokens[$i++];
360 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ')'))
361 throw new Exception("Group must end with ')': {$token['pos']}");
363 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '[')) {
366 $token = $tokens[$i++];
367 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ']'))
368 throw new Exception("Option must end with ']': {$token['pos']}");
370 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '{')) {
373 $token = $tokens[$i++];
374 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '}'))
375 throw new Exception("Loop must end with '}': {$token['pos']}");
378 throw new Exception("Factor expected: {$token['pos']}");