Antlr3.Tool.Grammar.SetName C# (CSharp) Method

SetName() public method

public SetName ( string name ) : void
name string
return void
        public virtual void SetName( string name )
        {
            if ( name == null )
            {
                return;
            }
            // don't error check autogenerated files (those with '__' in them)
            //String saneFile = fileName.replace( '\\', '/' );
            //int lastSlash = saneFile.lastIndexOf( '/' );
            //String onlyFileName = saneFile.substring( lastSlash + 1, fileName.length() );
            //string onlyFileName = fileName;
            //if ( builtFromString )
            //{
            //    string saneFile = fileName.Replace( '\\', '/' );
            //    onlyFileName = saneFile.Split( '/' ).LastOrDefault();
            //}
            if ( !builtFromString )
            {
                string onlyFileName = System.IO.Path.GetFileName( fileName );
                string onlyFileNameNoSuffix = System.IO.Path.GetFileNameWithoutExtension( onlyFileName );

                //int lastDot = onlyFileName.lastIndexOf( '.' );
                //String onlyFileNameNoSuffix = null;
                if ( onlyFileNameNoSuffix == onlyFileName )
                {
                    ErrorManager.Error( ErrorManager.MSG_FILENAME_EXTENSION_ERROR, fileName );
                    onlyFileNameNoSuffix = onlyFileName + GrammarFileExtension;
                }
                else
                {
                    //onlyFileNameNoSuffix = onlyFileName.substring( 0, lastDot );
                }
                if ( !name.Equals( onlyFileNameNoSuffix ) )
                {
                    ErrorManager.Error( ErrorManager.MSG_FILE_AND_GRAMMAR_NAME_DIFFER,
                                       name,
                                       fileName );
                }
            }
            this.name = name;
        }
Grammar