Changeset 488
- Timestamp:
- 04/12/07 23:52:39 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationAnnotationState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationNameState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamValueState.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamsState.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationAnnotationState.php
r454 r488 26 26 public function process($token) 27 27 { 28 switch ($token) { 29 case "\n": 30 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 31 break; 32 33 case '[': 34 $this->parser->changeState(stubAnnotationState::ANNOTATION_TYPE); 35 break; 36 37 case '(': 38 $this->parser->changeState(stubAnnotationState::PARAMS); 39 break; 28 if ("\n" === $token) { 29 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 30 return; 31 } 32 33 if ('[' === $token) { 34 $this->parser->changeState(stubAnnotationState::ANNOTATION_TYPE); 35 return; 36 } 37 38 if ('(' === $token) { 39 $this->parser->changeState(stubAnnotationState::PARAMS); 40 return; 40 41 } 41 42 } trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationNameState.php
r454 r488 53 53 public function process($token) 54 54 { 55 switch ($token) { 56 case ' ': 57 if (strlen($this->name) == 0) { 58 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 59 break; 60 } 61 55 if (' ' === $token) { 56 if (strlen($this->name) == 0) { 57 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 58 return; 59 } 60 61 $this->parser->registerAnnotation($this->name); 62 $this->parser->changeState(stubAnnotationState::ANNOTATION); 63 return; 64 } 65 66 if ("\n" === $token) { 67 if (strlen($this->name) > 0) { 62 68 $this->parser->registerAnnotation($this->name); 63 $this->parser->changeState(stubAnnotationState::ANNOTATION); 64 break; 69 } 65 70 66 case "\n": 67 if (strlen($this->name) > 0) { 68 $this->parser->registerAnnotation($this->name); 69 } 70 71 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 72 break; 71 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 72 return; 73 } 74 75 if ('[' === $token) { 76 if (strlen($this->name) == 0) { 77 throw new ReflectionException('Annotation name can not be empty'); 78 } 73 79 74 case '[': 75 if (strlen($this->name) == 0) { 76 throw new ReflectionException('Annotation name can not be empty'); 77 } 78 79 $this->parser->registerAnnotation($this->name); 80 $this->parser->changeState(stubAnnotationState::ANNOTATION_TYPE); 81 break; 80 $this->parser->registerAnnotation($this->name); 81 $this->parser->changeState(stubAnnotationState::ANNOTATION_TYPE); 82 return; 83 } 84 85 if ('(' === $token) { 86 if (strlen($this->name) == 0) { 87 throw new ReflectionException('Annotation name can not be empty'); 88 } 82 89 83 case '(': 84 if (strlen($this->name) == 0) { 85 throw new ReflectionException('Annotation name can not be empty'); 86 } 87 88 $this->parser->registerAnnotation($this->name); 89 $this->parser->changeState(stubAnnotationState::PARAMS); 90 break; 91 92 default: 93 if (strlen($this->name) == 0 && preg_match('/^[a-zA-Z_]$/', $token) == false) { 94 throw new ReflectionException('Annotation name has to start with a letter or underscore, but starts with ' . $token); 95 } elseif (preg_match('/^[a-zA-Z_0-9]$/', $token) == false) { 96 throw new ReflectionException('Annotation name may contain letters, underscores and numbers, but contains ' . $token); 97 } 98 99 $this->name .= $token; 90 $this->parser->registerAnnotation($this->name); 91 $this->parser->changeState(stubAnnotationState::PARAMS); 92 return; 100 93 } 94 95 if (strlen($this->name) == 0 && preg_match('/^[a-zA-Z_]$/', $token) == false) { 96 throw new ReflectionException('Annotation name has to start with a letter or underscore, but starts with ' . $token); 97 } elseif (preg_match('/^[a-zA-Z_0-9]$/', $token) == false) { 98 throw new ReflectionException('Annotation name may contain letters, underscores and numbers, but contains ' . $token); 99 } 100 101 $this->name .= $token; 101 102 } 102 103 } trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamNameState.php
r455 r488 53 53 public function process($token) 54 54 { 55 switch ($token) { 56 case "'": 57 case '"': 58 if (strlen($this->name) > 0) { 59 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains ' . $token . '. Probably an equal sign is missing.'); 60 } 61 62 $this->parser->registerAnnotationParam('value'); 63 $this->parser->changeState(stubAnnotationState::PARAM_VALUE, $token); 64 break; 55 if ("'" === $token || '"' === $token) { 56 if (strlen($this->name) > 0) { 57 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains ' . $token . '. Probably an equal sign is missing.'); 58 } 65 59 66 case '=': 67 if (strlen($this->name) == 0) { 68 throw new ReflectionException('Annotation parameter name has to start with a letter or underscore, but starts with ='); 69 } elseif (preg_match('/^[a-zA-Z_]{1}[a-zA-Z_0-9]*$/', $this->name) == false) { 70 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains an invalid character.'); 71 } 72 73 $this->parser->registerAnnotationParam($this->name); 74 $this->parser->changeState(stubAnnotationState::PARAM_VALUE); 75 break; 60 $this->parser->registerAnnotationParam('value'); 61 $this->parser->changeState(stubAnnotationState::PARAM_VALUE, $token); 62 return; 63 } 64 65 if ('=' === $token) { 66 if (strlen($this->name) == 0) { 67 throw new ReflectionException('Annotation parameter name has to start with a letter or underscore, but starts with ='); 68 } elseif (preg_match('/^[a-zA-Z_]{1}[a-zA-Z_0-9]*$/', $this->name) == false) { 69 throw new ReflectionException('Annotation parameter name may contain letters, underscores and numbers, but contains an invalid character.'); 70 } 76 71 77 case ')': 78 if (strlen($this->name) > 0) { 79 $this->parser->registerSingleAnnotationParam($this->name, false); 80 } 81 82 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 83 break; 84 85 default: 86 $this->name .= $token; 72 $this->parser->registerAnnotationParam($this->name); 73 $this->parser->changeState(stubAnnotationState::PARAM_VALUE); 74 return; 87 75 } 76 77 if (')' === $token) { 78 if (strlen($this->name) > 0) { 79 $this->parser->registerSingleAnnotationParam($this->name, false); 80 } 81 82 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 83 return; 84 } 85 86 $this->name .= $token; 88 87 } 89 88 } trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamValueState.php
r454 r488 110 110 111 111 if (null === $this->enclosed) { 112 switch ($token) { 113 case "'": 114 case '"': 115 if (strlen($this->value) > 0) { 116 $this->value .= $token; 117 } else { 118 $this->enclosed = $token; 119 $this->isString = true; 120 } 121 122 return; 112 if ("'" === $token || '"' === $token) { 113 if (strlen($this->value) > 0) { 114 $this->value .= $token; 115 } else { 116 $this->enclosed = $token; 117 $this->isString = true; 118 } 123 119 124 case ',': 125 $this->parser->setAnnotationParamValue($this->value, $this->isString); 126 $this->parser->changeState(stubAnnotationState::PARAMS); 127 return; 128 129 case ')': 130 $this->parser->setAnnotationParamValue($this->value, $this->isString); 131 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 132 return; 120 return; 133 121 } 134 } else { 135 switch ($token) { 136 case $this->enclosed: 137 $this->enclosed = null; 138 $this->parser->setAnnotationParamValue($this->value, $this->isString); 139 $this->parser->changeState(stubAnnotationState::PARAMS); 140 return; 141 142 case '\\': 143 $this->escapeNext = true; 144 return; 122 123 if (',' === $token) { 124 $this->parser->setAnnotationParamValue($this->value, $this->isString); 125 $this->parser->changeState(stubAnnotationState::PARAMS); 126 return; 127 } 128 129 if (')' === $token) { 130 $this->parser->setAnnotationParamValue($this->value, $this->isString); 131 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 132 return; 133 } 134 } else { 135 if ($this->enclosed === $token) { 136 $this->enclosed = null; 137 $this->parser->setAnnotationParamValue($this->value, $this->isString); 138 $this->parser->changeState(stubAnnotationState::PARAMS); 139 return; 140 } 141 142 if ('\\' === $token) { 143 $this->escapeNext = true; 144 return; 145 145 } 146 146 } trunk/src/main/php/net/stubbles/reflection/annotations/parser/state/stubAnnotationParamsState.php
r454 r488 20 20 { 21 21 /** 22 * list of tokens that lead to no actions in this state 23 * 24 * @var array<string> 25 */ 26 protected $doNothingTokens = array(',', ' ', "\n", "\t", '*'); 27 28 /** 22 29 * processes a token 23 30 * … … 26 33 public function process($token) 27 34 { 28 switch ($token) { 29 case ')': 30 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 31 break; 32 33 case ',': 34 case ' ': 35 case "\n": 36 case "\t": 37 case '*': 38 break; 39 40 default: 41 $this->parser->changeState(stubAnnotationState::PARAM_NAME, $token); 35 if (')' === $token) { 36 $this->parser->changeState(stubAnnotationState::DOCBLOCK); 37 return; 42 38 } 39 40 if (in_array($token, $this->doNothingTokens) == true) { 41 return; 42 } 43 44 $this->parser->changeState(stubAnnotationState::PARAM_NAME, $token); 43 45 } 44 46 }
