RecordWarning() private method

private RecordWarning ( MiniME.Bookmark position, MiniME.Bookmark order, string message ) : void
position MiniME.Bookmark
order MiniME.Bookmark
message string
return void
Esempio n. 1
0
        // Check for cases where a semicolon is optional
        //  - end of file
        //  - immediately before a brace
        //  - before a line break
        public bool IsAutoSemicolon()
        {
            if (p.eof || token == Token.closeBrace || m_bPreceededByLineBreak)
            {
                if (m_prevToken != Token.closeBrace)
                {
                    if (m_bWarnings)
                    {
                        var b = new Bookmark(p, m_prevTokenEnd, token, m_bWarnings);
                        b.file     = this.p;
                        b.position = this.m_prevTokenEnd;
                        b.token    = this.token;
                        Compiler.RecordWarning(b, "missing semicolon");
                    }
                }
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        // Get the next token, skipping comments as we go
        public Token Next()
        {
            m_prevToken = m_currentToken;
            do
            {
                m_currentToken = ParseToken();

                if (m_currentToken == Token.eof && m_IncludeStack.Count > 0)
                {
                    // Pop include stack
                    p = m_IncludeStack.Pop();
                    m_prevTokenEnd = p.position;
                    return(Next());
                }


                // Check for directive comments
                if (m_currentToken == Token.comment)
                {
                    if (m_strIdentifier.StartsWith("!"))
                    {
                        m_currentToken = Token.directive_comment;
                        break;
                    }

                    string str = m_strIdentifier.Trim();

                    if (str == "fall through")
                    {
                        m_currentToken = Token.kw_fallthrough;
                        break;
                    }

                    if (str == "warnings:on")
                    {
                        m_bWarnings = true;
                    }

                    if (str == "warnings:off")
                    {
                        m_bWarnings = false;
                    }

                    if (str == "warnings:push:on")
                    {
                        Compiler.WarningsEnabledStack.Push(m_bWarnings);
                        m_bWarnings = true;
                    }

                    if (str == "warnings:push:off")
                    {
                        Compiler.WarningsEnabledStack.Push(m_bWarnings);
                        m_bWarnings = false;
                    }
                    if (str == "warnings:pop")
                    {
                        if (Compiler.WarningsEnabledStack.Count > 0)
                        {
                            m_bWarnings = Compiler.WarningsEnabledStack.Pop();
                        }
                        else
                        {
                            m_bWarnings = true;
                            Compiler.RecordWarning(GetBookmark(), "can't pop warning state.");
                        }
                    }


                    if (str.StartsWith("private:"))
                    {
                        m_currentToken  = Token.directive_private;
                        m_strIdentifier = str.Substring(8);
                        break;
                    }
                    if (str.StartsWith("public:"))
                    {
                        m_currentToken  = Token.directive_public;
                        m_strIdentifier = str.Substring(7);
                        break;
                    }

                    if (str.StartsWith("include:"))
                    {
                        // Get file name
                        string strFile = str.Substring(8).Trim();

                        // Work out fully qualified name, relative to current file being processed
                        string strDir    = System.IO.Path.GetDirectoryName(p.FileName);
                        string strOldDir = System.IO.Directory.GetCurrentDirectory();
                        System.IO.Directory.SetCurrentDirectory(strDir);
                        strFile = System.IO.Path.GetFullPath(strFile);
                        System.IO.Directory.SetCurrentDirectory(strOldDir);

                        // Open the include file
                        OpenIncludeFile(System.IO.File.ReadAllText(strFile), strFile);

                        // Recurse
                        return(Next());
                    }
                }
            } while (m_currentToken == Token.comment);

            m_prevTokenEnd = m_tokenEnd;
            m_tokenEnd     = p.position;
            return(m_currentToken);
        }