diff --git a/FAILang/FAILangVisitor.cs b/FAILang/FAILangVisitor.cs index edb1fc2..a8c8a44 100644 --- a/FAILang/FAILangVisitor.cs +++ b/FAILang/FAILangVisitor.cs @@ -167,6 +167,12 @@ public override IType VisitDef([NotNull] FAILangParser.DefContext context) public override IType VisitExpression([NotNull] FAILangParser.ExpressionContext context) { + return VisitWhere(context.where()); + } + + public override IType VisitWhere([NotNull] FAILangParser.WhereContext context) + { + // TODO: Implement this return VisitBoolean(context.boolean()); } diff --git a/FAILang/Grammar/FAILang.g4 b/FAILang/Grammar/FAILang.g4 index de734aa..672e28b 100644 --- a/FAILang/Grammar/FAILang.g4 +++ b/FAILang/Grammar/FAILang.g4 @@ -24,7 +24,7 @@ imp def : update=UPDATE? memoize=MEMO? name L_PAREN fparams R_PAREN EQ expression - | update=UPDATE? name ( EQ | ASSIGN ) expression + | update=UPDATE? name EQ expression | update=UPDATE memoize=MEMO name ; @@ -49,6 +49,11 @@ param ; expression + : where + ; + +where + //: boolean (WHERE (name EQ expression COMMA)* name EQ expression)? : boolean ; @@ -123,7 +128,7 @@ indexer ; piecewise - : L_CURL condition+ (expression OTHERWISE SEMI_COLON)? + : L_CURL condition+ (expression OTHERWISE SEMI_COLON?)? ; condition @@ -270,9 +275,6 @@ ELIPSIS ARROW : '->' ; -ASSIGN - : ':=' - ; NUMBER : DIGIT* '.' DIGIT+ (E '-'? DIGIT+)? @@ -292,9 +294,6 @@ UNDEFINED : 'undefined' ; -LAMBDA - : 'lambda' - ; UPDATE : 'update' ; @@ -317,6 +316,10 @@ USING : 'using' ; +WHERE + : 'where' + ; + NAME : ( UPPERCASE diff --git a/FAILang/Types/Unevaluated/FunctionExpression.cs b/FAILang/Types/Unevaluated/FunctionExpression.cs index 894385d..95ba1c4 100644 --- a/FAILang/Types/Unevaluated/FunctionExpression.cs +++ b/FAILang/Types/Unevaluated/FunctionExpression.cs @@ -63,7 +63,7 @@ public IType Evaluate(Dictionary lookups) { return new BakedExpression(new FunctionExpression(func, args), lookups); } - if (func is IOperable n1 && args.Length == 1) + if (func is Number n1 && args.Length == 1) return new BinaryOperatorExpression(BinaryOperator.MULTIPLY, n1, args[0].Item1).Evaluate(lookups); return new Error("SyntaxError", $"You can't call an object of type {func.TypeName}."); }