Exemple #1
0
        private static void InitNumericStates()
        {
            DFAState <int, LexicalFunction> s5 = AddState(new LexicalState(5, false));                               //Numeric begin state;
            DFAState <int, LexicalFunction> s6 = AddState(new LexicalState(6, false));                               //Number dot state;
            DFAState <int, LexicalFunction> s7 = AddState(new LexicalState(7, true, LexicalFunction.OutputNumeric)); //Number quit state;

            //s0 [0-9] s5
            s0.AddNextState('0', '9', s5.Id);
            s0.AddNextState('0', '9', s5.Id);

            //s5 [0-9] s5
            s5.AddNextState('0', '9', s5.Id);
            s5.AddNextState('0', '9', s5.Id);

            //s5 [\.] s6
            s5.AddNextState('.', s6.Id);

            //s5 else s7 (integer)
            s5.AddElseState(s7.Id);

            //s6 [0-9] s6
            s6.AddNextState('0', '9', s6.Id);
            s6.AddNextState('0', '9', s6.Id);

            //s6 else s7 (float)
            s6.AddElseState(s7.Id);
        }
Exemple #2
0
        private static void InitChineseStates()
        {
            DFAState <int, LexicalFunction> s8 = AddState(new LexicalState(8, false));                               //Numeric begin state;
            DFAState <int, LexicalFunction> s9 = AddState(new LexicalState(9, true, LexicalFunction.OutputChinese)); //Number quit state;

            //s0 [4e00-9fa5] s5
            s0.AddNextState(0x4e00, 0x9fa5, s8.Id);

            s8.AddNextState(0x4e00, 0x9fa5, s8.Id);

            s8.AddElseState(s9.Id);
        }
Exemple #3
0
        private static void InitSpaceStates()
        {
            DFAState <int, LexicalFunction> s3 = AddState(new LexicalState(3, false));                             //Space begin state;
            DFAState <int, LexicalFunction> s4 = AddState(new LexicalState(4, true, LexicalFunction.OutputSpace)); //Space quit state;

            //s0 [ \t\r\n] s3
            s0.AddNextState(new int[] { ' ', '\t', '\r', '\n' }, s3.Id);

            //s3 [ \t\r\n] s3
            s3.AddNextState(new int[] { ' ', '\t', '\r', '\n' }, s3.Id);

            //s3 ^[ \t\r\n] s4
            s3.AddElseState(s4.Id);
        }
Exemple #4
0
        private static DFAState <int, LexicalFunction> sother = AddState(new LexicalState(255, true, LexicalFunction.Other)); //Start state;

        private static void InitIdentifierStates()
        {
            DFAState <int, LexicalFunction> s1 = AddState(new LexicalState(1));                                         //Identifier begin state;
            DFAState <int, LexicalFunction> s2 = AddState(new LexicalState(2, true, LexicalFunction.OutputIdentifier)); //Identifier quit state;

            //s0 [_a-zA-Z] s1
            s0.AddNextState('_', s1.Id);
            s0.AddNextState('a', 'z', s1.Id);
            s0.AddNextState('A', 'Z', s1.Id);
            s0.AddNextState('a', 'z', s1.Id);
            s0.AddNextState('A', 'Z', s1.Id);

            //s1 [_a-zA-Z0-9] s1
            s1.AddNextState('_', s1.Id);
            s1.AddNextState('a', 'z', s1.Id);
            s1.AddNextState('A', 'Z', s1.Id);
            s1.AddNextState('0', '9', s1.Id);
            s1.AddNextState('a', 'z', s1.Id);
            s1.AddNextState('A', 'Z', s1.Id);
            s1.AddNextState('0', '9', s1.Id);

            //s1 ^[_a-zA-Z0-9] s2
            s1.AddElseState(s2.Id);
        }
Exemple #5
0
 private static void InitOtherStates()
 {
     s0.AddElseState(sother.Id);
 }