public bool addSubTree(int q_index, SSYaccStackElement q_ele) { if ((q_index < 0) || (q_index >= this.m_subTreeSize)) { return(false); } this.m_subTree[q_index] = q_ele; return(true); }
public bool doReduce() { this.m_element = this.reduce(this.m_production, this.m_productionSize); if (this.m_element == null) { return(true); } this.pop(this.m_productionSize); return(this.goTo(this.m_leftside)); }
public SSYaccStackElement addSubTree() { SSYaccStackElement element = this.stackElement(); element.createSubTree(this.m_productionSize); for (int i = 0; i < this.m_productionSize; i++) { element.addSubTree(i, this.elementFromProduction(i)); } return(element); }
public bool doShift() { this.m_element = this.shift(this.m_lookahead); if (this.m_element == null) { return(true); } this.m_element.setLexeme(this.m_lookahead); this.m_element.setState(this.m_state); this.push(); return(this.doGetLexeme(true)); }
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(); }
public bool parse() { if (this.doGetLexeme(true)) { return(true); } Label_000B: if (!this.m_abort) { switch (this.m_action) { case 0: if (!this.doShift()) { goto Label_000B; } return(true); case 1: if (!this.doError()) { goto Label_000B; } if (!this.m_endOfInput) { return(false); // goto TryAgainAfterError; } return(true); case 2: if (!this.doReduce()) { goto Label_000B; } return(true); case 3: this.m_treeRoot = this.m_element; return(this.m_error); case 4: if (!this.doConflict()) { goto Label_000B; } return(true); } } return(true); }
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); }
public bool push(SSYaccStackElement q_element) { this.m_stack.push(q_element); return(true); }