Ejemplo n.º 1
0
        public StatementsToken ParseNetlist(Netlist netlist)
        {
            Statement       st;
            StatementsToken body = new StatementsToken();

            while (true)
            {
                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                {
                case DOT:
                case NEWLINE:
                case WORD:
                    break;

                default:
                    mcc_la1[0] = mcc_gen;
                    goto label_1;
                }
                st = ParseSpiceLine();
                if (st != null)
                {
                    body.Add(st);
                }
            }
            label_1 :;

            switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
            {
            case END :
                mcc_consume_token(END);
                break;

            case 0:
                mcc_consume_token(0);
                break;

            default:
                mcc_la1[1] = mcc_gen;
                mcc_consume_token(-1);
                throw new ParseException();
            }
            { return(body); }
            throw new Exception("Missing return statement in function");
        }
Ejemplo n.º 2
0
        public Statement ParseSpiceLine()
        {
            Statement        st;
            Token            t, tn;
            List <Token>     parameters = new List <Token>();
            StatementsToken  body;
            List <Statement> statements = new List <Statement>();

            switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
            {
            case WORD:
                // Component definitions
                tn = mcc_consume_token(WORD);
                while (true)
                {
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                    case VALUE:
                    case STRING:
                    case EXPRESSION:
                    case REFERENCE:
                    case WORD:
                    case IDENTIFIER:
                        ;
                        break;

                    default:
                        mcc_la1[2] = mcc_gen;
                        goto label_2;
                    }
                    t = ParseParameter();
                    parameters.Add(t);
                }
                label_2 :;

                switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                {
                case NEWLINE :
                    mcc_consume_token(NEWLINE);
                    break;

                case 0:
                    mcc_consume_token(0);
                    break;

                default:
                    mcc_la1[3] = mcc_gen;
                    mcc_consume_token(-1);
                    throw new ParseException();
                }
                {
                    return(new Statement(StatementType.Component, tn, parameters));
                }

            default:
                mcc_la1[12] = mcc_gen;
                if (mcc_2_1(2))
                {
                    mcc_consume_token(DOT);
                    tn = mcc_consume_token(1);
                    while (true)
                    {
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                        case VALUE:
                        case STRING:
                        case EXPRESSION:
                        case REFERENCE:
                        case WORD:
                        case IDENTIFIER:
                            ;
                            break;

                        default:
                            mcc_la1[4] = mcc_gen;
                            goto label_3;
                        }
                        t = ParseParameter();
                        parameters.Add(t);
                    }
                    label_3 :;

                    mcc_consume_token(NEWLINE);
                    body = new StatementsToken();
                    while (true)
                    {
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                        case DOT:
                        case NEWLINE:
                        case WORD:
                            ;
                            break;

                        default:
                            mcc_la1[5] = mcc_gen;
                            goto label_4;
                        }
                        st = ParseSpiceLine();
                        if (st != null)
                        {
                            body.Add(st);
                        }
                    }
                    label_4 :;

                    mcc_consume_token(ENDS);
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                    case WORD:
                        mcc_consume_token(WORD);
                        break;

                    default:
                        mcc_la1[6] = mcc_gen;
                        ;
                        break;
                    }
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                    case NEWLINE:
                        mcc_consume_token(NEWLINE);
                        break;

                    case 0:
                        mcc_consume_token(0);
                        break;

                    default:
                        mcc_la1[7] = mcc_gen;
                        mcc_consume_token(-1);
                        throw new ParseException();
                    }
                    parameters.Add(body);
                    { return(new Statement(StatementType.Subcircuit, tn, parameters)); }
                }
                else if (mcc_2_2(2))
                {
                    mcc_consume_token(DOT);
                    tn = mcc_consume_token(2);
                    while (true)
                    {
                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                        case VALUE:
                        case STRING:
                        case EXPRESSION:
                        case REFERENCE:
                        case WORD:
                        case IDENTIFIER:
                            ;
                            break;

                        default:
                            mcc_la1[8] = mcc_gen;
                            goto label_5;
                        }
                        t = ParseParameter();
                        parameters.Add(t);
                    }
                    label_5 :;

                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                    case NEWLINE :
                        mcc_consume_token(NEWLINE);
                        break;

                    case 0:
                        mcc_consume_token(0);
                        break;

                    default:
                        mcc_la1[9] = mcc_gen;
                        mcc_consume_token(-1);
                        throw new ParseException();
                    }
                    if (parameters.Count < 2)
                    {
                        throw new ParseException(tn, "At least a name and model type expected", false);
                    }
                    tn = parameters[0];
                    parameters.RemoveAt(0);
                    { return(new Statement(StatementType.Model, tn, parameters)); }
                }
                else
                {
                    switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                    {
                    case DOT:
                        mcc_consume_token(DOT);
                        tn = mcc_consume_token(WORD);
                        while (true)
                        {
                            switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                            {
                            case VALUE:
                            case STRING:
                            case EXPRESSION:
                            case REFERENCE:
                            case WORD:
                            case IDENTIFIER:
                                ;
                                break;

                            default:
                                mcc_la1[10] = mcc_gen;
                                goto label_6;
                            }
                            t = ParseParameter();
                            parameters.Add(t);
                        }
                        label_6 :;

                        switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk)
                        {
                        case NEWLINE :
                            mcc_consume_token(NEWLINE);
                            break;

                        case 0:
                            mcc_consume_token(0);
                            break;

                        default:
                            mcc_la1[11] = mcc_gen;
                            mcc_consume_token(-1);
                            throw new ParseException();
                        }
                        return(new Statement(StatementType.Control, tn, parameters));

                    case NEWLINE:
                        mcc_consume_token(NEWLINE);
                        return(null);

                    default:
                        mcc_la1[13] = mcc_gen;
                        mcc_consume_token(-1);
                        throw new ParseException();
                    }
                }
            }
            throw new Exception("Missing return statement in function");
        }