Skip to content

Commit

Permalink
Merge pull request #284 from BBasile/issue-280
Browse files Browse the repository at this point in the history
Add support for new mixin syntax, close #280
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Oct 15, 2018
2 parents b367597 + 5fdc900 commit 9445394
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/dparse/ast.d
Expand Up @@ -2093,9 +2093,9 @@ final class MixinExpression : ExpressionNode
{
override void accept(ASTVisitor visitor) const
{
mixin (visitIfNotNull!(assignExpression));
mixin (visitIfNotNull!(argumentList));
}
/** */ ExpressionNode assignExpression;
/** */ ArgumentList argumentList;
mixin OpEquals;
}

Expand Down
2 changes: 1 addition & 1 deletion src/dparse/formatter.d
Expand Up @@ -2074,7 +2074,7 @@ class Formatter(Sink)
debug(verbose) writeln("MixinExpression");

put("mixin (");
format(mixinExpression.assignExpression);
format(mixinExpression.argumentList);
put(")");
}

Expand Down
4 changes: 2 additions & 2 deletions src/dparse/parser.d
Expand Up @@ -4173,7 +4173,7 @@ class Parser
* Parses a MixinExpression
*
* $(GRAMMAR $(RULEDEF mixinExpression):
* $(LITERAL 'mixin') $(LITERAL '$(LPAREN)') $(RULE assignExpression) $(LITERAL '$(RPAREN)')
* $(LITERAL 'mixin') $(LITERAL '$(LPAREN)') $(RULE argumentList) $(LITERAL '$(RPAREN)')
* ;)
*/
MixinExpression parseMixinExpression()
Expand All @@ -4182,7 +4182,7 @@ class Parser
auto node = allocator.make!MixinExpression;
expect(tok!"mixin");
expect(tok!"(");
mixin(parseNodeQ!(`node.assignExpression`, `AssignExpression`));
mixin(parseNodeQ!(`node.argumentList`, `ArgumentList`));
expect(tok!")");
return node;
}
Expand Down
8 changes: 5 additions & 3 deletions test/pass_files/declarations.d
Expand Up @@ -16,9 +16,9 @@ auto a = [1, 2, 3];
auto a = [a:1, b:2, c:3];
auto a = b, c = d;
static if (true)
int a;
int a;
else
int b;
int b;

debug void foo();
debug(something) void foo();
Expand All @@ -36,7 +36,7 @@ mixin something!A;
mixin duff!(i, j, delegate { foo13(i); });
mixin typeof(something!A).x;
template mix(){
int x;
int x;
}
mixin .mix;
__vector(int[4]) intVector;
Expand Down Expand Up @@ -90,3 +90,5 @@ struct Foo(T);
union Foo(T);
class Foo(T);
interface Foo(T);

mixin("auto a = 1 + ", 1, ";");
1 change: 1 addition & 0 deletions test/pass_files/expressions.d
Expand Up @@ -32,6 +32,7 @@ auto a = function() { return 100; };
auto a = delegate() { return 100; };
auto a = function { return 100; };
auto a = delegate { return 100; };
auto a = mixin("1 + ", 1);
void foo()
{
a = b;
Expand Down
1 change: 1 addition & 0 deletions test/pass_files/statements.d
Expand Up @@ -71,4 +71,5 @@ label:
{
assert(i-- > 0);
}
mixin("auto a = 1 +", 1);
}

0 comments on commit 9445394

Please sign in to comment.