Skip to content

Commit 4b085a8

Browse files
committed
D: parse contract expressions
1 parent 4622e54 commit 4b085a8

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
@@ -90,7 +90,11 @@ static assert( num < TL.length, "Name '"~name~"' is not found");
9090

9191
__gshared int globalVar;
9292

93+
void out_contract()
94+
out(r; r > 0) {}
95+
9396
void main(string[] args)
97+
in(args.length > 0)
9498
{
9599
auto foo = new Class(1337);
96100

parsers/c-based.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,13 @@ static bool skipPostArgumentStuff (
20722072
{
20732073
case KEYWORD_ATTRIBUTE: skipParens (); break;
20742074
case KEYWORD_THROW: skipParens (); break;
2075-
case KEYWORD_IF: if (isInputLanguage (Lang_d)) skipParens (); break;
2075+
case KEYWORD_IF: // D template constraint
2076+
// D contract expressions
2077+
case KEYWORD_IN:
2078+
case KEYWORD_OUT:
2079+
if (isInputLanguage (Lang_d))
2080+
skipParens ();
2081+
break;
20762082
case KEYWORD_TRY: break;
20772083

20782084
case KEYWORD_CONST:

0 commit comments

Comments
 (0)