comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Indefinite type while writing a recursive descent parser
Date: Thu, 02 Nov 2017 21:21:07 +0200
Date: 2017-11-02T21:21:07+02:00	[thread overview]
Message-ID: <otfr73$18d6$1@gioia.aioe.org> (raw)

I am writing a recursive descent parser. (It parses RDF relations rather 
than a text file, but that's not very important for my question, except for 
the fact that I cannot use an existing text parser package.)

While parsing I need to extract data (numbers, booleans, arrays, etc.)

My first idea was:

generic
   type Data_Type(<>) is private;
package Base_Predicate is
   type Base_Predicate_Parser is tagged
      record
         Predicate: URI_Type;
         Data: access Data_Type;
      end record;
   not overriding
   procedure Parse (Parser: Base_Predicate_Parser; Node: Node_Type) is null;
end Base_Predicate;

I wanted my node parsers to assign to Data.all if Data/=null.

But then I realized that this won't work for an indefinite Data_Type.

So I have an Ada (2012) specific issue on possible ways to assign data while 
parsing. Please give advice.

I could use Indefinite_Holders everywhere but this would be a step into the 
direction of being like a dynamic language instead of strong typing system 
which Ada offers. I don't like to make a step in this direction.

-- 
Victor Porton - http://portonvictor.org


             reply	other threads:[~2017-11-02 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 19:21 Victor Porton [this message]
2017-11-02 19:27 ` Indefinite type while writing a recursive descent parser Victor Porton
2017-11-02 19:29   ` Victor Porton
2017-11-02 19:39     ` Victor Porton
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox