View Seq Extensions.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seq = | |
type [< RequireQualifiedAccess >] SplitByOption = Exclude | IncludeInFirst | IncludeInSecond | |
type [< RequireQualifiedAccess >] private SplitSubUnfoldState<'T> = | |
| PostValue of 'T * SplitSubUnfoldState<'T> | |
| Start of seqNo: int * start: int | |
| Started of tryNext: (unit -> 'T option) * bingo: ('T -> unit) * finish: (unit -> unit) | |
| Finish | |
type [< RequireQualifiedAccess >] private SplitUnfoldState<'T> = { |
View gist:00b6c75451ce729ecdf37d22c2dfd5b9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Regex = | |
open System.Text.RegularExpressions | |
type REx = REx of string with | |
member r.txt = let (REx t) = r in t | |
static member (+)(REx a, REx b) = REx(a + b) | |
let rex (REx v) = v | |
let (|Regex|_|) (REx pattern) input = |
View Msal.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" | |
#I @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades" | |
#I @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper\lib\net461" | |
#I @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper.UI\lib\net461" | |
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" | |
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" | |
#r @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper\lib\net461\WebSharper.Core.dll" | |
#r @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper\lib\net461\WebSharper.Core.JavaScript.dll" | |
#r @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper\lib\net461\WebSharper.Collections.dll" | |
#r @"D:\Abe\CIPHERWorkspace\FSharpStation\packages\WebSharper\lib\net461\WebSharper.InterfaceGenerator.dll" |
View gist:de365ab0e98be6d91df5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void button1_Click(object sender,EventArgs e) { | |
Parser P = new Parser(this.textBox1.Text); | |
if (P.Parse()) | |
this.textBox2.Text = "Success!"; | |
else | |
this.textBox2.Text = "Failed at " + P.Position.ToString(); | |
} |
View gist:c61c9da3055ff7dc3b1b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
namespace SimpleParser { | |
class Parser { | |
public Parser(string Text) { | |
Input = Text; |
View gist:0ef3dcf02b4714183c1e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String Input = null; | |
int LastPosition = -1; | |
int SpaceLength = 0; | |
void SkipSpacesComments() { | |
if (Position == LastPosition) return; | |
LastPosition = Position; | |
CurrentString = Input.Substring(Position); | |
string RegEx = "^([ \\t\\n\\r]|\\/\\*.*?\\*\\/)*"; | |
Match M = Regex.Match(CurrentString, RegEx); |
View gist:ec8c5b8332c267871ea1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int Position = 0; | |
String Token = null; | |
string CurrentString; | |
bool R(string RegEx) { | |
SkipSpacesComments(); | |
Match M = Regex.Match(CurrentString, "^" + RegEx | |
, RegexOptions.IgnoreCase); | |
if (M.Success) { | |
Token = CurrentString.Substring(0, M.Length); |
View gist:5829c37fe6e0c48ae561
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool Stopping = false; | |
bool P(rule R) { | |
if (Stopping) return false; | |
int StartingPosition = Position; | |
bool Result = R(); | |
if (!Result && StartingPosition != Position) | |
Stopping = true; | |
return Result; | |
} |
View grammarCSharp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wexpr = () => P(() => expr(0) && EOS() ); | |
expr = (L) => P(() => mexpr() && expr2(L) ); | |
expr2 = (L) => P(() => L < 4 && C("+") && expr(4) && expr2(L) ) | |
|| P(() => L < 4 && C("-") && expr(4) && expr2(L) ) | |
|| P(() => L < 5 && C("*") && expr(5) && expr2(L) ) | |
|| P(() => L < 5 && C("/") && expr(5) && expr2(L) ) | |
|| P(() => L < 2 && C("<=") && expr(2) && expr2(L) ) | |
|| P(() => L < 2 && C(">=") && expr(2) && expr2(L) ) |
View gist:c0ce24e4d3c29a119f7d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wexpr => expr(0) EOS | |
expr(L) => mexpr expr2(L) | |
expr2(L)=> L < 4 "+" expr(4) expr2(L) | |
=> L < 4 "-" expr(4) expr2(L) | |
=> L < 5 "*" expr(5) expr2(L) | |
=> L < 5 "/" expr(5) expr2(L) | |
=> L < 2 "<=" expr(2) expr2(L) | |
=> L < 2 ">=" expr(2) expr2(L) |