Skip to content

Commit 39db9d6

Browse files
authored
Merge pull request #2214 from WalterBright/SpecialKeyword
move Special Keywords to expression.dd merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>
2 parents 007e845 + bcc8b91 commit 39db9d6

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

spec/expression.dd

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,8 @@ $(GNAME PrimaryExpression):
11061106
$(GLINK TypeidExpression)
11071107
$(GLINK IsExpression)
11081108
$(D $(LPAREN)) $(GLINK Expression) $(D $(RPAREN))
1109+
$(GLINK SpecialKeyword)
11091110
$(GLINK2 traits, TraitsExpression)
1110-
$(GLINK2 traits, SpecialKeyword)
11111111
)
11121112

11131113
$(H3 $(LNAME2 identifier, .Identifier))
@@ -2091,6 +2091,67 @@ void main()
20912091

20922092
)
20932093

2094+
$(H2 $(LNAME2 specialkeywords, Special Keywords))
2095+
2096+
$(GRAMMAR
2097+
$(GNAME SpecialKeyword):
2098+
$(D $(RELATIVE_LINK2 specialkeywords, __FILE__))
2099+
$(D $(RELATIVE_LINK2 specialkeywords, __FILE_FULL_PATH__))
2100+
$(D $(RELATIVE_LINK2 specialkeywords, __MODULE__))
2101+
$(D $(RELATIVE_LINK2 specialkeywords, __LINE__))
2102+
$(D $(RELATIVE_LINK2 specialkeywords, __FUNCTION__))
2103+
$(D $(RELATIVE_LINK2 specialkeywords, __PRETTY_FUNCTION__))
2104+
)
2105+
2106+
2107+
$(P $(CODE __FILE__) and $(CODE __LINE__) expand to the source
2108+
file name and line number at the point of instantiation. The path of
2109+
the source file is left up to the compiler. )
2110+
2111+
$(P $(CODE __FILE_FULL_PATH__) expands to the absolute source
2112+
file name at the point of instantiation.)
2113+
2114+
$(P $(CODE __MODULE__) expands to the module name at the point of
2115+
instantiation.)
2116+
2117+
$(P $(CODE __FUNCTION__) expands to the fully qualified name of the
2118+
function at the point of instantiation.)
2119+
2120+
$(P $(CODE __PRETTY_FUNCTION__) is similar to $(CODE __FUNCTION__),
2121+
but also expands the function return type, its parameter types,
2122+
and its attributes.)
2123+
2124+
$(P Example:)
2125+
2126+
---
2127+
module test;
2128+
import std.stdio;
2129+
2130+
void test(string file = __FILE__, size_t line = __LINE__,
2131+
string mod = __MODULE__, string func = __FUNCTION__,
2132+
string pretty = __PRETTY_FUNCTION__,
2133+
string fileFullPath = __FILE_FULL_PATH__)
2134+
{
2135+
writefln("file: '%s', line: '%s', module: '%s',\nfunction: '%s', " ~
2136+
"pretty function: '%s',\nfile full path: '%s'",
2137+
file, line, mod, func, pretty, fileFullPath);
2138+
}
2139+
2140+
int main(string[] args)
2141+
{
2142+
test();
2143+
return 0;
2144+
}
2145+
---
2146+
2147+
$(P Assuming the file was at /example/test.d, this will output:)
2148+
2149+
$(CONSOLE
2150+
file: 'test.d', line: '13', module: 'test',
2151+
function: 'test.main', pretty function: 'int test.main(string[] args)',
2152+
file full path: '/example/test.d'
2153+
)
2154+
20942155
$(H2 $(LNAME2 associativity, Associativity and Commutativity))
20952156

20962157
$(P An implementation may rearrange the evaluation of expressions

spec/lex.dd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,12 +1029,12 @@ $(MULTICOLS 4,
10291029
$(LINK2 statement.html#WhileStatement, $(D while))
10301030
$(LINK2 statement.html#WithStatement, $(D with))
10311031

1032-
$(LINK2 traits.html#specialkeywords, $(D __FILE__))
1033-
$(LINK2 traits.html#specialkeywords, $(D __FILE_FULL_PATH__))
1034-
$(LINK2 traits.html#specialkeywords, $(D __MODULE__))
1035-
$(LINK2 traits.html#specialkeywords, $(D __LINE__))
1036-
$(LINK2 traits.html#specialkeywords, $(D __FUNCTION__))
1037-
$(LINK2 traits.html#specialkeywords, $(D __PRETTY_FUNCTION__))
1032+
$(LINK2 expression.html#specialkeywords, $(D __FILE__))
1033+
$(LINK2 expression.html#specialkeywords, $(D __FILE_FULL_PATH__))
1034+
$(LINK2 expression.html#specialkeywords, $(D __MODULE__))
1035+
$(LINK2 expression.html#specialkeywords, $(D __LINE__))
1036+
$(LINK2 expression.html#specialkeywords, $(D __FUNCTION__))
1037+
$(LINK2 expression.html#specialkeywords, $(D __PRETTY_FUNCTION__))
10381038

10391039
$(LINK2 attribute.html#gshared, $(D __gshared))
10401040
$(LINK2 traits.html, $(D __traits))

spec/traits.dd

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ $(GNAME TraitsArgument):
7474
$(GLINK2 declaration, Type)
7575
)
7676

77-
$(P Additionally special keywords are provided for debugging purposes:)
78-
79-
$(GRAMMAR
80-
$(GNAME SpecialKeyword):
81-
$(D $(RELATIVE_LINK2 specialkeywords, __FILE__))
82-
$(D $(RELATIVE_LINK2 specialkeywords, __FILE_FULL_PATH__))
83-
$(D $(RELATIVE_LINK2 specialkeywords, __MODULE__))
84-
$(D $(RELATIVE_LINK2 specialkeywords, __LINE__))
85-
$(D $(RELATIVE_LINK2 specialkeywords, __FUNCTION__))
86-
$(D $(RELATIVE_LINK2 specialkeywords, __PRETTY_FUNCTION__))
87-
)
88-
8977
$(H2 $(GNAME isArithmetic))
9078

9179
$(P If the arguments are all either types that are arithmetic types,
@@ -1068,55 +1056,6 @@ void main()
10681056
)
10691057

10701058

1071-
$(H2 $(LNAME2 specialkeywords, Special Keywords))
1072-
1073-
$(P $(CODE __FILE__) and $(CODE __LINE__) expand to the source
1074-
file name and line number at the point of instantiation. The path of
1075-
the source file is left up to the compiler. )
1076-
1077-
$(P $(CODE __FILE_FULL_PATH__) expands to the absolute source
1078-
file name at the point of instantiation.)
1079-
1080-
$(P $(CODE __MODULE__) expands to the module name at the point of
1081-
instantiation.)
1082-
1083-
$(P $(CODE __FUNCTION__) expands to the fully qualified name of the
1084-
function at the point of instantiation.)
1085-
1086-
$(P $(CODE __PRETTY_FUNCTION__) is similar to $(CODE __FUNCTION__),
1087-
but also expands the function return type, its parameter types,
1088-
and its attributes.)
1089-
1090-
$(P Example usage:)
1091-
1092-
-----
1093-
module test;
1094-
import std.stdio;
1095-
1096-
void test(string file = __FILE__, size_t line = __LINE__,
1097-
string mod = __MODULE__, string func = __FUNCTION__,
1098-
string pretty = __PRETTY_FUNCTION__,
1099-
string fileFullPath = __FILE_FULL_PATH__)
1100-
{
1101-
writefln("file: '%s', line: '%s', module: '%s',\nfunction: '%s', " ~
1102-
"pretty function: '%s',\nfile full path: '%s'",
1103-
file, line, mod, func, pretty, fileFullPath);
1104-
}
1105-
1106-
int main(string[] args)
1107-
{
1108-
test();
1109-
return 0;
1110-
}
1111-
-----
1112-
1113-
$(P Assuming the file was at /example/test.d, this will output:)
1114-
1115-
$(CONSOLE
1116-
file: 'test.d', line: '13', module: 'test',
1117-
function: 'test.main', pretty function: 'int test.main(string[] args)',
1118-
file full path: '/example/test.d'
1119-
)
11201059

11211060
$(SPEC_SUBNAV_PREV_NEXT version, Conditional Compilation, errors, Error Handling)
11221061
)

0 commit comments

Comments
 (0)