Exemplo n.º 1
0
 function parse($input)
 {
     if (!self::$tokenizer) {
         self::$tokenizer = new NTokenizer(self::$patterns, 'mi');
     }
     $input = str_replace("\r", '', $input);
     $input = strtr($input, "\t", ' ');
     $input = "\n" . $input . "\n";
     self::$tokenizer->tokenize($input);
     $this->n = 0;
     $res = $this->_parse();
     while (isset(self::$tokenizer->tokens[$this->n])) {
         if (self::$tokenizer->tokens[$this->n][0] === "\n") {
             $this->n++;
         } else {
             $this->error();
         }
     }
     return $res;
 }
Exemplo n.º 2
0
Arquivo: loader.php Projeto: GE3/GE3
 private function tokenize($s)
 {
     if (!self::$regexp) {
         self::$regexp = '~' . implode('|', self::$patterns) . '~mA';
     }
     $s = str_replace("\r", '', $s);
     $s = strtr($s, "\t", ' ');
     $s = "\n" . $s . "\n";
     $this->input = $s;
     $this->tokens = NString::split($s, self::$regexp, PREG_SPLIT_NO_EMPTY);
     if (end($this->tokens) !== "\n") {
         $this->n = key($this->tokens);
         $this->error();
     }
 }