Exemple #1
0
        public ScriptTokenizer(Regex inlineRx, List<string> skipGroups)
            : base(null, skipGroups)
        {
            Regex startRx, escRx, endRx;

            startRx = new Regex(@"^""");
            escRx = new Regex(@"\\.");
            endRx = new Regex(@"""");
            BlockTokenizer stringLiteral = new BlockTokenizer(startRx, escRx, endRx, "Str");

            startRx = new Regex(@"^/\*");
            escRx = new Regex(@"$^");       //  no mutch with anything, not using this parameter
            endRx = new Regex(@"\*/");
            BlockTokenizer commentBlock = new BlockTokenizer(startRx, escRx, endRx, "Cmt");

            startRx = inlineRx;

            Tokenizers = new TokenizerBase[]{
                stringLiteral
                , commentBlock
                , new InlineTokenizer(startRx)
            };

            foreach (TokenizerBase t in Tokenizers) t.Pos = this.Pos;
        }
Exemple #2
0
        public string TestNext(TestCase c)
        {
            Regex startRx, escRx, endRx;
            TokenizerBase tkz;
            startRx = new Regex(@"^/\.");
            escRx = new Regex(@"$^");
            endRx = new Regex(@",/");
            tkz = new BlockTokenizer(startRx, escRx, endRx, "Cmt");

            Token t;
            using (LineBufferedReader r = LineBufferedReader.GetInstanceWithText(c.Input, ""))
            {
                tkz.Init(r);
                t = tkz.Cur;
            }
            return TokenEx.ToUTStr(t) + "/Pos=" + tkz.Pos.Value.ToString();
            //return t.ToString() + "/Pos=" + tkz.Pos.Value.ToString();
        }