SemErr() public method

public SemErr ( int line, int col, string s ) : void
line int
col int
s string
return void
Ejemplo n.º 1
0
 public void SemErr(string msg)
 {
     if (errDist >= minErrDist)
     {
         errors.SemErr(t.line, t.col, msg);
     }
     errDist = 0;
 }
Ejemplo n.º 2
0
        public void AddOption(string optname, int line)
        {
            int optval; Symbol sym;

            try {
                optval = (int)Enum.Parse(typeof(Options), optname);
            } catch (System.ArgumentException) {
                errors.SemErr("Unsupported option '" + optname + "' encountered.");
                return;
            }
            useVector[optval] = true;
            sym = tab.FindSym(optname);
            if (sym == null)
            {
                tab.NewSym(Node.t, optname, line);
            }
        }
Ejemplo n.º 3
0
 public void Add(string NamespaceURI, XmlLangDefinition xldef)
 {
     if (XmlLangMap.ContainsKey(NamespaceURI))
     {
         errors.SemErr("Namespace '" + NamespaceURI + "' declared twice");
     }
     XmlLangMap.Add(NamespaceURI, xldef);
 }
Ejemplo n.º 4
0
        public bool NoCircularProductions()
        {
            bool      ok, changed, onLeftSide, onRightSide;
            ArrayList list = new ArrayList();

            foreach (Symbol sym in nonterminals)
            {
                ArrayList singles = new ArrayList();
                GetSingles(sym.graph, singles);         // get nonterminals s such that sym-->s
                foreach (Symbol s in singles)
                {
                    list.Add(new CNode(sym, s));
                }
            }
            do
            {
                changed = false;
                for (int i = 0; i < list.Count; i++)
                {
                    CNode n = (CNode)list[i];
                    onLeftSide = false; onRightSide = false;
                    foreach (CNode m in list)
                    {
                        if (n.left == m.right)
                        {
                            onRightSide = true;
                        }
                        if (n.right == m.left)
                        {
                            onLeftSide = true;
                        }
                    }
                    if (!onLeftSide || !onRightSide)
                    {
                        list.Remove(n); i--; changed = true;
                    }
                }
            } while(changed);
            ok = true;
            foreach (CNode n in list)
            {
                ok = false;
                errors.SemErr("  " + n.left.name + " --> " + n.right.name);
            }
            return(ok);
        }
Ejemplo n.º 5
0
Archivo: Util.cs Proyecto: ggrov/tacny
        private static string ParseFile(string dafnyFileName, Bpl.IToken tok, ModuleDecl module, BuiltIns builtIns, Errors errs, bool verifyThisFile = true)
        {
            string fn = Bpl.CommandLineOptions.Clo.UseBaseNameForFileName ? Path.GetFileName(dafnyFileName) : dafnyFileName;

            try {
                int errorCount = Microsoft.Dafny.Parser.Parse(dafnyFileName, module, builtIns, errs, verifyThisFile);
                if (errorCount != 0)
                {
                    return($"{errorCount} parse errors detected in {fn}");
                }
            } catch (IOException e) {
                errs.SemErr(tok, "Unable to open included file");
                return($"Error opening file \"{fn}\": {e.Message}");
            }
            return(null); // Success
        }
Ejemplo n.º 6
0
        private static string ParseFile(string dafnyFileName, Bpl.IToken tok, ModuleDecl module, BuiltIns builtIns, Errors errs, bool verifyThisFile = true)
        {
            var fn = DafnyOptions.Clo.UseBaseNameForFileName ? Path.GetFileName(dafnyFileName) : dafnyFileName;

            try {
                int errorCount = Dafny.Parser.Parse(dafnyFileName, module, builtIns, errs, verifyThisFile);
                if (errorCount != 0)
                {
                    return(string.Format("{0} parse errors detected in {1}", errorCount, fn));
                }
            } catch (IOException e) {
                errs.SemErr(tok, "Unable to open included file");
                return(string.Format("Error opening file \"{0}\": {1}", fn, e.Message));
            }
            return(null); // Success
        }
Ejemplo n.º 7
0
        private static string ParseFile(DafnyFile dafnyFile, Include include, ModuleDecl module, BuiltIns builtIns, Errors errs, bool verifyThisFile = true, bool compileThisFile = true)
        {
            var fn = DafnyOptions.Clo.UseBaseNameForFileName ? Path.GetFileName(dafnyFile.FilePath) : dafnyFile.FilePath;

            try {
                int errorCount = Dafny.Parser.Parse(dafnyFile.UseStdin, dafnyFile.SourceFileName, include, module, builtIns, errs, verifyThisFile, compileThisFile);
                if (errorCount != 0)
                {
                    return(string.Format("{0} parse errors detected in {1}", errorCount, fn));
                }
            } catch (IOException e) {
                Bpl.IToken tok = include == null ? Bpl.Token.NoToken : include.tok;
                errs.SemErr(tok, "Unable to open included file");
                return(string.Format("Error opening file \"{0}\": {1}", fn, e.Message));
            }
            return(null); // Success
        }
Ejemplo n.º 8
0
        public static string UnescapeString(string str, Scope s, Errors e, CodePragma location, List <VariableRef> refs)
        {
            int           lastIdx = 1;
            int           idx;
            StringBuilder ret = new StringBuilder();

            try
            {
                while ((idx = str.IndexOf(':', lastIdx)) != -1)
                {
                    //Append the string between the last escape and this one
                    ret.Append(str, lastIdx, idx - lastIdx);

                    //Decipher the escape
                    int         endIdx, refnum;
                    VariableRef vr;
                    switch (str[idx + 1])
                    {
                    case ')':
                        ret.Append('\n');
                        lastIdx = idx + 2;
                        break;

                    case '>':
                        ret.Append('\t');
                        lastIdx = idx + 2;
                        break;

                    case 'o':
                        ret.Append('\a');
                        lastIdx = idx + 2;
                        break;

                    case '"':
                        ret.Append('"');
                        lastIdx = idx + 2;
                        break;

                    case ':':
                        ret.Append(':');
                        lastIdx = idx + 2;
                        break;

                    case '(':
                        endIdx = str.IndexOf(')', idx + 2);
                        ret.Append(char.ConvertFromUtf32(int.Parse(str.Substring(idx + 2, endIdx - idx - 2), System.Globalization.NumberStyles.AllowHexSpecifier)));
                        lastIdx = endIdx + 1;
                        break;

                    case '{':
                        endIdx = str.IndexOf('}', idx + 2);
                        vr     = s[str.Substring(idx + 2, endIdx - idx - 2)] as VariableRef;
                        if (vr == null)
                        {
                            e.SemErr(location.filename, location.startLine, location.startColumn, string.Format("Undefined variable: \"{0}\"", str.Substring(idx + 2, endIdx - idx - 2)));
                        }
                        refnum = refs.IndexOf(vr);
                        if (refnum == -1)
                        {
                            refnum = refs.Count;
                            refs.Add(vr);
                        }
                        ret.Append("{" + refnum.ToString() + "}");
                        lastIdx = endIdx + 1;
                        break;

                    case '[':
                        endIdx = str.IndexOf(']', idx + 2);
                        string uc = UnicodeNameLookup.GetUnicodeCharacter(str.Substring(idx + 2, endIdx - idx - 2));
                        if (uc == null)
                        {
                            e.SemErr(location.filename, location.startLine, location.startColumn, string.Format("Unknown unicode normative name: \"{0}\".", str.Substring(idx + 2, endIdx - idx - 2)));
                        }
                        else
                        {
                            ret.Append(uc);
                        }
                        lastIdx = endIdx + 1;
                        break;
                    }
                }

                //Append the end of the string
                ret.Append(str, lastIdx, str.Length - lastIdx - 1);
            }
            catch (Exception ex)
            {
                e.SemErr(string.Format("Invalid escape sequence in string constant: {0}", ex.Message));
            }

            return(ret.ToString());
        }