Esempio n. 1
0
        //mxd. This adds an error to the ErrorLogger
        public void LogError()
        {
            string message = ScriptType + " error in \"" + shorterrorsource
                             + (errorline != CompilerError.NO_LINE_NUMBER ? "\", line " + (errorline + 1) : "\"") + ". "
                             + errordesc + ".";

            TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Error,
                ScriptType, datalocation,
                (sourcename.StartsWith("?") ? sourcename.Substring(1) : sourcename),
                sourcelumpindex, errorline, message);

            General.ErrorLogger.Add(error);
        }
Esempio n. 2
0
        protected internal void LogWarning(string message, int linenumber)
        {
            // Add a warning
            int errline = (linenumber != CompilerError.NO_LINE_NUMBER
                ? linenumber
                : (datastream != null ? GetCurrentLineNumber() : CompilerError.NO_LINE_NUMBER));
            string errsource = (ScriptType == ScriptType.ACS && sourcename.StartsWith("?") ? sourcename.Substring(1) : Path.Combine(datalocation.GetDisplayName(), sourcename));
            if(sourcelumpindex != -1) errsource += ":" + sourcelumpindex;

            message = ScriptType + " warning in \"" + errsource
                      + (errline != CompilerError.NO_LINE_NUMBER ? "\", line " + (errline + 1) : "\"") + ". "
                      + message + ".";

            TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Warning,
                ScriptType, datalocation,
                (sourcename.StartsWith("?") ? sourcename.Substring(1) : sourcename),
                sourcelumpindex, errline, message);

            General.ErrorLogger.Add(error);
        }
Esempio n. 3
0
        // This skips whitespace on the stream, placing the read
        // position right before the first non-whitespace character
        // Returns false when the end of the stream is reached
        protected internal bool SkipWhitespace(bool skipnewline)
        {
            int offset = skipnewline ? 0 : 1;
            char c;
            prevstreamposition = datastream.Position; //mxd

            do
            {
                if(datastream.Position == datastream.Length) return false;
                c = (char)datareader.ReadByte();

                // Check if this is comment
                if(c == '/')
                {
                    if(datastream.Position == datastream.Length) return false;
                    char c2 = (char)datareader.ReadByte();
                    if(c2 == '/')
                    {
                        // Check if not a special comment with a token
                        if(datastream.Position == datastream.Length) return false;
                        char c3 = (char)datareader.ReadByte();
                        if(skipeditorcomments || c3 != '$') //mxd. Added skipeditorcomments
                        {
                            // Skip entire line
                            char c4 = ' ';
                            while((c4 != '\n') && (datastream.Position < datastream.Length)) { c4 = (char)datareader.ReadByte(); }
                            c = c4;
                        }
                        else
                        {
                            // Not a comment
                            c = c3;
                        }
                    }
                    else if(c2 == '*')
                    {
                        // Skip until */
                        char c4, c3 = '\0';
                        prevstreamposition = datastream.Position; //mxd
                        do
                        {
                            if(datastream.Position == datastream.Length) //mxd
                            {
                                // ZDoom doesn't give even a warning message about this, so we shouldn't report error or fail parsing.
                                string message = ScriptType + " warning in \"" + sourcename + "\", line " + GetCurrentLineNumber() + ". Block comment is not closed.";
                                TextResourceErrorItem error = new TextResourceErrorItem(ErrorType.Warning, ScriptType, datalocation, sourcename, sourcelumpindex, GetCurrentLineNumber(), message);
                                General.ErrorLogger.Add(error);
                                return false;
                            }

                            c4 = c3;
                            c3 = (char)datareader.ReadByte();
                        }
                        while((c4 != '*') || (c3 != '/'));
                        c = ' ';
                    }
                    else
                    {
                        // Not a comment, rewind from reading c2
                        datastream.Seek(-1, SeekOrigin.Current);
                    }
                }
                //mxd. Region/endregion handling
                else if(skipregions && c == '#')
                {
                    long startpos = datastream.Position - 1;
                    string s = ReadToken(false).ToLowerInvariant();
                    if(s == "region" || s == "endregion")
                    {
                        // Skip entire line
                        char ch = ' ';
                        while((ch != '\n') && (datastream.Position < datastream.Length)) { ch = (char)datareader.ReadByte(); }
                        c = ch;
                    }
                    else
                    {
                        // Rewind so this structure can be read again
                        DataStream.Seek(startpos, SeekOrigin.Begin);
                        return true;
                    }
                }
            }
            while(whitespace.IndexOf(c, offset) > -1);

            // Go one character back so we can read this non-whitespace character again
            datastream.Seek(-1, SeekOrigin.Current);
            return true;
        }
Esempio n. 4
0
 public void ShowError(TextResourceErrorItem error)
 {
 }
Esempio n. 5
0
 //mxd
 internal void DisplayError(TextResourceErrorItem error)
 {
     editor.ShowError(error);
 }