Skip to content

Instantly share code, notes, and snippets.

@takeshik
Created June 14, 2011 04:02
Show Gist options
  • Save takeshik/1024292 to your computer and use it in GitHub Desktop.
Save takeshik/1024292 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Linq.Expressions;
using XSpect.Yacq.LanguageServices;
namespace yacqrun
{
class Program
{
static void Main(string[] args)
{
var result = ((Expression<Func<int, Func<int, Func<int, int>>>>) new Reader(@"
; this is comment (to end of line)
; All parameters is typed as System.Int32, yet.
; Following code returns x => y => z => x + y + z .
(\ [x] (\ [y] (\ [z] (+ x y z))))"
)
// This is just a charm, or like an idiom. Don't care.
.Read()
.Select(e => e.Reduce())
.ToArray()
.Last()
).Compile()
// Invoke!
(100)(20)(3);
// Output the result with Console class.
((Expression<Action<int>>) new Reader(@"
(import-type Console 'System.Console') ; import System.Console class as ID 'Console'
(\ [x] (Console.(WriteLine x)))"
).Read().Select(e => e.Reduce()).ToArray().Last()).Compile()(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment