Exemple #1
0
        ScriptBlock Parse()
        {
            decompiler = CreateDecompiler ();
            ScriptBlock current_script_or_fn = new ScriptBlock (new Location (ts.SourceName, ts.LineNumber));
            decompiler.GetCurrentOffset ();
            decompiler.AddToken (Token.SCRIPT);
            ok = true;

            try {
                for (;;) {
                    //hwd
                    try
                    {

                        ts.allow_reg_exp = true;
                        int tt = ts.GetToken();
                        ts.allow_reg_exp = false;

                        if (tt <= Token.EOF)
                            break;

                        AST n;
                        if (tt == Token.FUNCTION)
                        {
                            try
                            {
                                n = Function(current_script_or_fn, FunctionType.Statement);
                            }
                            catch (ParserException)
                            {
                                ok = false;
                                break;
                            }
                        }
                        else
                        {
                            ts.UnGetToken(tt);
                            n = Statement(current_script_or_fn);
                        }
                        current_script_or_fn.Add(n);

                    }
                    catch (Exception exc)
                    {
                        //hwd
                        ReportError(exc.Message);
                    }

                }
            } catch (StackOverflowException) {
                throw new Exception ("Error: too deep parser recursion.");
            }

            if (!ok)
                return null;

            this.decompiler = null; // It helps GC
            return current_script_or_fn;
        }