public new static object Serialise(object o, Serialiser s) { if (s == null) { return((object)new ParserOldAction()); } ParserOldAction parserOldAction = (ParserOldAction)o; if (s.Encode) { ParserAction.Serialise((object)parserOldAction, s); s.Serialise((object)parserOldAction.m_action); return((object)null); } ParserAction.Serialise((object)parserOldAction, s); parserOldAction.m_action = (int)s.Deserialise(); return((object)parserOldAction); }
public override void OldAction(ParserOldAction a) { int ch = '{'; a.m_symtype = CSymbol.SymType.oldaction; a.m_action = ++action; a.m_initialisation = GetBracketedSeq(ref ch, '}'); a.m_sym = (CSymbol)m_prod.m_lhs; NextNonWhite(out ch); if (ch == ';' || ch == '|') { // an old action at the end is converted into a simple action m_lexer.yytext = "%"; ParserSimpleAction sa = new ParserSimpleAction(this); SimpleAction(sa); NewConstructor(ref sa.m_sym, ")" + a.m_initialisation); a.m_sym = (CSymbol)sa; sa.yytext += sa.m_sym.yytext; a.yytext = "#" + sa.yytext; a.m_action = -1; // mark the old action for deletion } }
public void RhSide(Production p) { CSymbol s; ParserOldAction a = null; // last old action seen while (m_tok != null) { if (m_tok.Matches(";")) { break; } if (m_tok.Matches("|")) { break; } if (m_tok.Matches(":")) { Advance(); p.m_alias[m_tok.yytext] = p.m_rhs.Count; Advance(); } else if (m_tok is PrecReference) { if (p.m_rhs.Count == 0) { erh.Error(new CSToolsException(21, "%prec cannot be at the start of a right hand side")); } PrecReference pr = (PrecReference)m_tok; CSymbol r = (CSymbol)p.m_rhs[p.m_rhs.Count - 1]; r.m_prec = pr.precref.m_prec; Advance(); } else { s = (CSymbol)m_tok; if (s.m_symtype == CSymbol.SymType.oldaction) { if (a != null) { Error(42, s.pos, "adjacent actions"); } a = (ParserOldAction)s; if (a.m_action < 0) { // an OldAction that has been converted to a SimpleAction: discard it s = a.m_sym; // add the SimpleAction instead s.m_symtype = CSymbol.SymType.simpleaction; ParserSimpleAction sa = (ParserSimpleAction)s; } else // add it to the Actions function { m_actions += String.Format("\ncase {0} : {1} break;", a.m_action, a.m_initialisation); } a = null; } else if (s.m_symtype != CSymbol.SymType.simpleaction) { s = ((CSymbol)m_tok).Resolve(); } p.AddToRhs(s); Advance(); } } Precedence.Check(p); }
public abstract void OldAction(ParserOldAction a);