private NonlocalStatement ParseNonlocalStmt() { if (_functions != null && _functions.Count == 0 && _classDepth == 0) { ReportSyntaxError("nonlocal declaration not allowed at module level"); } Eat(TokenKind.KeywordNonlocal); string localWhiteSpace = _tokenWhiteSpace; var start = GetStart(); List<string> commaWhiteSpace; List<string> namesWhiteSpace; var l = ReadNameList(out commaWhiteSpace, out namesWhiteSpace); var names = l.ToArray(); NonlocalStatement ret = new NonlocalStatement(names); ret.SetLoc(start, GetEnd()); if (_verbatim) { AddPreceedingWhiteSpace(ret, localWhiteSpace); AddListWhiteSpace(ret, commaWhiteSpace.ToArray()); AddNamesWhiteSpace(ret, namesWhiteSpace.ToArray()); } return ret; }
// NonlocalStatement public override bool Walk(NonlocalStatement node) { return ShouldWalkWorker(node); }
public override bool Walk(NonlocalStatement node) { foreach (var name in node.Names) { if (name.Name != null) { _scope.AddVariable(name.Name, CreateVariableInDeclaredScope(name)); } } return false; }
public override void PostWalk(NonlocalStatement node) { PostWalkWorker(node); }