ReportSyntaxError() приватный Метод

private ReportSyntaxError ( string message, Node node ) : void
message string
node Node
Результат void
Пример #1
0
 private void Verify(PythonNameBinder binder)
 {
     if (ContainsImportStar)
     {
         binder.ReportSyntaxWarning("import * only allowed at module level", this);
     }
     if (ContainsImportStar && IsClosure)
     {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
     if (ContainsImportStar && Parent is FunctionDefinition)
     {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
     if (ContainsImportStar && ContainsNestedFreeVariables)
     {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it contains a nested function with free variables",
                 Name),
             this);
     }
     if (ContainsUnqualifiedExec && ContainsNestedFreeVariables)
     {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "unqualified exec is not allowed in function '{0}' because it contains a nested function with free variables",
                 Name),
             this);
     }
     if (ContainsUnqualifiedExec && IsClosure)
     {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "unqualified exec is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
 }
Пример #2
0
        internal virtual void Bind(PythonNameBinder binder)
        {
            if (_references != null)
            {
                foreach (var reference in _references.Values)
                {
                    PythonVariable variable;
                    reference.PythonVariable = variable = BindReference(binder, reference);

                    // Accessing outer scope variable which is being deleted?
                    if (variable != null)
                    {
                        if (variable.Deleted && variable.Scope != this && !variable.Scope.IsGlobal)
                        {
                            // report syntax error
                            binder.ReportSyntaxError(
                                String.Format(
                                    System.Globalization.CultureInfo.InvariantCulture,
                                    "can not delete variable '{0}' referenced in nested scope",
                                    reference.Name
                                    ),
                                this);
                        }
                    }
                }
            }
        }
Пример #3
0
 private void Verify(PythonNameBinder binder)
 {
     if (ContainsImportStar)
     {
         binder.ReportSyntaxError("import * only allowed at module level", this);
     }
 }
Пример #4
0
 internal virtual void Bind(PythonNameBinder binder)
 {
     if (_references != null)
     {
         foreach (var reference in _references.Values)
         {
             reference.PythonVariable = BindReference(binder, reference);
             if ((reference.PythonVariable is null || reference.PythonVariable.Kind is VariableKind.Global) && TryGetNonlocalStatement(reference.Name, out NonlocalStatement node))
             {
                 binder.ReportSyntaxError($"no binding for nonlocal '{reference.Name}' found", node);
             }
         }
     }
 }
Пример #5
0
 private void Verify(PythonNameBinder binder) {
     if (ContainsImportStar && IsClosure) {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
     if (ContainsImportStar && Parent is FunctionDefinition) {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
     if (ContainsImportStar && ContainsNestedFreeVariables) {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "import * is not allowed in function '{0}' because it contains a nested function with free variables",
                 Name),
             this);
     }
     if (ContainsUnqualifiedExec && ContainsNestedFreeVariables) {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "unqualified exec is not allowed in function '{0}' because it contains a nested function with free variables",
                 Name),
             this);
     }
     if (ContainsUnqualifiedExec && IsClosure) {
         binder.ReportSyntaxError(
             String.Format(
                 System.Globalization.CultureInfo.InvariantCulture,
                 "unqualified exec is not allowed in function '{0}' because it is a nested function",
                 Name),
             this);
     }
 }
Пример #6
0
        internal virtual void Bind(PythonNameBinder binder) {
            if (_references != null) {
                foreach (var reference in _references.Values) {
                    PythonVariable variable;
                    reference.PythonVariable = variable = BindReference(binder, reference);

                    // Accessing outer scope variable which is being deleted?
                    if (variable != null) {
                        if (variable.Deleted && variable.Scope != this && !variable.Scope.IsGlobal) {

                            // report syntax error
                            binder.ReportSyntaxError(
                                String.Format(
                                    System.Globalization.CultureInfo.InvariantCulture,
                                    "can not delete variable '{0}' referenced in nested scope",
                                    reference.Name
                                    ),
                                this);
                        }
                    }
                }
            }
        }
Пример #7
0
        internal virtual void Bind(PythonNameBinder binder) {
            if (_references != null) {
                foreach (KeyValuePair<SymbolId, PythonReference> kv in _references) {
                    PythonVariable variable;
                    kv.Value.PythonVariable = variable = BindName(binder, kv.Key);

                    // Accessing outer scope variable which is being deleted?
                    if (variable != null) {
                        if (variable.Deleted &&
                        (object)variable.Scope != (object)this &&
                        !variable.Scope.IsGlobal) {

                            // report syntax error
                            binder.ReportSyntaxError(
                                String.Format(
                                    System.Globalization.CultureInfo.InvariantCulture,
                                    "can not delete variable '{0}' referenced in nested scope",
                                    SymbolTable.IdToString(kv.Key)
                                    ),
                                this);
                        }
                        
                        if (variable.Scope != this && 
                            variable.Kind != VariableKind.Global && variable.Kind != VariableKind.GlobalLocal &&
                            !variable.Scope.IsGlobal) {

                            ScopeStatement curScope = Parent;
                            while (curScope != variable.Scope) {
                                if (curScope._childReferences == null) {
                                    curScope._childReferences = new Dictionary<SymbolId, PythonReference>();
                                }

                                curScope._childReferences[kv.Key] = kv.Value;
                                curScope = curScope.Parent;
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        internal virtual void Bind(PythonNameBinder binder) {
            if (_references != null) {
                foreach (KeyValuePair<SymbolId, PythonReference> kv in _references) {
                    PythonVariable variable;
                    kv.Value.PythonVariable = variable = BindName(binder, kv.Key);

                    // Accessing outer scope variable which is being deleted?
                    if (variable != null &&
                        variable.Deleted &&
                        (object)variable.Scope != (object)this &&
                        !variable.Scope.IsGlobal) {

                        // report syntax error
                        binder.ReportSyntaxError(
                            String.Format(
                                System.Globalization.CultureInfo.InvariantCulture,
                                "can not delete variable '{0}' referenced in nested scope",
                                SymbolTable.IdToString(kv.Key)
                                ),
                            this);
                    }
                }
            }
        }