Skip to content

Instantly share code, notes, and snippets.

public class NameListPage
{
public Name : string
{
mutable _name : string;
get
{
server.GetName(name => { ServerName = name });
_name
}
class XInt { public F() : void {} }
class XString { public G() : void {} }
class XObject
{
public static @()(_ : XObject, x : int) : XInt { XInt(); }
public static @()(_ : XObject, x : int) : XString { XString(); }
public X() : void {}
}
@NN---
NN--- / gist:4445011
Last active December 10, 2015 14:08
/// <summary>
/// Transforms system type identifier with generic arguments to the parse-tree expression.
/// Number of elemnts in args must match number of generic parameters in the systemType.
/// </summary>
/// <example>
/// "NS.A`2+B`1", ["X", "Y", "Z"] ==> <[ NS.A.[X, Y].B.[Z] ]>
/// </example>
public static FromSystemType(manager : ManagerClass, systemType : string, args : list[string]) : PExpr
{
if (string.IsNullOrEmpty (systemType)) <[]>
Main() : void
{
def type = "A.B`2+C`1";
def args = ["X", "Y", "Z"].ToList();
def re = Regex(@"`(\d)");
def sp = re.Split(type.Replace('+', '.'), int.MaxValue);
def sb = StringBuilder();
// Calculator.CalcParser
private mutable mutable __GENERATED_PEG__Memeoize_Pos__start__ : int
// Calculator.CalcParser
private mutable mutable __GENERATED_PEG__Memeoize_End__start__ : int
// Calculator.CalcParser
private mutable mutable __GENERATED_PEG__Memeoize_Res__start__ : int
// Calculator.CalcParser
private __GENERATED_PEG__RULE__sumOrSubx__(position : int, text : string) : int * int
{
mutable result;
def p = unchecked
{
mutable (c : char);
_ = c;
{
_ = "CaptureH[sumOrSub](CaptureA[(int, List[(Chars, Void, int)])](CaptureA[(int, List[(Chars, Void, int)])](CaptureA[int](mulOrDiv) CaptureA[List[(Chars, Void, int)]](CaptureA[(Chars, Void, int)](CaptureA[(Chars, Void, int)](CaptureA[Chars]('+' / '-') CaptureA[Void](spaces) CaptureA[int](mulOrDiv)))*))))";
private __GENERATED_PEG__RULE__startx__(position : int, text : string) : int
{
unchecked
{
mutable (c : char);
_ = c;
{
mutable token_1;
if (__GENERATED_PEG__Memeoize_Pos__start__ == position)