Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <syntax>
        /// Try : try
        ///          StatementList
        ///       catch ( [ Identifier : ] UnitType )
        ///          [ StatementList ]
        ///     { catch ( [ Identifier : ] UnitType )
        ///          [ StatementList ]
        ///     }
        ///     [ else [ StatementsList ] ]
        ///       end
        /// </syntax>
        /// <returns></returns>
        public static void parse(iSCOPE context)
        {
            Token token = get();
            Token begin = token;

            if (token.code != TokenCode.Try)   // Compiler error
            {
            }
            forget();

            TRY result = new TRY();

            Context.enter(result);

            BODY.parse(TokenCode.Catch, TokenCode.ERROR, TokenCode.ERROR, result);

            while (true)
            {
                token = get();
                if (token.code != TokenCode.Catch)
                {
                    break;
                }
                CATCH.parse(result);
            }
            token = get();
            if (token.code == TokenCode.Else)
            {
                forget();
                BODY.parse(TokenCode.End, TokenCode.ERROR, TokenCode.ERROR, context);
            }
            token = get();
            if (token.code != TokenCode.End)   // Syntax error
            {
            }
            forget();

            result.setSpan(begin, token);
            context.add(result);
            Context.exit();
        }
Пример #2
0
 public void add(CATCH c)
 {
     handlers.Add(c);
 }
Пример #3
0
        public static void parse(iSCOPE context) // REWRITE!!
        {
            Token token = get();
            Token begin = token;

            if (token.code != TokenCode.Catch)   // Compiler error
            {
            }
            forget();

            CATCH handler = new CATCH();

            Context.enter(handler);

            token = get();
            if (token.code != TokenCode.LParen)   // Syntax error
            {
            }
            else
            {
                forget();
            }

            token = get();
            if (token.code != TokenCode.Identifier)   // Syntax error
            {
            }
            else
            {
                Token id = token;
                forget();
                token = get();
                if (token.code == TokenCode.Colon)
                {
                    forget();
                    // handler.identifier = id.image;

                    token = get();
                    if (token.code != TokenCode.Identifier)   // Syntax error
                    {
                    }
                    forget();
                    token = id;
                }
                UNIT_REF unit_ref = UNIT_REF.parse(null, false, context); // CHECK!!
                handler.unit_ref = unit_ref;
                unit_ref.parent  = handler;
            }

            token = get();
            if (token.code != TokenCode.RParen)   // Syntax error
            {
            }
            forget();

            BODY.parse(TokenCode.Catch, TokenCode.Else, TokenCode.End, handler);

            token = get(); // just to get the span...
            handler.setSpan(begin, token);

            Context.exit();
            context.add(handler);
        }