php-parser
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "php-parser", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "PHP parser", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -10,7 +10,8 @@ /** | ||
* <ebnf> | ||
* variable ::= (reference_variable | namespace_name) (T_DOUBLE_COLON reference_variable)? | ||
* variable ::= ...complex @todo | ||
* </ebnf> | ||
* <code> | ||
* $var // simple var | ||
* var::CONST_NAME // dynamic class name with const retrieval | ||
* classname::CONST_NAME // dynamic class name with const retrieval | ||
* foo() // function call | ||
* $var->func()->property // chained calls | ||
@@ -27,5 +28,10 @@ * </code> | ||
result = this.read_namespace_name(); | ||
if (this.token != tokens.T_DOUBLE_COLON) { | ||
if ( | ||
this.token != tokens.T_DOUBLE_COLON | ||
&& this.token != '(' | ||
) { | ||
// @see parser.js line 130 : resolves a conflict with scalar | ||
return ['const', result.length == 1 ? result[0] : result]; | ||
} else { | ||
result = ['ns', result]; | ||
} | ||
@@ -36,6 +42,6 @@ } else { | ||
// static call | ||
// static mode | ||
if (this.token === tokens.T_DOUBLE_COLON) { | ||
var getter = null; | ||
if (this.is([tokens.T_VARIABLE, '$'])) { | ||
if (this.next().is([tokens.T_VARIABLE, '$'])) { | ||
getter = this.read_reference_variable(); | ||
@@ -48,14 +54,39 @@ } else if (this.token === tokens.T_STRING) { | ||
} | ||
if (this.token === '(') { | ||
var args = this.next().read_parameter_list(); | ||
this.expect(')').next(); | ||
result = ['static.call', result, getter, args ]; | ||
} else { | ||
result = ['static.get', result, getter]; | ||
if (result[0] != 'ns') { | ||
result = ['lookup', 'class', result]; | ||
} | ||
result = ['static', 'get', result, getter]; | ||
} | ||
// @todo | ||
// if (this.token === ) { | ||
// } | ||
recursive_scan_loop: | ||
while(this.token != EOF) { | ||
switch(this.token) { | ||
case '(': | ||
result = ['call', result, this.read_function_argument_list()]; | ||
break; | ||
case '[': | ||
var offset = this.next().read_expr(); | ||
this.expect(']').next(); | ||
result = ['offset', result, offset]; | ||
break; | ||
case tokens.T_OBJECT_OPERATOR: | ||
var what; | ||
switch(this.next().token) { | ||
case tokens.T_STRING: | ||
what = this.text(); | ||
this.next(); | ||
break; | ||
case tokens.T_VARIABLE: | ||
what = ['var', this.text()]; | ||
this.next(); | ||
break; | ||
default: | ||
this.error([tokens.T_STRING, tokens.T_VARIABLE]); | ||
} | ||
result = ['prop', result, what]; | ||
break; | ||
default: | ||
break recursive_scan_loop; | ||
} | ||
} | ||
@@ -66,3 +97,3 @@ return result; | ||
* <ebnf> | ||
* reference_variable ::= (T_VARIABLE | '${' EXPR '}') ( '[' OFFSET ']' | '{' EXPR '}' )* | ||
* reference_variable ::= simple_variable ('[' OFFSET ']')* | '{' EXPR '}' | ||
* </ebnf> | ||
@@ -72,3 +103,3 @@ * <code> | ||
* $foo{1}; // foo is a string ==> get the 2nd char offset | ||
* ${'foo'}; // get the dynamic var $foo | ||
* ${'foo'}[123]; // get the dynamic var $foo | ||
* $foo[123]{1}; // gets the 2nd char from the 123 array entry | ||
@@ -86,5 +117,4 @@ * </code> | ||
this.expect('}').next(); | ||
} else { | ||
break; | ||
} | ||
} else break; | ||
} | ||
@@ -111,7 +141,8 @@ return result; | ||
break; | ||
case '$': // @todo $$$var | ||
result = ['lookup', this.read_simple_variable()]; | ||
case '$': // $$$var | ||
result = ['lookup', 'var', this.read_simple_variable()]; | ||
break; | ||
case tokens.T_VARIABLE: // $$var | ||
result = this.read_simple_variable(); | ||
result = ['var', this.text()]; | ||
this.next(); | ||
break; | ||
@@ -121,3 +152,3 @@ default: | ||
} | ||
result = ['lookup', result]; | ||
result = ['lookup', 'var', result]; | ||
} | ||
@@ -124,0 +155,0 @@ return result; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3256
1130105