Exemple #1
0
        public bool doConflict()
        {
            this.m_cache = 0;
            int num = 0;

            num = this.m_lexSubtable.lookup(num, this.m_lookahead.token());
            while ((this.m_larLookahead = this.getLexemeCache()) != null)
            {
                num = this.m_lexSubtable.lookup(num, this.m_larLookahead.token());
                if (num == -1)
                {
                    break;
                }
                SSLexFinalState state = this.m_lexSubtable.lookupFinal(num);
                if (state.isFinal())
                {
                    if (state.isReduce())
                    {
                        this.m_production = state.token();
                        SSYaccTableProd prod = this.m_table.lookupProd(this.m_production);
                        this.m_leftside       = prod.leftside();
                        this.m_productionSize = prod.size();
                        return(this.doReduce());
                    }
                    this.m_state = state.token();
                    return(this.doShift());
                }
            }
            return(this.doLarError());
        }
Exemple #2
0
        public SSLexLexeme remove()
        {
            SSLexLexeme lexeme = null;

            if (this.Count != 0)
            {
                lexeme = (SSLexLexeme)this.Dequeue();
            }
            return(lexeme);
        }
Exemple #3
0
 public SSYacc(SSYaccTable q_table, SSLex q_lex)
 {
     this.m_lex        = q_lex;
     this.m_abort      = false;
     this.m_error      = false;
     this.m_table      = q_table;
     this.m_endOfInput = false;
     this.m_endLexeme  = new SSLexLexeme("eof", -1);
     this.m_endLexeme.setToken(-1);
     this.m_stack       = new SSYaccStack(5, 5);
     this.m_lexemeCache = new SSYaccCache();
     this.m_element     = this.stackElement();
     this.push();
 }
Exemple #4
0
 public bool doGetLexeme(bool q_look)
 {
     this.m_lookahead = this.m_lexemeCache.remove();
     if (this.m_lookahead == null)
     {
         return(this.getLexeme(q_look));
     }
     if (this.larLookahead(this.m_lookahead))
     {
         return(true);
     }
     if (q_look)
     {
         this.lookupAction(this.m_state, this.m_lookahead.token());
     }
     return(false);
 }
Exemple #5
0
 public bool getLexeme(bool q_look)
 {
     if (this.m_endOfInput)
     {
         return(true);
     }
     this.m_lookahead = this.nextLexeme();
     if (this.m_lookahead == null)
     {
         this.m_endOfInput = true;
         this.m_lookahead  = this.m_endLexeme;
     }
     if (q_look)
     {
         this.lookupAction(this.m_state, this.m_lookahead.token());
     }
     return(false);
 }
Exemple #6
0
        public void findKeyword(SSLexLexeme z_lexeme)
        {
            int length = 0;
            int num2   = 0;

            length = this.m_keyTables[0].m_keys.Length;
            while (length > num2)
            {
                int    num3;
                int    index = num2 + ((length - num2) / 2);
                string strB  = this.m_keyTables[0].m_keys[index];
                string str2  = new string(z_lexeme.lexeme());
                if (this.m_keyTables[0].m_index[(index * 3) + 1] == 1)
                {
                    num3 = str2.ToLower().CompareTo(strB);
                }
                else
                {
                    num3 = str2.CompareTo(strB);
                }
                if (num3 < 0)
                {
                    if (num2 == index)
                    {
                        return;
                    }
                    length = index;
                }
                else
                {
                    if (num3 == 0)
                    {
                        z_lexeme.setToken(this.m_keyTables[0].m_index[index * 3]);
                        return;
                    }
                    if (length == (index + 1))
                    {
                        return;
                    }
                    num2 = index;
                }
            }
        }
Exemple #7
0
        public SSLexLexeme getLexemeCache()
        {
            SSLexLexeme endLexeme = null;

            if ((this.m_cache != -1) && this.m_lexemeCache.hasElements())
            {
                endLexeme = (SSLexLexeme)this.m_lexemeCache.Dequeue();
            }
            if (endLexeme == null)
            {
                this.m_cache = -1;
                endLexeme    = this.nextLexeme();
                if (endLexeme == null)
                {
                    endLexeme = this.m_endLexeme;
                }
                this.m_lexemeCache.Enqueue(endLexeme);
            }
            return(endLexeme);
        }
Exemple #8
0
        public bool syncErr()
        {
            SSYaccTableRow row3;
            SSYaccSet      set = new SSYaccSet();

            for (int i = 0; i < this.m_stack.getSize(); i++)
            {
                int            num2 = ((SSYaccStackElement)this.m_stack.elementAt(i)).state();
                SSYaccTableRow row  = this.m_table.lookupRow(num2);
                if (row.hasSync() || row.hasSyncAll())
                {
                    for (int j = 0; j < row.action(); j++)
                    {
                        SSYaccTableRowEntry entry = row.lookupEntry(j);
                        if (row.hasSyncAll() || entry.hasSync())
                        {
                            int num4 = entry.token();
                            set.add(num4);
                        }
                    }
                }
                if (row.hasError())
                {
                    SSYaccTableRow row2 = this.m_table.lookupRow(row.lookupError().entry());
                    for (int k = 0; k < row2.action(); k++)
                    {
                        int num6 = row2.lookupEntry(k).token();
                        set.add(num6);
                    }
                }
            }
            if (set.Count == 0)
            {
                return(true);
            }
            while (!set.locate(this.m_lookahead.token()))
            {
                if (this.doGetLexeme(false))
                {
                    return(true);
                }
            }
Label_012B:
            row3 = this.m_table.lookupRow(this.m_state);
            if (row3.hasError())
            {
                this.lookupAction(row3.lookupError().entry(), this.m_lookahead.token());
                if (this.m_action != 1)
                {
                    SSLexLexeme lexeme = new SSLexLexeme("%error", -2);
                    this.m_element = this.stackElement();
                    this.m_element.setLexeme(lexeme);
                    this.m_element.setState(row3.lookupError().entry());
                    this.push();
                    goto Label_0226;
                }
            }
            if (row3.hasSyncAll())
            {
                this.lookupAction(this.m_state, this.m_lookahead.token());
                if (this.m_action == 1)
                {
                    goto Label_0219;
                }
                goto Label_0226;
            }
            if (row3.hasSync() && (row3.lookupAction(this.m_lookahead.token()) != null))
            {
                this.lookupAction(this.m_state, this.m_lookahead.token());
                goto Label_0226;
            }
Label_0219:
            this.pop(1);
            goto Label_012B;
Label_0226:
            return(false);
        }
Exemple #9
0
 public virtual SSYaccStackElement shift(SSLexLexeme q_lexeme)
 {
     return(this.stackElement());
 }
Exemple #10
0
 public bool larLookahead(SSLexLexeme q_lex)
 {
     return(false);
 }
Exemple #11
0
 public bool larError(int q_state, SSLexLexeme q_look, SSLexLexeme q_larLook)
 {
     return(this.error(q_state, q_look));
 }
Exemple #12
0
 public virtual bool error(int q_state, SSLexLexeme q_look)
 {
     return(this.syncErr());
 }
Exemple #13
0
 public void setLexeme(SSLexLexeme q_lexeme)
 {
     this.m_lexeme = q_lexeme;
 }
Exemple #14
0
        public SSLexLexeme next()
        {
            bool            flag   = false;
            SSLexLexeme     lexeme = null;
            SSLexFinalState state  = null;

Label_0006:
            this.m_state = 0;
            flag         = false;
            SSLexMark mark = null;

            state = this.m_table.lookupFinal(this.m_state);
            if (state.isFinal())
            {
                this.m_consumer.mark();
            }
            while (this.m_consumer.next())
            {
                flag = true;
                this.m_currentChar[0] = this.m_consumer.getCurrent();
                this.m_table.translateClass(this.m_currentChar);
                this.m_state = this.m_table.lookup(this.m_state, this.m_currentChar[0]);
                if (this.m_state == -1)
                {
                    break;
                }
                SSLexFinalState state2 = this.m_table.lookupFinal(this.m_state);
                if (state2.isFinal())
                {
                    mark  = this.m_consumer.mark();
                    state = state2;
                }
                if (state2.isContextStart())
                {
                    this.m_consumer.mark();
                }
            }
            if (flag)
            {
                if (state.isContextEnd() && (mark != null))
                {
                    this.m_consumer.flushEndOfLine(mark);
                }
                if (state.isIgnore() && (mark != null))
                {
                    this.m_consumer.flushLexeme(mark);
                    if (state.isPop() && state.isPush())
                    {
                        this.m_table.gotoSubtable(state.pushIndex());
                    }
                    else if (state.isPop())
                    {
                        this.m_table.popSubtable();
                    }
                    else if (state.isPush())
                    {
                        this.m_table.pushSubtable(state.pushIndex());
                    }
                    goto Label_0006;
                }
                if (!state.isFinal() || (mark == null))
                {
                    lexeme = new SSLexLexeme(this.m_consumer);
                    if (this.error(lexeme))
                    {
                        return(lexeme);
                    }
                    this.m_consumer.flushLexeme();
                    lexeme = null;
                    goto Label_0006;
                }
                if (state.isPop() && state.isPush())
                {
                    this.m_table.gotoSubtable(state.pushIndex());
                }
                else if (state.isPop())
                {
                    this.m_table.popSubtable();
                }
                else if (state.isPush())
                {
                    this.m_table.pushSubtable(state.pushIndex());
                }
                if ((state.isStartOfLine() && (this.m_consumer.line() != 0)) && (this.m_consumer.offset() != 0))
                {
                    this.m_consumer.flushStartOfLine(mark);
                }
                lexeme = new SSLexLexeme(this.m_consumer, state, mark);
                if (state.isKeyword())
                {
                    this.m_table.findKeyword(lexeme);
                }
                this.m_consumer.flushLexeme(mark);
                if (!this.complete(lexeme))
                {
                    lexeme = null;
                    goto Label_0006;
                }
            }
            return(lexeme);
        }
Exemple #15
0
 public virtual bool error(SSLexLexeme q_lexeme)
 {
     return(false);
 }
Exemple #16
0
 public virtual bool complete(SSLexLexeme q_lexeme)
 {
     return(true);
 }