Instantly share code, notes, and snippets.

View decompiler-battle.cs
// Original
public static Expression DispatchMethod(
Expression instance,
IEnumerable<MethodBase> methods,
IList<Type> typeArguments,
IList<Expression> arguments
return methods
.Select(m => m is MethodInfo && ((MethodInfo) m).IsExtensionMethod()
View TaskQueue-mod.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace ConsoleApplication1
public class TaskQueue : IDisposable
View parseq-new-msg.cs
var reply = Chars.Digit()
.Or(Chars.Any().Message("not a digit"))
.Select(cs => new string(cs.ToArray()))
reply.Status.Dump(); // Success
reply.Left.Value.Value.Dump(); // "12a3b"
// [ not a digit (1:5,1:5),
// not a digit (1:3,1:3),
View yacqexpr.cs
Expression.Call(typeof(Enumerable), "Sum", null,
Expression.Call(typeof(Enumerable), "Take", new [] { typeof(int), },
Expression.Call(typeof(Enumerable), "Reverse", new [] { typeof(int), },
Expression.Call(typeof(Enumerable), "Range", null, Expression.Constant(1), Expression.Constant(100))
), Expression.Constant(10)));
// ↓ Yacqize ↓
Expression expr2 = YacqExpression.TypeCandidate(typeof(Enumerable))
.Method("Range", Expression.Constant(1), Expression.Constant(100))
View gist:5693584
var s = new SymbolTable();
var parser = YacqCombinators.List(Combinator.Sequence(
YacqCombinators.Reduce().Is<int>().As(s, "x"),
YacqCombinators.Reduce().Is<int>().As(s, "y")
)).Select(_ => Expression.Add(s["x"], s["y"]));
var stream = YacqServices.ReadAll("(+ 123 (+ 45 6))").AsStream();
View ReduceWhile.cs
/// <summary>
/// Reduces this node until the type of result is specified expression node type, with (if possible) additional symbol tables.
/// </summary>
/// <param name="expression">The reducing expression.</param>
/// <param name="symbols">The additional symbol table for reducing.</param>
/// <param name="expectedType">The type which is expected as the type of reduced expression.</param>
/// <returns>The reduced expression which has specified type, or <c>null</c> if this expression is never reduced as specified type.</returns>
public static TExpression ReduceWhile<TExpression>(this Expression expression, SymbolTable symbols = null, Type expectedType = null)
where TExpression : Expression
View grammar.cs
// Yacq
private static readonly Grammar _standard = new Grammar();
public static Grammar Standard
return _standard;
View a.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace TinyTweet
View get-attrs.cs
public static Attribute[] GetAttributes(Expression expr)
switch (expr.NodeType)
case ExpressionType.MemberAccess:
return Attribute.GetCustomAttributes(((MemberExpression) expr).Member);
case ExpressionType.Invoke:
return Attribute.GetCustomAttributes(((MethodCallExpression) expr).Method);
case ExpressionType.Index:
return Attribute.GetCustomAttributes(((IndexExpression) expr).Indexer);
View parseq-typename.cs
public class TypeName
public String Namespace { get; set; }
public String[] HierarchicalNames { get; set; }
public override String ToString()
return String.Join("+", this.HierarchicalNames);