public void Initialise(Compiler compiler)
        {
            m_compiler = compiler;
            new CSCodeGenerator(compiler);
            //            LSL_Converter = new CSCodeGenerator(null, compiler);

            //Add new LSL events that haven't been added into the parser
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("transaction_result", new [] {
                "LSL_Types.LSLString", "LSL_Types.LSLInteger", "LSL_Types.LSLString"
            }));
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("path_update", new [] {
                "LSL_Types.LSLInteger", "LSL_Types.list"
            }));
        }
        public void Initialize(Compiler compiler)
        {
            m_compiler = compiler;
            //? // new CSCodeGenerator(compiler);

            //Add new LSL events that haven't been added into the parser
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("experience_permissions", new [] {
                "LSL_Types.LSLString"
            }));
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("experience_permissions_denied", new [] {
                "LSL_Types.LSLString", "LSL_Types.LSLInteger"
            }));
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("path_update", new [] {
                "LSL_Types.LSLInteger", "LSL_Types.list"
            }));
            LSL2CSCodeTransformer.AddLSLEvent(new EventInfo("transaction_result", new [] {
                "LSL_Types.LSLString", "LSL_Types.LSLInteger", "LSL_Types.LSLString"
            }));
        }
        /// <summary>
        ///     Generate the code from the AST we have.
        /// </summary>
        /// <param name="script">The LSL source as a string.</param>
        /// <returns>String containing the generated C# code.</returns>
        public string Convert(string script)
        {
            //Unless we are using the same LSL_Converter instance for all scripts, we don't need to reset this
            //ResetCounters();

            LSL2CSCodeTransformer codeTransformer;
            try
            {
                //               lock (p)
                {
                    codeTransformer = new LSL2CSCodeTransformer(p.Parse(FixAdditionalEvents(script)), script);
                    //                    p.m_lexer.Reset();
                }
            }
            catch (CSToolsException e)
            {
                string message;

                // LL start numbering lines at 0 - geeks!
                // Also need to subtract one line we prepend!
                //
                string emessage = e.Message;
                string slinfo = e.slInfo.ToString();

                // Remove wrong line number info
                //
                if (emessage.StartsWith(slinfo + ": "))
                    emessage = emessage.Substring(slinfo.Length + 2);

                if (e.slInfo.lineNumber - 1 <= 0)
                    e.slInfo.lineNumber = 2;
                if (e.slInfo.charPosition - 1 <= 0)
                    e.slInfo.charPosition = 2;

                message = String.Format("({0},{1}) {2}",
                                        e.slInfo.lineNumber - 1,
                                        e.slInfo.charPosition - 1, emessage);

                m_compiler.AddError(message);
                //                p.m_lexer.Reset();
                ResetCounters();
                return "Error parsing the script. " + message;
            }

            SYMBOL root = codeTransformer.Transform(LocalMethods, LocalMethodArguements);
            DuplicatedGlobalVariables = codeTransformer.DuplicatedGlobalVars;
            DuplicatedLocalVariables = codeTransformer.DuplicatedLocalVars;
            OriginalScript = script;
            StringBuilder retVal = new StringBuilder();

            // line number
            //m_CSharpLine += 3;

            // here's the payload
            retVal.Append(GenerateLine());
            foreach (SYMBOL s in root.kids)
                retVal.Append(GenerateNode(s));

            retVal.Append(GenerateFireEventMethod());

            // Removes all carriage return characters which may be generated in Windows platform.
            //Is there a cleaner way of doing this?
            string returnstring = retVal.ToString().Replace("\r", "");

            try
            {
                CheckEventCasts(returnstring);
            }
            catch (InvalidOperationException ex)
            {
                m_compiler.AddError(ex.Message);
                return ex.Message;
            }
            return CreateCompilerScript(m_compiler, MethodsToAdd, returnstring);
        }