public void NullaryFunctionIsApplication() { var grammar = Grammar.FromFile(grammarFile); var expr1 = grammar.ReadExpression("asdfasdf asd"); //Assert.IsInstanceOf<Function> (expr1); Assert.IsInstanceOf <ApplicationExpression>(expr1); var expr2 = grammar.ReadExpression("asdf (xaxa lala) (xaxa lala kaka)"); var vstr = new Expression.Visitor <string>(); Func <IEnumerable <Expression>, IEnumerable <string> > ag = args => args.Select(a => a.Accept(vstr)); vstr.fVisitApplication = (fn, args) => $"_{fn}({String.Join(",", ag(args))})"; var outString2 = expr2.Accept(vstr); //Assert.AreEqual ("_asdf", outString); Assert.AreEqual("_asdf(_xaxa(_lala()),_xaxa(_lala(),_kaka()))", outString2); }
internal abstract R Accept <R>(Expression.Visitor <R> vistor);