Skip to content

Commit

Permalink
- Framework for knowing what kind of variable we just parsed.
Browse files Browse the repository at this point in the history
- This will be used in compile-time error checking which couldn't be done
- at the level of the grammar.
  • Loading branch information
Andi Gutmans committed Dec 16, 2001
1 parent b4bd4d4 commit 880e7d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Zend/zend_compile.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -556,6 +556,14 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_FETCH_CLASS_SELF 1 #define ZEND_FETCH_CLASS_SELF 1
#define ZEND_FETCH_CLASS_MAIN 2 #define ZEND_FETCH_CLASS_MAIN 2


/* variable parsing type (compile-time) */
#define ZEND_PARSED_MEMBER (1<<0)
#define ZEND_PARSED_METHOD_CALL (1<<1)
#define ZEND_PARSED_STATIC_MEMBER (1<<2)
#define ZEND_PARSED_FUNCTION_CALL (1<<3)
#define ZEND_PARSED_VARIABLE (1<<4)


/* unset types */ /* unset types */
#define ZEND_UNSET_REG 0 #define ZEND_UNSET_REG 0
#define ZEND_UNSET_OBJ 1 #define ZEND_UNSET_OBJ 1
Expand Down
23 changes: 12 additions & 11 deletions Zend/zend_language_parser.y
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -627,28 +627,29 @@ r_cvar_without_static_member:




cvar: cvar:
base_cvar_without_objects T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); } object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not base_cvar_without_objects T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
variable_properties { zend_do_pop_object(&$$ TSRMLS_CC); } object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not variable_properties
{ zend_do_pop_object(&$$ TSRMLS_CC); $$.u.EA.type = $1.u.EA.type | ($7.u.EA.type ? $7.u.EA.type : $6.u.EA.type); }
| base_cvar_without_objects { $$ = $1; } | base_cvar_without_objects { $$ = $1; }
; ;




variable_properties: variable_properties:
variable_properties variable_property variable_properties variable_property { $$.u.EA.type = $2.u.EA.type; }
| /* empty */ | /* empty */ { $$.u.EA.type = 0; }
; ;




variable_property: variable_property:
T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.u.EA.type = $4.u.EA.type; }
; ;


method_or_not: method_or_not:
'(' { zend_do_pop_object(&$1 TSRMLS_CC); zend_do_begin_method_call(NULL, &$1 TSRMLS_CC); } '(' { zend_do_pop_object(&$1 TSRMLS_CC); zend_do_begin_method_call(NULL, &$1 TSRMLS_CC); }
function_call_parameter_list ')' function_call_parameter_list ')'
{ zend_do_end_function_call(&$1, &$$, &$3, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); { zend_do_end_function_call(&$1, &$$, &$3, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);
zend_do_push_object(&$$ TSRMLS_CC); } zend_do_push_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_METHOD_CALL; }
| /* empty */ | /* empty */ { $$.u.EA.type = ZEND_PARSED_MEMBER; }
; ;


cvar_without_objects: cvar_without_objects:
Expand All @@ -662,10 +663,10 @@ static_member:




base_cvar_without_objects: base_cvar_without_objects:
reference_variable { $$ = $1; } reference_variable { $$ = $1; $$.u.EA.type = ZEND_PARSED_VARIABLE; }
| simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); } | simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_VARIABLE; }
| static_member { $$ = $1; } | static_member { $$ = $1; $$.u.EA.type = ZEND_PARSED_STATIC_MEMBER; }
| function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; } | function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.u.EA.type = ZEND_PARSED_FUNCTION_CALL; }
; ;


reference_variable: reference_variable:
Expand Down

0 comments on commit 880e7d8

Please sign in to comment.