Exemplo n.º 1
0
        static myPaserResult myparser2(string line)
        {
            //state table
            //state |token
            //      |,      |"      |other
            //------+-------+-------+------
            //s     |s      |a      |e
            //a     |a      |b      |a
            //b     |s      |a      |invalid
            //e     |s      |invalid|e
            myPaserResult res    = new myPaserResult();
            myState       cur    = myState.s;
            myState       nState = myState.s;

            foreach (char c in line)
            {
                myToken tk = new myToken(c);
                cur    = nState;
                nState = tbl[(int)cur, (int)tk.type];
                if (nState == myState.invalid)
                {
                    break;
                }
                myRule cb = clbTbl[(int)cur, (int)tk.type];
                cb(res, tk);
            }

            //case eol
            return(res);
        }
Exemplo n.º 2
0
 static void f_es(myPaserResult res, myToken tk)
 {
     res.count++;
     res.arr.Add(res.gerCurObj());
     res.curObj.iCur++;
     //res.fields.Add(res.curObj);
 }
Exemplo n.º 3
0
 static void f_ss(myPaserResult res, myToken tk)
 {
     res.count++;
     res.arr.Add("");
     res.curObj.iStart = ++res.curObj.iCur;
     //res.fields.Add(res.curObj); //to debug
 }
Exemplo n.º 4
0
        protected string[] parseLine(string line, bool isCSV)
        {
            myPaserResult m = myparser2(line);

            if (isCSV)
            {
                m.arr.Add(m.gerCurObj());
            }
            return(m.arr.ToArray());
        }
Exemplo n.º 5
0
        static myPaserResult myparser2(string line)
        {
            //state table
            //state |token
            //      |,      |"      |other
            //------+-------+-------+------
            //s     |s      |a      |e
            //a     |a      |b      |a
            //b     |s      |a      |invalid
            //e     |s      |invalid|e
            myPaserResult res    = new myPaserResult(line);
            myState       cur    = myState.s;
            myState       nState = myState.s;

            foreach (char c in line)
            {
                myTkType type;
#if false
                myToken tk = new myToken(c);
                type = tk.type;
#else
                switch (c)
                {
                case '"':
                    type = myTkType.t_dblq;
                    break;

                case ',':
                    type = myTkType.t_comma;
                    break;

                default:
                    type = myTkType.t_other;
                    break;
                }
#endif
                cur    = nState;
                nState = tbl[(int)cur, (int)type];
                if (nState == myState.invalid)
                {
                    break;
                }
                myRule cb = clbTbl[(int)cur, (int)type];
                cb(res, null);
            }

            //case eol
            return(res);
        }
Exemplo n.º 6
0
 static void f_zz(myPaserResult res, myToken tk)
 {
     res.curObj.iCur++;
 }
Exemplo n.º 7
0
 static void f_se(myPaserResult res, myToken tk)
 {
     res.curObj.iStart = res.curObj.iCur++;
 }
Exemplo n.º 8
0
 static void f_en(myPaserResult res, myToken tk)
 {
     res.arr.Add(res.gerCurObj());
 }
Exemplo n.º 9
0
 static void f_ba(myPaserResult res, myToken tk)
 {
     res.curObj.iCur += 2;
     res.curObj.dblQt = true;
 }
Exemplo n.º 10
0
 static void f_sa(myPaserResult res, myToken tk)
 {
     res.curObj.iStart = ++res.curObj.iCur;
 }
Exemplo n.º 11
0
 static void f_01(myPaserResult res, myToken tk)
 {
 }
Exemplo n.º 12
0
 static void f_ba(myPaserResult res, myToken tk)
 {
     res.curObj += "\"";
 }
Exemplo n.º 13
0
 static void f_bs(myPaserResult res, myToken tk)
 {
     res.count++;
     res.arr.Add(res.curObj);
 }
Exemplo n.º 14
0
 static void f_aa(myPaserResult res, myToken tk)
 {
     res.curObj += tk;
 }
Exemplo n.º 15
0
 static void f_ss(myPaserResult res, myToken tk)
 {
     res.count++;
     res.arr.Add("");
 }