> Did you you already try it or do you just assume that it doesn't work? Somehow, I missed BaseTree.AddChild. That'll do the trick. CommonTree.Parent initially jumped out at me, and I chased the wrong rabbit. My bad.
----- Original Message ----- From: "Johannes Luber" <[email protected]> To: "Ben Gillis" <[email protected]> Cc: <[email protected]> Sent: Thursday, January 22, 2009 1:17 AM Subject: Re: [antlr-interest] CSharp2: serialize/deserialize as AST > Ben Gillis schrieb: >>> Doesn't the usual approach via Binary/XML formatters work? If >> Yes, with a CommonTree wrapper or SurrogateSelector. >> >> But, how do you handle the CommonTree.Parent member upon >> deserialization? Again, looking at the ANTLR code, it's a pointer, >> right? Merely restoring a serialized value won't work for that. > > Actually, I don't know how pointers are treated, but I'd be surprised if > the standard formatters don't handle this case themselves as it is a > general case with using references instead value types in member fields. > Did you you already try it or do you just assume that it doesn't work? > > If it really doesn't work, then you could create your own (De)Serializer > and replace pointers by an object id field. IIRC, on CodeProject is an > article on doing so. > > Johannes >> >> >> >> ----- Original Message ----- From: "Johannes Luber" <[email protected]> >> To: "Ben Gillis" <[email protected]> >> Cc: <[email protected]> >> Sent: Thursday, January 22, 2009 12:41 AM >> Subject: Re: [antlr-interest] CSharp2: serialize/deserialize as AST >> >> >>> Ben Gillis schrieb: >>>> I want to serialize/deserialize an AST, binary format, using C#. >>>> >>>> But, I'm not clear how the AST is reconstructed on deserialization >>>> concerning the IToken.Parent. >>>> >>>> I see some serialization in ANTLR, e.g. >>>> Antlr.Runtime.Debug.DebugEventSocketProxy.SerializeToken. This would >>>> be >>>> a pointer; therefore, some recursive approach to using built-in >>>> AddChild >>>> methods or something must be done??? >>>> >>>> Before I brew up something, perhaps this is (a) already done/available? >>>> (b) easier than I'm making it??? >>> >>> Doesn't the usual approach via Binary/XML formatters work? If the >>> classes in 3.1.1 don't have the required attributes, then get a >>> snapshot, as those should be in the repo files. >>> >>> Johannes >>>> >>>> Thanks, >>>> Ben >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------ >>>> >>>> >>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest >>>> Unsubscribe: >>>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address >>> >> > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
