Beispiel #1
0
    /// <summary>
    /// Function called when a <see cref="AssignBlock"/> block is read.
    /// Checks whether the assignment is to a variable or to an asset's attribute, and
    /// calls the corresponding functions that handle the assignment.
    /// Called by <see cref="INSTRUCTION"/>.
    /// </summary>
    void ASSIGNMENT()
    {
        Expect(32);        // set
        Expect(1);         // id
        string id = t.val;

        if (la.kind == 22) // '.'
        {
            try
            {
                QuadrupleManager.ReadAssetId(id);
                Get();
                ATTRIBUTE();                 // we don't need to verify the attribute as the UI forces the user to select a valid one
            }
            catch (Exception e) { SemErr(e.Message); }
        }
        else
        {
            try { QuadrupleManager.ReadIDVariable(id); }
            catch (Exception e) { SemErr(e.Message); }
        }

        Expect(33); // '='
        SUPER_EXP();

        try { QuadrupleManager.AssignEnd(); }
        catch (Exception e) { SemErr(e.Message); }
    }
Beispiel #2
0
 /// <summary>
 /// Function called when a <see cref="DoBlock"/> block is read.
 /// Verifies the id of the asset by calling <see cref="QuadrupleManager.ReadAssetId(string)"/>
 /// and calls <see cref="ACTION"/> to handle the action to perform.
 /// Called by <see cref="INSTRUCTION"/>.
 /// </summary>
 void DO()
 {
     Expect(21);        // "do"
     Expect(1);         // id
     try { QuadrupleManager.ReadAssetId(t.val); }
     catch (Exception e) { SemErr(e.Message); }
     Expect(22);         // '.'
     ACTION();
 }
Beispiel #3
0
    /// <summary>
    /// This is the lowest level of abstraction for an expression. Checks which is the
    /// factor being used as an expression, retrieves this information, and calls the
    /// necessesary functions in <see cref="QuadrupleManager"/> that handles each case
    /// individually.
    /// Called by <see cref="TERM"/>.
    /// </summary>
    void FACTOR()
    {
        if (la.kind == 10)           // '('
        // push a fake bottom
        {
            QuadrupleManager.PushFakeBottom();
            Get();
            SUPER_EXP();
            Expect(12);             // ')'
            // exit fake bottom
            QuadrupleManager.PopFakeBottom();
        }
        else if (StartOf(6))
        {
            if (la.kind == 37)               // negative sign
            {
                Get();
                QuadrupleManager.PushOperator(SemanticCubeUtilities.Operators.negative);
            }

            if (la.kind == 4)               // number constant
            {
                Get();
                try { QuadrupleManager.ReadConstantNumber(Int32.Parse(t.val)); }
                catch (Exception e) { SemErr(e.Message); }
            }
            else if (la.kind == 1)     // id
            {
                Get();
                string id = t.val;
                if (la.kind == 22) // '.' character
                {
                    try
                    {
                        QuadrupleManager.ReadAssetId(id);
                        Get();
                        ATTRIBUTE();                         // we don't need to verify the attribute as the UI forces the user to select a valid one
                    }
                    catch (Exception e) { SemErr(e.Message); }
                }
                else
                {
                    try { QuadrupleManager.ReadIDVariable(id); }
                    catch (Exception e) { SemErr(e.Message); }
                }
            }
            else if (la.kind == 19)                 // "call"
            {
                CALL_TO_FUNCTION();
            }
            else if (la.kind == 2 || la.kind == 3)                 // true or false
            {
                BOOL();
            }
            else if (la.kind == 5)                 // string constant
            {
                Get();
                try { QuadrupleManager.ReadConstantText(t.val); }
                catch (Exception e) { SemErr(e.Message); }
            }
            else
            {
                SynErr(60);                // invalid FACTOR
            }
            try { QuadrupleManager.PopOperator(SemanticCubeUtilities.OperatorToPriority(SemanticCubeUtilities.Operators.negative)); }
            catch (Exception e) { SemErr(e.Message); }
        }
        else
        {
            SynErr(61);          // invalid FACTOR
        }
    }