예제 #1
0
 public YyLexer(ErrorHandler eh)
 {
     this.erh = eh;
     this.UsingCat(UnicodeCategory.OtherPunctuation);
     this.m_gencat = UnicodeCategory.OtherPunctuation;
     Tfactory tfactory = new Tfactory(this, "TOKEN", new TCreator(this.Tokenfactory));
 }
예제 #2
0
파일: dfa.cs 프로젝트: jswiatkowski/cognipy
        public void Check(Lexer yyl, ref TOKEN tok)
        {
            string str = tok.yytext;

            if (m_upper)
            {
                str = str.ToUpper();
            }
            object o = m_wds[str];

            if (o == null)
            {
                return;
            }
            tok = (TOKEN)Tfactory.create((string)o, yyl);
        }
예제 #3
0
파일: ResWds.cs 프로젝트: m33p/radegast
        public void Check(Lexer yyl, ref TOKEN tok)
        {
            string str = tok.yytext;

            if (this.m_upper)
            {
                str = str.ToUpper();
            }
            object wd = this.m_wds[(object)str];

            if (wd == null)
            {
                return;
            }
            tok = (TOKEN)Tfactory.create((string)wd, yyl);
        }
예제 #4
0
        bool TryActions(Dfa dfa, ref TOKEN tok)
        {
            int len = m_pch - m_startMatch;

            if (len == 0)
            {
                return(false);
            }
            if (m_startMatch + len <= m_buf.Length)
            {
                yytext = m_buf.Substring(m_startMatch, len);
            }
            else // can happen with {EOF} rules
            {
                yytext = m_buf.Substring(m_startMatch);
            }
            // actions is a list of old-style actions for this DFA in order of priority
            // there is a list because of the chance that any of them may REJECT
            Dfa.Action a      = dfa.m_actions;
            bool       reject = true;

            while (reject && a != null)
            {
                int action = a.a_act;
                reject = false;
                a      = a.a_next;
                if (a == null && dfa.m_tokClass != "")
                { // last one might not be an old-style action
                    if (m_debug)
                    {
                        Console.WriteLine("creating a " + dfa.m_tokClass);
                    }
                    tok = (TOKEN)Tfactory.create(dfa.m_tokClass, this);
                }
                else
                {
                    tok = m_tokens.OldAction(this, ref yytext, action, ref reject);
                    if (m_debug && !reject)
                    {
                        Console.WriteLine("Old action " + action);
                    }
                }
            }
            return(!reject);
        }
예제 #5
0
파일: Lexer.cs 프로젝트: m33p/radegast
        private bool TryActions(Dfa dfa, ref TOKEN tok)
        {
            int length = this.m_pch - this.m_startMatch;

            if (length == 0)
            {
                return(false);
            }
            this.yytext = this.m_startMatch + length > this.m_buf.Length ? this.m_buf.Substring(this.m_startMatch) : this.m_buf.Substring(this.m_startMatch, length);
            Dfa.Action action = dfa.m_actions;
            bool       reject = true;

            while (reject && action != null)
            {
                int aAct = action.a_act;
                reject = false;
                action = action.a_next;
                if (action == null && dfa.m_tokClass != "")
                {
                    if (this.m_debug)
                    {
                        Console.WriteLine("creating a " + dfa.m_tokClass);
                    }
                    tok = (TOKEN)Tfactory.create(dfa.m_tokClass, this);
                }
                else
                {
                    tok = this.m_tokens.OldAction(this, ref this.yytext, aAct, ref reject);
                    if (this.m_debug && !reject)
                    {
                        Console.WriteLine("Old action " + (object)aAct);
                    }
                }
            }
            return(!reject);
        }