1 | <?php |
||
16 | class Lexer |
||
17 | { |
||
18 | private static $CONDITON = 0; |
||
19 | private static $VALUE = 1; |
||
20 | |||
21 | 175 | public function readString($string) |
|
29 | |||
30 | 174 | private function readForm(Reader $reader) |
|
31 | { |
||
32 | 174 | switch ($reader->peek()) { |
|
33 | 174 | case '(': |
|
34 | 154 | $reader->next(); |
|
35 | 154 | $collection = new ListType(); |
|
36 | 154 | return $this->readCollection($reader, $collection, ')'); |
|
37 | 174 | case ')': |
|
38 | 1 | throw new Exception('Unexpected )'); |
|
39 | 173 | case '[': |
|
40 | 27 | $reader->next(); |
|
41 | 27 | $collection = new VectorType(); |
|
42 | 27 | return $this->readCollection($reader, $collection, ']'); |
|
43 | 173 | case ']': |
|
44 | 1 | throw new Exception('Unexpected ]'); |
|
45 | 172 | case '{': |
|
46 | 22 | $reader->next(); |
|
47 | 22 | $hash = new HashType(); |
|
48 | 22 | return $this->readHash($reader, $hash); |
|
49 | 172 | case '}': |
|
50 | 2 | throw new Exception('Unexpected }'); |
|
51 | default: |
||
52 | 171 | $form = $this->readAtom($reader->peek()); |
|
53 | 171 | $reader->next(); |
|
54 | 171 | return $form; |
|
55 | } |
||
56 | } |
||
57 | |||
58 | 157 | private function readCollection(Reader $reader, $collection, $end) |
|
69 | |||
70 | 22 | private function readHash(Reader $reader, $hash) |
|
87 | |||
88 | 171 | private function readAtom($token) |
|
99 | |||
100 | 171 | private function tokenTestList($token) |
|
111 | } |
||
112 |