Implement the "globals" and "locals" keyword

fixes #8244
This commit is contained in:
Gunnar Beutner 2015-01-16 13:04:34 +01:00
parent b4c74efde0
commit 848d076090
2 changed files with 13 additions and 1 deletions

View File

@ -190,6 +190,8 @@ false { yylval->boolean = 0; return T_BOOLEAN; }
const return T_CONST;
var return T_VAR;
this return T_THIS;
globals return T_GLOBALS;
locals return T_LOCALS;
use return T_USE;
apply return T_APPLY;
to return T_TO;

View File

@ -142,6 +142,8 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%token T_GREATER_THAN "> (T_GREATER_THAN)"
%token T_VAR "var (T_VAR)"
%token T_GLOBALS "globals (T_GLOBALS)"
%token T_LOCALS "locals (T_LOCALS)"
%token T_CONST "const (T_CONST)"
%token T_USE "use (T_USE)"
%token <type> T_TYPE_DICTIONARY "dictionary (T_TYPE_DICTIONARY)"
@ -221,7 +223,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%left UNARY_MINUS UNARY_PLUS
%right '!' '~'
%left '.' '(' '['
%left T_VAR T_THIS
%left T_VAR T_THIS T_GLOBALS T_LOCALS
%right ';' ','
%right T_NEWLINE
%{
@ -807,6 +809,14 @@ rterm_no_side_effect: T_STRING
{
$$ = new GetScopeExpression(ScopeThis);
}
| T_GLOBALS
{
$$ = new GetScopeExpression(ScopeGlobal);
}
| T_LOCALS
{
$$ = new GetScopeExpression(ScopeLocal);
}
| rterm_array
| rterm_scope_require_side_effect
{