On 1/25/13 5:31 PM, Victor Efimov via RT wrote:
Show quoted text> I have something like
>
> my $data = 'file content';
> my ($pos_start, $pos_end) = (0, length($data)-1);
>
> obviously "-1" should be allowed here.
"-1" is not an allowed value, purposely.
On the other hand, subtracting "1" is allowed.
Put a space between the minus and the digit and PPI will parse the two separately.
Show quoted text> ppidump '(0, length($data)-1);'
PPI::Document
PPI::Statement
PPI::Structure::List ( ... )
PPI::Statement::Expression
[ 1, 2, 2 ] PPI::Token::Number '0'
[ 1, 3, 3 ] PPI::Token::Operator ','
[ 1, 5, 5 ] PPI::Token::Word 'length'
PPI::Structure::List ( ... )
PPI::Statement::Expression
[ 1, 12, 12 ] PPI::Token::Symbol '$data'
[ 1, 18, 18 ] PPI::Token::Number '-1'
[ 1, 21, 21 ] PPI::Token::Structure ';'
Show quoted text> ppidump '(0, length($data) - 1);'
PPI::Document
PPI::Statement
PPI::Structure::List ( ... )
PPI::Statement::Expression
[ 1, 2, 2 ] PPI::Token::Number '0'
[ 1, 3, 3 ] PPI::Token::Operator ','
[ 1, 5, 5 ] PPI::Token::Word 'length'
PPI::Structure::List ( ... )
PPI::Statement::Expression
[ 1, 12, 12 ] PPI::Token::Symbol '$data'
[ 1, 18, 18 ] PPI::Token::Operator '-'
[ 1, 20, 20 ] PPI::Token::Number '1'
[ 1, 22, 22 ] PPI::Token::Structure ';'