Subversion Repositories fastphp

Rev

Rev 28 | Rev 31 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 29
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
-
 
3
// TODO: Parsing der Datei codeexplorer.php bricht einfach so ab?
-
 
4
 
3
define('ICON_ATTR_PUBLIC',           1);
5
define('ICON_ATTR_PUBLIC',           1);
4
define('ICON_ATTR_PRIVATE',          2);
6
define('ICON_ATTR_PRIVATE',          2);
5
define('ICON_ATTR_PROTECTED',        4);
7
define('ICON_ATTR_PROTECTED',        4);
6
define('ICON_ATTR_ABSTRACT',         8);
8
define('ICON_ATTR_ABSTRACT',         8);
7
define('ICON_ATTR_STATIC',          16);
9
define('ICON_ATTR_STATIC',          16);
Line 32... Line 34...
32
        $x = token_get_all($code);
34
        $x = token_get_all($code);
33
       
35
       
34
        // file_put_contents('debug.tmp', $code);
36
        // file_put_contents('debug.tmp', $code);
35
       
37
       
36
        if (!$x) {
38
        if (!$x) {
37
                // TODO: when this happen, do not update the output in the editor...
39
                // TODO: when this happens, do not update the output in the editor...
38
                echo _outputLeafNode(2048, 1, 'SYNTAX ERROR');
40
                echo _outputLeafNode(2048, 1, 'SYNTAX ERROR');
39
        }
41
        }
40
       
42
       
41
        //print_r($x); // debug
43
        //print_r($x); // debug
42
        $wait_function = false;
44
        $wait_function = false;
43
        $wait_class = false;
45
        $wait_class = false;
44
        $class = array();
46
        $class = array();
45
        $qualifiers = array();
47
        $icon_add_flags = 0;
46
        $dep = 0;
48
        $dep = 0;
47
 
49
 
48
        foreach ($x as $n => $data) {
50
        foreach ($x as $n => $data) {
49
                if ($data == '{') $dep++;
51
                if ($data == '{') $dep++;
50
                if ($data == '}') {
52
                if ($data == '}') {
51
                        $dep--;
53
                        $dep--;
52
                        if ((count($class) > 0) && (array_peek($class)[1] == $dep)) array_pop($class);
54
                        if ((count($class) > 0) && (array_peek($class)[1] == $dep)) {
-
 
55
                                array_pop($class);
-
 
56
                                echo _outputDecreaseLevel();
-
 
57
                        }
53
                }
58
                }
54
 
59
 
55
                $token = $data[0];
60
                $token = (!is_array($data)) ? null : $data[0];
56
                $value = $data[1];
61
                $value = (!is_array($data)) ? null : $data[1];
57
                $line = $data[2];
62
                $line = (!is_array($data)) ? null : $data[2];
58
 
63
 
59
                if ($wait_function && ($token == T_STRING)) {
64
                if ($wait_function && ($token == T_STRING)) {
60
                        $desc = "$line: Method ";
65
                        $desc = "function ";
-
 
66
                        /*
61
                        foreach ($class as $cdata) {
67
                        foreach ($class as $cdata) {
62
                                $desc .= $cdata[0].'->';
68
                                $desc .= $cdata[0].'->';
63
                        }
69
                        }
-
 
70
                        */
64
                        $desc .= "$value() ";
71
                        $desc .= "$value()";
65
                        $desc .= implode(' ', $qualifiers);
-
 
66
                        $qualifiers = array();
72
                        $icon_add_flags = 0;
67
                        $wait_function = false;
73
                        $wait_function = false;
68
                       
74
 
-
 
75
                        if ($value == '__construct') { // TODO: auch eine methode mit dem namen der klasse soll eine konstruktor sein
-
 
76
                                echo _outputLeafNode(ICON_ATTR_CONSTRUCTOR | $icon_add_flags, $line, $desc);
-
 
77
                        } else if ($value == '__destruct') {
69
                        echo _outputLeafNode(0/*TODO*/, $line, $desc);
78
                                echo _outputLeafNode(ICON_ATTR_DESTRUCTOR  | $icon_add_flags, $line, $desc);
-
 
79
                        } else if (substr($value, 0, 2) == '__') {
-
 
80
                                echo _outputLeafNode(ICON_ATTR_MAGICMETHOD | $icon_add_flags, $line, $desc);
-
 
81
                        } else {
-
 
82
                                echo _outputLeafNode(ICON_ATTR_FUNCTION    | $icon_add_flags, $line, $desc);
-
 
83
                        }
70
                }
84
                }
71
 
85
 
72
                if ($wait_class && ($token == T_STRING)) {
86
                if ($wait_class && ($token == T_STRING)) {
73
                        $desc = "$line: Class ";
87
                        $desc = "Class ";
-
 
88
                        /*
74
                        foreach ($class as $cdata) {
89
                        foreach ($class as $cdata) {
75
                                $desc .= $cdata[0].'->';
90
                                $desc .= $cdata[0].'->';
76
                        }
91
                        }
-
 
92
                        */
77
                        $desc .= "$value\n";           
93
                        $desc .= "$value\n";
78
                        $class[] = array($value, $dep);
94
                        $class[] = array($value, $dep);
79
                        $wait_class = false;
95
                        $wait_class = false;
80
 
96
 
81
                        echo _outputLeafNode(0/*TODO*/, $line, $desc);
97
                        echo _outputLeafNode(ICON_ATTR_CLASS | $icon_add_flags, $line, $desc);
-
 
98
                        echo _outputIncreaseLevel();
82
                }
99
                }
83
 
100
 
84
                if ($token == T_PUBLIC) $qualifiers[] = '(Pub)';
101
                if ($token == T_PUBLIC)    $icon_add_flags |= ICON_ATTR_PUBLIC;
85
                if ($token == T_PRIVATE) $qualifiers[] = '(Priv)';
102
                if ($token == T_PRIVATE)   $icon_add_flags |= ICON_ATTR_PRIVATE;
86
                if ($token == T_PROTECTED) $qualifiers[] = '(Prot)';
103
                if ($token == T_PROTECTED) $icon_add_flags |= ICON_ATTR_PROTECTED;
87
                if ($token == T_STATIC) $qualifiers[] = '(S)';
104
                if ($token == T_STATIC)    $icon_add_flags |= ICON_ATTR_STATIC;
88
                if (($data == ';') || ($data == '{') || ($data == '}')) $qualifiers = array();
105
                if (($data == ';') || ($data == '{') || ($data == '}')) $icon_add_flags = 0;
89
 
106
 
90
                if ($token == T_FUNCTION) {
107
                if ($token == T_FUNCTION) {
91
                        $wait_function = true;
108
                        $wait_function = true;
92
                }
109
                }
93
                if ($token == T_CLASS) {
110
                if ($token == T_CLASS) {
Line 101... Line 118...
101
                        }
118
                        }
102
                }
119
                }
103
        }
120
        }
104
       
121
       
105
        echo _outputExit();
122
        echo _outputExit();
-
 
123
 
106
        echo chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8);
124
        echo chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8);
107
 
125
 
108
        sleep(1);
126
        sleep(1);
109
}
127
}
110
 
128
 
Line 132... Line 150...
132
        if (!isset($array[count($array)-1])) return null;
150
        if (!isset($array[count($array)-1])) return null;
133
        return $array[count($array)-1];
151
        return $array[count($array)-1];
134
}
152
}
135
 
153
 
136
function strip_comment($x) {
154
function strip_comment($x) {
-
 
155
        if (substr($x, 0, 1) == '#') return trim(substr($x, 1));
137
        if (substr($x, 0, 2) == '//') return trim(substr($x, 2));
156
        if (substr($x, 0, 2) == '//') return trim(substr($x, 2));
138
        if (substr($x, 0, 2) == '/*') return trim(substr($x, 2, strlen($x)-4));
157
        if (substr($x, 0, 2) == '/*') return trim(substr($x, 2, strlen($x)-4));
139
}
158
}
-
 
159
 
-
 
160
 
-
 
161
// TODO: hallo
-
 
162
# TODO: xxx