From bf9eec6b2365f82333dffa385a9105c3825d1921 Mon Sep 17 00:00:00 2001 From: Adam Jimenez Date: Mon, 2 Jun 2014 23:26:59 +0100 Subject: [PATCH 1/3] fix "{$foo->bar}"."{$foo->bar($a)}"."{$foo->bar(&$a, $b)}"; --- lib/ace/mode/php/php.js | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/ace/mode/php/php.js b/lib/ace/mode/php/php.js index ed23f641..74af47c2 100644 --- a/lib/ace/mode/php/php.js +++ b/lib/ace/mode/php/php.js @@ -717,34 +717,52 @@ PHP.Lexer = function( src, ini ) { var re; if ( curlyOpen > 0) { - re = /^([^\\\$"{}\]\)]|\\.)+/g; + re = /^([^\\\$"{}\]\)\->]|\\.)+/g; } else { re = /^([^\\\$"{]|\\.|{[^\$]|\$(?=[^a-zA-Z_\x7f-\uffff]))+/g;; } + var type, match2; while(( match = result.match( re )) !== null ) { - - if (result.length === 1) { throw new Error(match); } + + type = 0; - - - results.push([ - parseInt(( curlyOpen > 0 ) ? PHP.Constants.T_CONSTANT_ENCAPSED_STRING : PHP.Constants.T_ENCAPSED_AND_WHITESPACE, 10), - match[ 0 ].replace(/\n/g,"\\n").replace(/\r/g,""), - line - ]); + if( curlyOpen > 0 ){ + if( match2 = match[0].match(/^[\[\]\;\:\?\(\)\!\.\,\>\<\=\+\-\/\*\|\&\{\}\@\^\%\"\'\$\~]/) ){ + results.push(match2[0]); + }else{ + type = PHP.Constants.T_STRING; + } + }else{ + type = PHP.Constants.T_ENCAPSED_AND_WHITESPACE; + } + + if( type ){ + results.push([ + parseInt(type, 10), + match[ 0 ].replace(/\n/g,"\\n").replace(/\r/g,""), + line + ]); + } line += match[ 0 ].split('\n').length - 1; result = result.substring( match[ 0 ].length ); + } + if( curlyOpen > 0 && result.match(/^\->/) !== null ) { + results.push([ + parseInt(PHP.Constants.T_OBJECT_OPERATOR, 10), + '->', + line + ]); + result = result.substring( 2 ); } if( result.match(/^{\$/) !== null ) { - results.push([ parseInt(PHP.Constants.T_CURLY_OPEN, 10), "{", From 32e3ad5966e5f199a3b2019d02b7558ef98bfe4c Mon Sep 17 00:00:00 2001 From: Adam Jimenez Date: Tue, 3 Jun 2014 00:41:47 +0100 Subject: [PATCH 2/3] fix "{$foo['bar']}" --- lib/ace/mode/php/php.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/php/php.js b/lib/ace/mode/php/php.js index 74af47c2..e82a680a 100644 --- a/lib/ace/mode/php/php.js +++ b/lib/ace/mode/php/php.js @@ -731,7 +731,7 @@ PHP.Lexer = function( src, ini ) { type = 0; if( curlyOpen > 0 ){ - if( match2 = match[0].match(/^[\[\]\;\:\?\(\)\!\.\,\>\<\=\+\-\/\*\|\&\{\}\@\^\%\"\'\$\~]/) ){ + if( match2 = match[0].match(/^[\[\]\;\:\?\(\)\!\.\,\>\<\=\+\-\/\*\|\&\{\}\@\^\%\$\~]/) ){ results.push(match2[0]); }else{ type = PHP.Constants.T_STRING; From 617cd3202ae29fa6e1c9b96d90e05c4da0561b0c Mon Sep 17 00:00:00 2001 From: Adam Jimenez Date: Wed, 4 Jun 2014 10:39:50 +0100 Subject: [PATCH 3/3] fix "{$this->foo->bar('foobar')}" --- lib/ace/mode/php/php.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/php/php.js b/lib/ace/mode/php/php.js index e82a680a..fd703ae2 100644 --- a/lib/ace/mode/php/php.js +++ b/lib/ace/mode/php/php.js @@ -717,7 +717,7 @@ PHP.Lexer = function( src, ini ) { var re; if ( curlyOpen > 0) { - re = /^([^\\\$"{}\]\)\->]|\\.)+/g; + re = /^([^\\\$"{}\]\(\)\->]|\\.)+/g; } else { re = /^([^\\\$"{]|\\.|{[^\$]|\$(?=[^a-zA-Z_\x7f-\uffff]))+/g;; }