Parsing Expressions 6
This commit is contained in:
parent
2de4381fae
commit
d937226553
5 changed files with 177 additions and 6 deletions
|
|
@ -8,6 +8,7 @@ import taggedalgebraic;
|
|||
|
||||
import jlox.token;
|
||||
import jlox.tokentype;
|
||||
import jlox.util;
|
||||
|
||||
abstract class Expr{
|
||||
interface Visitor(R){
|
||||
|
|
@ -20,10 +21,7 @@ abstract class Expr{
|
|||
static foreach(T; rTypes)
|
||||
abstract T accept(Visitor!T visitor);
|
||||
private template defCtorAndAccept(){
|
||||
this(Args...)(auto ref Args args){
|
||||
static foreach(i, a; args)
|
||||
this.tupleof[i] = a;
|
||||
}
|
||||
mixin defaultCtor;
|
||||
static foreach(T; rTypes)
|
||||
override T accept(Visitor!T visitor) => visitor.visit(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue