Skip to content

Commit dce3fe7

Browse files
authored
added lambda
1 parent 8478fc6 commit dce3fe7

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

SourceCode/ast/LambdaExpression.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OwnLang.ast.lib
8+
{
9+
public class LambdaExpression : Expression
10+
{
11+
public Statement statement;
12+
13+
public LambdaExpression(Statement statement)
14+
{
15+
this.statement = statement;
16+
}
17+
18+
public Value eval()
19+
{
20+
return new StatementValue(statement);
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OwnLang.ast.lib
8+
{
9+
public class StatementStatement : Statement
10+
{
11+
private Statement body;
12+
13+
public StatementStatement(Statement body)
14+
{
15+
this.body = body;
16+
}
17+
18+
void Statement.execute()
19+
{
20+
body.execute();
21+
}
22+
}
23+
}

SourceCode/ast/StatementValue.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OwnLang.ast.lib
8+
{
9+
public class StatementValue : Value
10+
{
11+
private Statement value;
12+
13+
public StatementValue(Statement value)
14+
{
15+
this.value = value;
16+
}
17+
18+
public Statement asStatement()
19+
{
20+
return value;
21+
}
22+
23+
public char asChar()
24+
{
25+
throw new NotImplementedException();
26+
}
27+
28+
public double asDouble()
29+
{
30+
throw new NotImplementedException();
31+
}
32+
33+
public int asNumber()
34+
{
35+
throw new NotImplementedException();
36+
}
37+
38+
public string asString()
39+
{
40+
throw new NotImplementedException();
41+
}
42+
43+
public TokenType type()
44+
{
45+
return TokenType.LAMBDA;
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)