-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
257 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Shapoco.Calctus.Model.Evaluations; | ||
using Shapoco.Calctus.Model.Types; | ||
using Shapoco.Calctus.Model.Parsers; | ||
using Shapoco.Calctus.Model.Functions; | ||
|
||
namespace Shapoco.Calctus.Model.Expressions { | ||
class AsterExpr : Expr{ | ||
public readonly IdExpr Id; | ||
public AsterExpr(Token t, IdExpr id) : base(t) { | ||
Id = id; | ||
} | ||
|
||
public override bool CausesValueChange() => true; | ||
|
||
protected override Val OnEval(EvalContext e) { | ||
throw new EvalError(e, Token, "Unexpected asterisk."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Shapoco.Calctus.Model.Evaluations; | ||
using Shapoco.Calctus.Model.Parsers; | ||
using Shapoco.Calctus.Model.Types; | ||
using Shapoco.Calctus.Model.Functions; | ||
|
||
namespace Shapoco.Calctus.Model.Expressions { | ||
class ParenthesisExpr : Expr { | ||
public readonly Expr[] Exprs; | ||
public readonly Token Comma; | ||
|
||
public override bool CausesValueChange() => Exprs.Any(p => p.CausesValueChange()); | ||
|
||
public ParenthesisExpr(Token token, Token firstComma, Expr[] exprs) : base(token) { | ||
this.Exprs = exprs; | ||
this.Comma = firstComma; | ||
} | ||
|
||
protected override Val OnEval(EvalContext e) { | ||
if (Exprs.Length == 0) { | ||
throw new EvalError(e, Token, "Empty expression"); | ||
} | ||
else if (Exprs.Length >=2) { | ||
throw new EvalError(e, Comma, "')' is expected."); | ||
} | ||
else { | ||
return Exprs[0].Eval(e); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.