public BlaiseImportOptions ConvertPhase1(string fileName)
        {
            CaseInsensitiveFileStream stream = new CaseInsensitiveFileStream(fileName);
            stream.UpperCaseGrammar = true;

            // Run the lexer.
            BlaiseLexer lexer = new BlaiseLexer(stream);
            this.tokens = new CommonTokenStream(lexer, Lexer.DEFAULT_TOKEN_CHANNEL);

            // Create the parser and sign up for error events.
            BParser parser = new BParser(this.tokens);
            parser.TreeAdaptor = new CommonTreeAdaptor();
            parser.Error += new EventHandler<ParseErrorEventArgs>(parser_Error);
            parser.Warning += new EventHandler<ParseErrorEventArgs>(parser_Warning);
            parser.Message += new EventHandler<ParseErrorEventArgs>(parser_Message);

            // Run the parser.
            BParser.blaise_file_return r = null;
            try
            {
                r = parser.blaise_file();
            }
            catch (RecognitionException e)
            {
                TriggerError(e);
            }

            foreach (string missingFile in lexer.MissingFiles)
            {
                this.Messages.Add("Could not find " + missingFile);
            }

            if (r == null)
            {
                return null;
            }

            this.tree = r.Tree as CommonTree;

            if (this.tree == null ||
                this.tokens == null)
            {
                // TODO log this and/or send an error.
                return null;
            }

            // Prepare for the tree walkers.
            CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
            nodes.TokenStream = this.tokens;

            // Walk the tree to find language definitions.
            BlaiseImportOptions options = new BlaiseImportOptions() { BaseFilePath = fileName };
            LanguageTreeWalker ltw = new LanguageTreeWalker(tree);
            ltw.Parse();
            options.DefinedLanguages = ltw.DefinedLanguages;
            options.DefinedLanguagesOrder = ltw.DefinedLanguagesOrder;

            return options;
        }
    // $ANTLR end "T__214"

    // $ANTLR start "INCLUDE_FILE"
    public void mINCLUDE_FILE() // throws RecognitionException [2]
    {
    		try
    		{
            int _type = INCLUDE_FILE;
    	int _channel = DEFAULT_TOKEN_CHANNEL;
            IToken f = null;

            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:159:13: ( INCLUDE ( WS )* f= QSTRING )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:159:15: INCLUDE ( WS )* f= QSTRING
            {
            	mINCLUDE(); 
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:159:23: ( WS )*
            	do 
            	{
            	    int alt1 = 2;
            	    int LA1_0 = input.LA(1);

            	    if ( ((LA1_0 >= '\t' && LA1_0 <= '\n') || (LA1_0 >= '\f' && LA1_0 <= '\r') || LA1_0 == ' ') )
            	    {
            	        alt1 = 1;
            	    }


            	    switch (alt1) 
            		{
            			case 1 :
            			    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:159:24: WS
            			    {
            			    	mWS(); 

            			    }
            			    break;

            			default:
            			    goto loop1;
            	    }
            	} while (true);

            	loop1:
            		;	// Stops C# compiler whining that label 'loop1' has no statements

            	int fStart58 = CharIndex;
            	mQSTRING(); 
            	f = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, fStart58, CharIndex-1);

            		#region Include input stream switching
            		String name = f.Text;
            		name = name.Trim('"');
            		try
            		{
            			// save current lexer's state
            			SaveStruct ss = new SaveStruct(input);
            		
            		CaseInsensitiveFileStream currentStream = input as CaseInsensitiveFileStream;
            			if (currentStream != null)
            			{
            				if (string.IsNullOrEmpty(topLevelDirectory))
            				{
            					topLevelDirectory = Path.GetDirectoryName(currentStream.SourceName);
            				}
            		
            			if(topLevelDirectory != null) 
            				{
            					// Blaise apparently treats all INCLUDES as if they are relative to the top level.
            					// string dir = Path.GetDirectoryName(currentStream.SourceName);
            					string bigPath = topLevelDirectory +
            					System.IO.Path.DirectorySeparatorChar +
            					name;
            					name = System.IO.Path.GetFullPath(bigPath);
            				}
            			}
            			
            			// switch on new input stream
            			if(!File.Exists(name)) 
            			{ 
            				System.Console.WriteLine("Cannot find include file " + name);
            				this.MissingFiles.Add(name);
            			}
            			else {
            			CaseInsensitiveFileStream newStream = new CaseInsensitiveFileStream(name);
            			newStream.UpperCaseGrammar = true;                    
            			this.CharStream = newStream;
            			includes.Push(ss);
            			Reset();
            			}
            		}
            		catch (Exception fnf)
            		{
            			//throw new Exception("Cannot open include file " + name, fnf);
            			System.Console.WriteLine("Cannot open include file " + name);
            		}
            		#endregion


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally 
    	{
        }
    }