Unescape() публичный Метод

public Unescape ( string s ) : string
s string
Результат string
Пример #1
0
        void SimSet(out CharSet s)
        {
            int n1, n2;

            s = new CharSet();
            if (la.kind == 1)
            {
                Get();
                CharClass c = tab.FindCharClass(t.val);
                if (c == null)
                {
                    SemErr("undefined name");
                }
                else
                {
                    s.Or(c.set);
                }
            }
            else if (la.kind == 3)
            {
                Get();
                string name = t.val;
                name = tab.Unescape(name.Substring(1, name.Length - 2));
                foreach (char ch in name)
                {
                    if (dfa.ignoreCase)
                    {
                        s.Set(char.ToLower(ch));
                    }
                    else
                    {
                        s.Set(ch);
                    }
                }
            }
            else if (la.kind == 5)
            {
                Char(out n1);
                s.Set(n1);
                if (la.kind == 22)
                {
                    Get();
                    Char(out n2);
                    for (int i = n1; i <= n2; i++)
                    {
                        s.Set(i);
                    }
                }
            }
            else if (la.kind == 23)
            {
                Get();
                s = new CharSet(); s.Fill();
            }
            else
            {
                SynErr(46);
            }
        }
Пример #2
0
        // match string against current automaton; store it either as a fixedToken or as a litToken
        public void MatchLiteral(string s, Symbol sym)
        {
            s = tab.Unescape(s.Substring(1, s.Length - 2));
            int    i, len = s.Length;
            State  state = firstState;
            Action a     = null;

            for (i = 0; i < len; i++)       // try to match s against existing DFA
            {
                a = FindAction(state, s[i]);
                if (a == null)
                {
                    break;
                }
                state = a.target.state;
            }
            // if s was not totally consumed or leads to a non-final state => make new DFA from it
            if (i != len || state.endOf == null)
            {
                state    = firstState; i = 0; a = null;
                dirtyDFA = true;
            }
            for (; i < len; i++)       // make new DFA for s[i..len-1], ML: i is either 0 or len
            {
                State to = NewState();
                NewTransition(state, to, Node.chr, s[i], Node.normalTrans);
                state = to;
            }
            Symbol matchedSym = state.endOf;

            if (state.endOf == null)
            {
                state.endOf = sym;
            }
            else if (matchedSym.tokenKind == Symbol.fixedToken || (a != null && a.tc == Node.contextTrans))
            {
                // s matched a token with a fixed definition or a token with an appendix that will be cut off
                parser.SemErr("tokens " + sym.name + " and " + matchedSym.name + " cannot be distinguished");
            }
            else         // matchedSym == classToken || classLitToken
            {
                matchedSym.tokenKind = Symbol.classLitToken;
                sym.tokenKind        = Symbol.litToken;
            }
        }