From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,61e050d0d34345a2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Data structures for syntax trees Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <20100201213441.503839d5.tero.koskinen@iki.fi> Date: Mon, 1 Feb 2010 21:03:44 +0100 Message-ID: NNTP-Posting-Date: 01 Feb 2010 21:03:43 CET NNTP-Posting-Host: b6fea09f.newsspool3.arcor-online.net X-Trace: DXC=B?Ne^Dca6`i]BlmkiiU@BiMcF=Q^Z^V3h4Fo<]lROoRa8kF On Mon, 1 Feb 2010 21:34:41 +0200, Tero Koskinen wrote: > And what kind of data structures others have used to present > syntax trees? I am using access types to non-controlled class-wide objects allocated in an arena pool. A syntax tree is usually removed as a whole. Tree_Pool : Stack_Storage.Pool (2048, 128); type Node is abstract tagged limited null record; function Image (Item : Node) return String is abstract; type Node_Ptr is access Node'Class; for Node_Ptr'Storage_Pool use Tree_Pool; type Term is abstract new Node with record Location : Parsers.Multiline_Source.Location; end record; type Expression (Count : Positive) is new Node with record Operation : Operations; Location : Parsers.Multiline_Source.Location; Operands : Argument_List (1..Count); end record; And so on. The example can be found here: http://www.dmitry-kazakov.de/ada/components.htm#12.9 I cannot tell if that works with Janus, I don't have the compiler. Alternatively I would use a directed graph. That again would be access types to the arena pool of the graph nodes, parent-child relations maintained implicitly by the pool. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de