support negative numbers

This commit is contained in:
Jan Tvrdik 2017-11-17 10:12:33 +01:00
parent 523d45b7ef
commit d973733eee
2 changed files with 7 additions and 7 deletions

View File

@ -9,15 +9,15 @@ ConstantExpr
/ ConstantFetch / ConstantFetch
ConstantFloat ConstantFloat
= [0-9]+ '.' [0-9]* ConstantFloatExp? = '-'? [0-9]+ '.' [0-9]* ConstantFloatExp?
/ [0-9]* '.' [0-9]+ ConstantFloatExp? / '-'? [0-9]* '.' [0-9]+ ConstantFloatExp?
/ [0-9]+ ConstantFloatExp / '-'? [0-9]+ ConstantFloatExp
ConstantFloatExp ConstantFloatExp
= [eE] [0-9]+ = [eE] '-'? [0-9]+
ConstantInt ConstantInt
= [0-9]+ = '-'? [0-9]+
ConstantTrue ConstantTrue
= [tT][rR][uU][eE] = [tT][rR][uU][eE]

View File

@ -131,8 +131,8 @@ class Lexer
self::TOKEN_CLOSE_PHPDOC => '\\*/', self::TOKEN_CLOSE_PHPDOC => '\\*/',
self::TOKEN_PHPDOC_TAG => '@[a-z-]++', 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_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_INTEGER => '-?[0-9]++',
self::TOKEN_SINGLE_QUOTED_STRING => '\'(?:\\\\.|[^\'])*+\'', self::TOKEN_SINGLE_QUOTED_STRING => '\'(?:\\\\.|[^\'])*+\'',
self::TOKEN_DOUBLE_QUOTED_STRING => '"(?:\\\\.|[^"])*+"', self::TOKEN_DOUBLE_QUOTED_STRING => '"(?:\\\\.|[^"])*+"',