BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 <?php
2  
3  
4  
5 abstract class flex_scanner {
6 /*
7 Let's face it: PHP is not up to lexical processing. GNU flex handles
8 it well, so I've created a little protocol for delegating the work.
9 Extend this class so that executable() gives a path to your lexical
10 analyser program.
11 */
12 abstract function executable();
13 function __construct($path) {
14 if (!is_readable($path)) throw new Exception("$path is not readable.");
15 putenv("PHP_LIME_SCAN_STDIN=$path");
16 $scanner = $this->executable();
17 $tokens = explode("\0", `$scanner < "\$PHP_LIME_SCAN_STDIN"`);
18 array_pop($tokens);
19 $this->tokens = $tokens;
20 $this->lineno = 1;
21 }
22 function next() {
23 if (list($key, $token) = each($this->tokens)) {
24 list($this->lineno, $type, $text) = explode("\1", $token);
25 return array($type, $text);
26 }
27 }
28 function feed($parser) {
29 while (list($type, $text) = $this->next()) {
30 $parser->eat($type, $text);
31 }
32 return $parser->eat_eof();
33 }
34 }