Skip to content

Commit

Permalink
D: parse contract expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed May 1, 2023
1 parent 4622e54 commit 38ed914
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Units/parser-d.r/simple.d.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ main input.d /^void main(string[] args)$/;" f file:
member input.d /^ T member;$/;" m class:Class.CT file:
modulevar input.d /^ int modulevar;$/;" m file:
obj input.d /^Object obj;$/;" v
out_contract input.d /^T out_contract()$/;" f file:
qar input.d /^ int qar;$/;" m union:Struct.Union file:
quxx input.d /^ bool quxx;$/;" m union:Struct.Union file:
test.simple input.d /^module test.simple;$/;" M
Expand Down
4 changes: 4 additions & 0 deletions Units/parser-d.r/simple.d.d/input.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ static assert( num < TL.length, "Name '"~name~"' is not found");

__gshared int globalVar;

T out_contract()
out(r; r > 0) {} do {}

void main(string[] args)
in(args.length > 0)
{
auto foo = new Class(1337);

Expand Down
8 changes: 7 additions & 1 deletion parsers/c-based.c
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,13 @@ static bool skipPostArgumentStuff (
{
case KEYWORD_ATTRIBUTE: skipParens (); break;
case KEYWORD_THROW: skipParens (); break;
case KEYWORD_IF: if (isInputLanguage (Lang_d)) skipParens (); break;
case KEYWORD_IF: // D template constraint
// D contract expressions
case KEYWORD_IN:
case KEYWORD_OUT:
if (isInputLanguage (Lang_d))
skipParens ();
break;
case KEYWORD_TRY: break;

case KEYWORD_CONST:
Expand Down

0 comments on commit 38ed914

Please sign in to comment.