66
77class ParseException extends \LogicException implements ParserExceptionInterface
88{
9- final public const CODE_UNEXPECTED_TOKEN = 0x01 ;
9+ final public const ERROR_CODE_UNEXPECTED_TOKEN = 0x01 ;
1010
11- final public const CODE_UNRECOGNIZED_TOKEN = 0x02 ;
11+ final public const ERROR_CODE_UNRECOGNIZED_TOKEN = 0x02 ;
1212
13- final public const CODE_UNEXPECTED_SYNTAX_ERROR = 0x03 ;
13+ final public const ERROR_CODE_UNEXPECTED_SYNTAX_ERROR = 0x03 ;
1414
15- final public const CODE_INTERNAL_ERROR = 0x05 ;
15+ final public const ERROR_CODE_INTERNAL_ERROR = 0x05 ;
1616
17- final public const CODE_SEMANTIC_ERROR_BASE = 0x06 ;
17+ final public const ERROR_CODE_SEMANTIC_ERROR_BASE = 0x06 ;
1818
19- public const CODE_LAST = self ::CODE_SEMANTIC_ERROR_BASE + SemanticException:: CODE_LAST ;
19+ protected const CODE_LAST = self ::ERROR_CODE_SEMANTIC_ERROR_BASE ;
2020
2121 final public function __construct (string $ message , int $ code = 0 , ?\Throwable $ previous = null )
2222 {
@@ -37,7 +37,7 @@ public static function fromUnexpectedToken(string $char, string $statement, int
3737 Formatter::suffix ($ statement , $ offset ),
3838 ]);
3939
40- return new static ($ message , self ::CODE_UNEXPECTED_TOKEN );
40+ return new static ($ message , self ::ERROR_CODE_UNEXPECTED_TOKEN );
4141 }
4242
4343 /**
@@ -53,7 +53,7 @@ public static function fromUnrecognizedToken(string $token, string $statement, i
5353 Formatter::suffix ($ statement , $ offset ),
5454 ]);
5555
56- return new static ($ message , self ::CODE_UNRECOGNIZED_TOKEN );
56+ return new static ($ message , self ::ERROR_CODE_UNRECOGNIZED_TOKEN );
5757 }
5858
5959 /**
@@ -66,28 +66,28 @@ public static function fromUnrecognizedSyntaxError(string $statement, int $offse
6666 Formatter::suffix ($ statement , $ offset ),
6767 ]);
6868
69- return new static ($ message , self ::CODE_UNEXPECTED_SYNTAX_ERROR );
69+ return new static ($ message , self ::ERROR_CODE_UNEXPECTED_SYNTAX_ERROR );
7070 }
7171
7272 /**
7373 * @param int<0, max> $offset
7474 */
7575 public static function fromSemanticError (string $ message , string $ statement , int $ offset , int $ code = 0 ): static
7676 {
77- $ message = \vsprintf ('Semantic error, %s in %s %s ' , [
78- \lcfirst ($ message ),
77+ $ message = \vsprintf ('%s in %s %s ' , [
78+ \ucfirst ($ message ),
7979 Formatter::source ($ statement ),
8080 Formatter::suffix ($ statement , $ offset ),
8181 ]);
8282
83- return new static ($ message , self ::CODE_SEMANTIC_ERROR_BASE + $ code );
83+ return new static ($ message , self ::ERROR_CODE_SEMANTIC_ERROR_BASE + $ code );
8484 }
8585
8686 public static function fromInternalError (string $ statement , \Throwable $ e ): static
8787 {
8888 $ message = "An internal error occurred while parsing %s " ;
8989 $ message = \sprintf ($ message , Formatter::source ($ statement ));
9090
91- return new static ($ message , self ::CODE_INTERNAL_ERROR , $ e );
91+ return new static ($ message , self ::ERROR_CODE_INTERNAL_ERROR , $ e );
9292 }
9393}
0 commit comments