Skip to content

Commit 027c099

Browse files
authored
Merge pull request #3708 from ntrel/d-contracts
D: parse contract expressions
2 parents 08b7295 + 4b085a8 commit 027c099

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Units/parser-d.r/simple.d.d/expected.tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ main input.d /^void main(string[] args)$/;" f file:
2323
member input.d /^ T member;$/;" m class:Class.CT file:
2424
modulevar input.d /^ int modulevar;$/;" m file:
2525
obj input.d /^Object obj;$/;" v
26+
out_contract input.d /^void out_contract()$/;" f file:
2627
qar input.d /^ int qar;$/;" m union:Struct.Union file:
2728
quxx input.d /^ bool quxx;$/;" m union:Struct.Union file:
2829
test.simple input.d /^module test.simple;$/;" M

Units/parser-d.r/simple.d.d/input.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ static assert( num < TL.length, "Name '"~name~"' is not found");
9595

9696
__gshared int globalVar;
9797

98+
void out_contract()
99+
out(r; r > 0) {}
100+
98101
void main(string[] args)
102+
in(args.length > 0)
99103
{
100104
auto foo = new Class(1337);
101105

parsers/c-based.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,13 @@ static bool skipPostArgumentStuff (
20842084
{
20852085
case KEYWORD_ATTRIBUTE: skipParens (); break;
20862086
case KEYWORD_THROW: skipParens (); break;
2087-
case KEYWORD_IF: if (isInputLanguage (Lang_d)) skipParens (); break;
2087+
case KEYWORD_IF: // D template constraint
2088+
// D contract expressions
2089+
case KEYWORD_IN:
2090+
case KEYWORD_OUT:
2091+
if (isInputLanguage (Lang_d))
2092+
skipParens ();
2093+
break;
20882094
case KEYWORD_TRY: break;
20892095

20902096
case KEYWORD_CONST:

0 commit comments

Comments
 (0)