예제 #1
0
    /// <summary>
    /// Function called when a <see cref="FunctionCall"/> block is found.
    /// Verifies that the call's structure is correct and calls <see cref="QuadrupleManager"/>
    /// to carry out the necessary actions given the instruction.
    /// Called by <see cref="FACTOR"/>.
    /// </summary>
    void CALL_TO_FUNCTION()
    {
        Expect(19); // "call"
        Expect(1);  // id
        string functionId = t.val;

        try { QuadrupleManager.CallFunctionBeforeParameters(functionId); }
        catch (Exception e) { SemErr(e.Message); }
        Expect(10); // '('
        try { QuadrupleManager.CallFunctionOpeningParenthesis(); }
        catch (Exception e) { SemErr(e.Message); }
        if (StartOf(3))
        {
            SUPER_EXP();             // result of parameter
            try {
                QuadrupleManager.CallFunctionParameter();
                while (la.kind == 11)   // ','
                {
                    Get();
                    SUPER_EXP(); // result of parameter
                    QuadrupleManager.CallFunctionParameter();
                }
            }
            catch (Exception e) { SemErr(e.Message); }
        }
        Expect(12);         // ')'
        try { QuadrupleManager.CallFunctionClosingParenthesis(); }
        catch (Exception e) { SemErr(e.Message); }
        try { QuadrupleManager.CallFunctionEnd(); }
        catch (Exception e) { SemErr(e.Message); }
    }