rework everything; add emacs output mode
[php-sqllint.git] / src / phpsqllint / Renderer / Emacs.php
1 <?php
2 /**
3  * Part of php-sqllint
4  *
5  * PHP version 5
6  *
7  * @category Tools
8  * @package  PHP-SQLlint
9  * @author   Christian Weiske <cweiske@cweiske.de>
10  * @license  http://www.gnu.org/licenses/agpl.html GNU AGPL v3
11  * @link     http://cweiske.de/php-sqllint.htm
12  */
13 namespace phpsqllint;
14
15 /**
16  * Output for emacs' compilation mode
17  *
18  * @category Tools
19  * @package  PHP-SQLlint
20  * @author   Christian Weiske <cweiske@cweiske.de>
21  * @license  http://www.gnu.org/licenses/agpl.html GNU AGPL v3
22  * @link     http://www.emacswiki.org/emacs/CreatingYourOwnCompileErrorRegexp
23  */
24 class Renderer_Emacs implements Renderer
25 {
26     protected $filename;
27
28     /**
29      * Begin syntax check output rendering
30      *
31      * @param string $filename Path to the SQL file
32      *
33      * @return void
34      */
35     public function startRendering($filename)
36     {
37         $this->filename = $filename;
38     }
39
40     /**
41      * Output errors in GNU style; see emacs compilation.txt
42      *
43      * @param string  $msg   Error message
44      * @param string  $token Character which caused the error
45      * @param integer $line  Line at which the error occured
46      * @param integer $col   Column at which the error occured
47      *
48      * @return void
49      */
50     public function displayError($msg, $token, $line, $col)
51     {
52         echo $this->filename
53             . ':' . $line
54             . '.' . $col
55             . ':Error:'
56             . ' '. $msg
57             . "\n";
58     }
59
60     /**
61      * Finish syntax check output rendering; no syntax errors found
62      *
63      * @return void
64      */
65     public function finishOk()
66     {
67         //do nothing
68     }
69 }
70 ?>