Lines Matching refs:token
277 throw new EbnfException("Invalid token at position", $i);
282 function ebnf_check_token($token, $type, $value) { argument
283 return $token['type']==$type && $token['value']==$value;
291 $i = 0; $token = $tokens[$i++];
292 if ($token['type'] == EBNF_LITERAL_TOKEN) {
294 stripcslashes(substr($token['value'], 1, strlen($token['value'])-2 )));
295 $token = $tokens[$i++];
297 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '{') )
298 throw new EbnfException("Syntax must start with '{'", $token['pos']);
299 $token = $tokens[$i];
300 while ($i < count($tokens) && $token['type'] == EBNF_IDENTIFIER_TOKEN) {
302 if ($i<count($tokens)) $token = $tokens[$i];
303 } $i++; if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '}'))
306 $token = $tokens[$i];
307 if ($token['type'] == EBNF_LITERAL_TOKEN) {
309 stripcslashes(substr($token['value'], 1, strlen($token['value'])-2 )));
316 $token = $tokens[$i++];
317 if ($token['type']!=EBNF_IDENTIFIER_TOKEN)
318 throw new EbnfException("Production must start with an identifier'{'", $token['pos']);
320 $production->setAttribute('name', $token['value']);
321 $token = $tokens[$i++];
322 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, "="))
323 throw new EbnfException("Identifier must be followed by '='", $token['pos']);
325 $token = $tokens[$i++];
326 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '.')
327 && !ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ';'))
328 throw new EbnfException("Rule must end with '.' or ';'", $token['pos']);
335 $token=$tokens[$i]; $mul = false;
336 while (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '|')) {
339 $token=$tokens[$i]; $mul = true;
347 $token=$tokens[$i]; $mul = false;
348 while ($token['value']!='.' && $token['value']!='=' && $token['value']!='|'
349 && $token['value']!=')' && $token['value']!=']' && $token['value']!='}') {
351 $token=$tokens[$i]; $mul = true;
356 $token = $tokens[$i++];
357 if ($token['type']==EBNF_IDENTIFIER_TOKEN) {
359 $identifier->setAttribute('value', $token['value']);
361 } if ($token['type']==EBNF_LITERAL_TOKEN){
363 …$literal->setAttribute('value', stripcslashes(substr($token['value'], 1, strlen($token['value'])-2…
365 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '(')) {
367 $token = $tokens[$i++];
368 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ')'))
369 throw new EbnfException("Group must end with ')'", $token['pos']);
371 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '[')) {
374 $token = $tokens[$i++];
375 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, ']'))
376 throw new EbnfException("Option must end with ']'", $token['pos']);
378 } if (ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '{')) {
381 $token = $tokens[$i++];
382 if (!ebnf_check_token($token, EBNF_OPERATOR_TOKEN, '}'))
383 throw new EbnfException("Loop must end with '}'", $token['pos']);
386 throw new EbnfException("Factor expected", $token['pos']);