diff --git a/doc/grammars/const-expr.peg b/doc/grammars/const-expr.peg index f5b0a0a..cd98456 100644 --- a/doc/grammars/const-expr.peg +++ b/doc/grammars/const-expr.peg @@ -9,15 +9,15 @@ ConstantExpr / ConstantFetch ConstantFloat - = [0-9]+ '.' [0-9]* ConstantFloatExp? - / [0-9]* '.' [0-9]+ ConstantFloatExp? - / [0-9]+ ConstantFloatExp + = '-'? [0-9]+ '.' [0-9]* ConstantFloatExp? + / '-'? [0-9]* '.' [0-9]+ ConstantFloatExp? + / '-'? [0-9]+ ConstantFloatExp ConstantFloatExp - = [eE] [0-9]+ + = [eE] '-'? [0-9]+ ConstantInt - = [0-9]+ + = '-'? [0-9]+ ConstantTrue = [tT][rR][uU][eE] diff --git a/src/Lexer/Lexer.php b/src/Lexer/Lexer.php index 701a049..8ba3ef6 100644 --- a/src/Lexer/Lexer.php +++ b/src/Lexer/Lexer.php @@ -131,8 +131,8 @@ class Lexer self::TOKEN_CLOSE_PHPDOC => '\\*/', self::TOKEN_PHPDOC_TAG => '@[a-z-]++', - self::TOKEN_FLOAT => '(?:[0-9]++\\.[0-9]*+(?:e[0-9]++)?)|(?:[0-9]*+\\.[0-9]++(?:e[0-9]++)?)|(?:[0-9]++e[0-9]++)', - self::TOKEN_INTEGER => '[0-9]++', + self::TOKEN_FLOAT => '(?:-?[0-9]++\\.[0-9]*+(?:e-?[0-9]++)?)|(?:-?[0-9]*+\\.[0-9]++(?:e-?[0-9]++)?)|(?:-?[0-9]++e-?[0-9]++)', + self::TOKEN_INTEGER => '-?[0-9]++', self::TOKEN_SINGLE_QUOTED_STRING => '\'(?:\\\\.|[^\'])*+\'', self::TOKEN_DOUBLE_QUOTED_STRING => '"(?:\\\\.|[^"])*+"',