comp.lang.ada
 help / color / mirror / Atom feed
* Placement of pragmas in the grammar (language laywers required)
@ 2015-12-10  7:46 Lucretia
  2015-12-10 14:39 ` Lucretia
  2015-12-10 17:12 ` Bob Duff
  0 siblings, 2 replies; 6+ messages in thread
From: Lucretia @ 2015-12-10  7:46 UTC (permalink / raw)


Hi,

I'm looking at the 2012 grammar in the AARM/LRM and I just don't get why you designers don't include pragma's in their correct places instead of saying:

5 Pragmas are only allowed at the following places in a program: 
6 After a semicolon delimiter, but not within a formal_part or discriminant_part.
7/3 {AI05-0100-1} {AI05-0163-1} At any place where the syntax rules allow a construct defined by a syntactic category whose name ends with "declaration", "item", "statement", "clause", or "alternative", or one of the syntactic categories variant or exception_handler; but not in place of such a construct if the construct is required, or is part of a list that is required to have at least one such construct. Also at any place where a compilation_unit would be allowed.
7.1/3 {AI05-0163-1} In place of a statement in a sequence_of_statements.
7.2/3 {AI05-0100-1} At any place where a compilation_unit is allowed. 

etc.

So, for basic_declaration, do I add pragma as follows:

basic_declaration ::= 
     type_declaration | subtype_declaration
   | object_declaration | number_declaration
   | subprogram_declaration | abstract_subprogram_declaration
   | null_procedure_declaration | expression_function_declaration
   | package_declaration | renaming_declaration
   | exception_declaration | generic_declaration
   | generic_instantiation
   | pragma

and then inside each of the above *_declaration's, e.g. type_declaration:

type_declaration ::=  full_type_declaration
   | incomplete_type_declaration
   | private_type_declaration
   | private_extension_declaration
   | pragma

and again inside the above *_declaration's? And then, e.g component_item:

component_item ::= component_declaration | aspect_clause | pragma

and agian inside the component_declaration rule?

Seems overkill.

I must be missing something here.

Thanks,
Luke.



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

* Re: Placement of pragmas in the grammar (language laywers required)
  2015-12-10  7:46 Placement of pragmas in the grammar (language laywers required) Lucretia
@ 2015-12-10 14:39 ` Lucretia
  2015-12-10 17:12 ` Bob Duff
  1 sibling, 0 replies; 6+ messages in thread
From: Lucretia @ 2015-12-10 14:39 UTC (permalink / raw)


Having looked at this again, basic_declaration would derive to pragma from any of the enclosed *_declaration rules, in this case type_declaration, so having it in both cases does seem wrong.

Maybe I should start by adding it to the *_items first and see if any of the *_declaration rules would derive to pragma??

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

* Re: Placement of pragmas in the grammar (language laywers required)
  2015-12-10  7:46 Placement of pragmas in the grammar (language laywers required) Lucretia
  2015-12-10 14:39 ` Lucretia
@ 2015-12-10 17:12 ` Bob Duff
  2015-12-10 17:59   ` Lucretia
  1 sibling, 1 reply; 6+ messages in thread
From: Bob Duff @ 2015-12-10 17:12 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> I'm looking at the 2012 grammar in the AARM/LRM and I just don't get why you
> designers don't include pragma's in their correct places instead of saying:

I agree pragma placement should have been part of the BNF.

>...
> and again inside the above *_declaration's? And then, e.g component_item:
>
> component_item ::= component_declaration | aspect_clause | pragma

That won't work without additional checks, because of the "not in place
of" wording.  This is syntactically illegal:

    type T is record
        pragma Listing(Off);
    end record;

- Bob


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

* Re: Placement of pragmas in the grammar (language laywers required)
  2015-12-10 17:12 ` Bob Duff
@ 2015-12-10 17:59   ` Lucretia
  2015-12-10 18:19     ` Bob Duff
  0 siblings, 1 reply; 6+ messages in thread
From: Lucretia @ 2015-12-10 17:59 UTC (permalink / raw)


On Thursday, 10 December 2015 17:12:30 UTC, Bob Duff  wrote:

> That won't work without additional checks, because of the "not in place
> of" wording.  This is syntactically illegal:
> 
>     type T is record
>         pragma Listing(Off);
>     end record;

I would assume the check to make sure pragma is "not in place of" something should be part of the semantic steps?

So far, I've modified the following from the EBNF in the manual:

-- 3.8

component_item =
     component_declaration
   | aspect_clause
   | pragma
   ;

-- 3.11

basic_declarative_item =
     basic_declaration
   | aspect_clause
   | use_clause
   | pragma
   ;

-- 9.1

task_item =
     entry_declaration
   | aspect_clause
   | pragma
   ;

-- 9.4

protected_operation_item =
     subprogram_declaration
   | subprogram_body
   | entry_body
   | aspect_clause
   | pragma
   ;

-- 10.1.1

library_item =
    [private] library_unit_declaration
  | library_unit_body
  | [private] library_unit_renaming_declaration
  | pragma
  ;

The pragma in library_item seems to cover context_item as well due to:

compilation_unit ::= 
    context_clause library_item
  | context_clause subunit

Where library_item reduces to pragma and context_clause would reduce to the empty string. I mean, I could put it in every case, but that seems like overkill.

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

* Re: Placement of pragmas in the grammar (language laywers required)
  2015-12-10 17:59   ` Lucretia
@ 2015-12-10 18:19     ` Bob Duff
  2015-12-10 23:47       ` Randy Brukardt
  0 siblings, 1 reply; 6+ messages in thread
From: Bob Duff @ 2015-12-10 18:19 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

> I would assume the check to make sure pragma is "not in place of" something
> should be part of the semantic steps?

That's probably easiest.

- Bob

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

* Re: Placement of pragmas in the grammar (language laywers required)
  2015-12-10 18:19     ` Bob Duff
@ 2015-12-10 23:47       ` Randy Brukardt
  0 siblings, 0 replies; 6+ messages in thread
From: Randy Brukardt @ 2015-12-10 23:47 UTC (permalink / raw)


"Bob Duff" <bobduff@theworld.com> wrote in message 
news:87zixixj24.fsf@theworld.com...
> Lucretia <laguest9000@googlemail.com> writes:
>
>> I would assume the check to make sure pragma is "not in place of" 
>> something
>> should be part of the semantic steps?
>
> That's probably easiest.

I'm pretty sure that's what Janus/Ada does. (Either that or it doesn't check 
at all, 'cause it isn't practical or sensible (the error correction would be 
nasty) to put that rule into the grammar.)

                                Randy.


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

end of thread, other threads:[~2015-12-10 23:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10  7:46 Placement of pragmas in the grammar (language laywers required) Lucretia
2015-12-10 14:39 ` Lucretia
2015-12-10 17:12 ` Bob Duff
2015-12-10 17:59   ` Lucretia
2015-12-10 18:19     ` Bob Duff
2015-12-10 23:47       ` Randy Brukardt

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