comp.lang.ada
 help / color / mirror / Atom feed
* Syntax question:  new with a constrained subtype indication
@ 2005-04-25 15:44 James Alan Farrell
  2005-04-25 16:07 ` Alex R. Mosteo
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: James Alan Farrell @ 2005-04-25 15:44 UTC (permalink / raw)


Hi all,
I'm working on software to analyze Ada programs using ASIS.  As such I 
need to make sure I handle all cases in the syntax (and I'm finding that 
in past assignments I've used only a small portion of the whole language!)

I'm currently working on a piece of code to analyze allocator 
expressions (ARM 4.8).  The entire relevant syntax is:

  4.8:
  allocator ::=
     new subtype_indication | new qualified_expression

  3.2.2:
  subtype_indication ::=  subtype_mark [constraint]

  3.2.2:
  subtype_mark ::= subtype_name

  3.2.2:
  constraint ::= scalar_constraint | composite_constraint

  3.2.2:
  scalar_constraint ::=
       range_constraint | digits_constraint | delta_constraint

  3.5
  range_constraint ::= range range

  3.5:
  range ::=  range_attribute_reference
    | simple_expression .. simple_expression

 From this, it appears I should be able to do something like:

package body Mod1 is

    procedure Proc1 is

       type Vector    is array (Integer range <>) of Float;
       type VectorPtr is access Vector;

       V : VectorPtr;

    begin
       V := new Vector range 1 .. 10;
    end Proc1;

end mod1;

Using gnat 3.15p, I get this error:

mod1.adb:15:23: incorrect constraint for this kind of type
gnatmake: "mod1.adb" compilation error

I suspect this is a type issue, but let me know if there is something 
incorrect in the syntax.

The thing is, I've read 4.8 of the *annotated* ARM and I don't see 
anything to say I cannot do this.  So what am I missing?  Is there 
something, other than that document, that spells out the allowed types 
of constraint?

Thank you,
James Alan Farrell



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-04-26 14:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-25 15:44 Syntax question: new with a constrained subtype indication James Alan Farrell
2005-04-25 16:07 ` Alex R. Mosteo
2005-04-25 16:34   ` James Alan Farrell
2005-04-25 18:52     ` Martin Krischik
2005-04-26 14:17       ` James Alan Farrell
2005-04-25 16:18 ` Adrien Plisson
2005-04-25 16:37   ` James Alan Farrell
2005-04-25 17:16     ` Adrien Plisson
2005-04-25 16:34 ` Martin Krischik
2005-04-25 19:03   ` James Alan Farrell
2005-04-25 17:02 ` Martin Dowie
2005-04-25 17:22   ` Adrien Plisson
2005-04-25 23:28     ` Randy Brukardt

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