Пример #1
0
 public void AddAutonomus(Autonomus an)
 {
     autonomus.AddLast(an);
 }
Пример #2
0
    // throws RecognitionException [1]
    // $ANTLR end "start"
    // $ANTLR start "automonus"
    // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:69:1: automonus returns [Autonomus aut] : 'autonomus' name= ID '{' (fromName= INT '-' ev= ID ( '*' tax= FLOAT )? '-' toName= INT ';' )+ '}' ;
    public Autonomus automonus()
    {
        Autonomus aut = null;

        IToken name = null;
        IToken fromName = null;
        IToken ev = null;
        IToken tax = null;
        IToken toName = null;

        try
        {
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:69:35: ( 'autonomus' name= ID '{' (fromName= INT '-' ev= ID ( '*' tax= FLOAT )? '-' toName= INT ';' )+ '}' )
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:69:37: 'autonomus' name= ID '{' (fromName= INT '-' ev= ID ( '*' tax= FLOAT )? '-' toName= INT ';' )+ '}'
            {
                Match(input,16,FOLLOW_16_in_automonus587);
                name=(IToken)Match(input,ID,FOLLOW_ID_in_automonus591);

                        aut = new Autonomus(name.Text);

                Match(input,17,FOLLOW_17_in_automonus599);
                // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:73:6: (fromName= INT '-' ev= ID ( '*' tax= FLOAT )? '-' toName= INT ';' )+
                int cnt4 = 0;
                do
                {
                    int alt4 = 2;
                    int LA4_0 = input.LA(1);

                    if ( (LA4_0 == INT) )
                    {
                        alt4 = 1;
                    }

                    switch (alt4)
                    {
                        case 1 :
                            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:73:7: fromName= INT '-' ev= ID ( '*' tax= FLOAT )? '-' toName= INT ';'
                            {
                                fromName=(IToken)Match(input,INT,FOLLOW_INT_in_automonus604);
                                Match(input,18,FOLLOW_18_in_automonus606);
                                ev=(IToken)Match(input,ID,FOLLOW_ID_in_automonus610);
                                // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:73:30: ( '*' tax= FLOAT )?
                                int alt3 = 2;
                                int LA3_0 = input.LA(1);

                                if ( (LA3_0 == 19) )
                                {
                                    alt3 = 1;
                                }
                                switch (alt3)
                                {
                                    case 1 :
                                        // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:73:31: '*' tax= FLOAT
                                        {
                                            Match(input,19,FOLLOW_19_in_automonus613);
                                            tax=(IToken)Match(input,FLOAT,FOLLOW_FLOAT_in_automonus617);

                                        }
                                        break;

                                }

                                Match(input,18,FOLLOW_18_in_automonus622);
                                toName=(IToken)Match(input,INT,FOLLOW_INT_in_automonus626);
                                Match(input,20,FOLLOW_20_in_automonus628);

                                        float ratio = (tax != null) ? float.Parse(tax.Text, System.Globalization.CultureInfo.InvariantCulture) : 1.0f;
                                        aut.AddEdge(ev.Text, Int32.Parse(fromName.Text), Int32.Parse(toName.Text),
                                            ratio);
                                        tax = null;

                            }
                            break;

                        default:
                            if ( cnt4 >= 1 ) goto loop4;
                                EarlyExitException eee4 =
                                    new EarlyExitException(4, input);
                                throw eee4;
                    }
                    cnt4++;
                } while (true);

                loop4:
                    ;	// Stops C# compiler whining that label 'loop4' has no statements

                Match(input,21,FOLLOW_21_in_automonus637);

            }

        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input,re);
        }
        finally
        {
        }
        return aut;
    }
Пример #3
0
        public void TestInitialize()
        {
            san = new SAN();

            Autonomus aut1 = new Autonomus("A");
            aut1.AddNode(0);
            aut1.AddNode(1);
            aut1.AddEdge("ev1", 0, 1, 1.0f);
            aut1.AddEdge("ev2", 1, 0, 1.0f);
            san.AddAutonomus(aut1);

            Autonomus aut2 = new Autonomus("B");
            aut2.AddNode(0);
            aut2.AddNode(1);
            aut2.AddEdge("ev3", 0, 1, 1.0f);
            aut2.AddEdge("ev4", 1, 0, 1.0f);
            san.AddAutonomus(aut2);

            Autonomus aut3 = new Autonomus("C");
            aut3.AddNode(0);
            aut3.AddNode(1);
            aut3.AddEdge("ev2", 0, 1, 1.0f);
            aut3.AddEdge("ev3", 1, 0, 1.0f);

            san.AddAutonomus(aut3);

            san.AddEvent("ev1", Event.EventType.LOC, null);
            san.AddEvent("ev2", Event.EventType.LOC, null);
            san.AddEvent("ev3", Event.EventType.LOC, null);
            san.AddEvent("ev4", Event.EventType.LOC, null);
        }