digitalmars.D.learn - Where is pragma Declaration in the grammar?
- Stefan Koch (17/17) Dec 04 2020 Hi,
- Paul Backus (13/24) Dec 04 2020 They're under Attribute:
- Stefan Koch (3/31) Dec 04 2020 The Decldef is not optional.
- Paul Backus (4/23) Dec 04 2020 That's what I thought at first too, but according to the official
Hi,
today I've been dusting my SDC fork and implemented a rudimentary
version of pragma(msg).
I could pragmaStatement
as in void f()
{
pragma(msg, typeof(f));
}
but not a declaration as in
pragma(msg, typeof(f))
without a function body.
there is a StaticAssert is in the grammar under declaration,
pragma is not.
Maybe it's stated differently?
Any help is appreciated.
Cheers,
Stefan
Dec 04 2020
On Saturday, 5 December 2020 at 00:57:04 UTC, Stefan Koch wrote:
Hi,
today I've been dusting my SDC fork and implemented a
rudimentary version of pragma(msg).
I could pragmaStatement
as in void f()
{
pragma(msg, typeof(f));
}
but not a declaration as in
pragma(msg, typeof(f))
without a function body.
They're under Attribute:
https://dlang.org/spec/grammar.html#Attribute
The syntax tree for `pragma(msg, typeof(f))` in a declaration
context would be:
DeclDef
AttributeSpecifier
Attribute
Pragma
pragma(msg, typeof(f))
DeclarationBlock
DeclDef
;
Dec 04 2020
On Saturday, 5 December 2020 at 02:59:58 UTC, Paul Backus wrote:On Saturday, 5 December 2020 at 00:57:04 UTC, Stefan Koch wrote:The Decldef is not optional. This is for pragmas like pragma mangle that affect symbols.Hi, today I've been dusting my SDC fork and implemented a rudimentary version of pragma(msg). I could pragmaStatement as in void f() { pragma(msg, typeof(f)); } but not a declaration as in pragma(msg, typeof(f)) without a function body.They're under Attribute: https://dlang.org/spec/grammar.html#Attribute The syntax tree for `pragma(msg, typeof(f))` in a declaration context would be: DeclDef AttributeSpecifier Attribute Pragma pragma(msg, typeof(f)) DeclarationBlock DeclDef ;
Dec 04 2020
On Saturday, 5 December 2020 at 03:55:52 UTC, Stefan Koch wrote:On Saturday, 5 December 2020 at 02:59:58 UTC, Paul Backus wrote:That's what I thought at first too, but according to the official grammar, the DeclDef can be a single semicolon (i.e., empty): https://dlang.org/spec/grammar.html#DeclDefThey're under Attribute: https://dlang.org/spec/grammar.html#Attribute The syntax tree for `pragma(msg, typeof(f))` in a declaration context would be: DeclDef AttributeSpecifier Attribute Pragma pragma(msg, typeof(f)) DeclarationBlock DeclDef ;The Decldef is not optional. This is for pragmas like pragma mangle that affect symbols.
Dec 04 2020








Paul Backus <snarwin gmail.com>