public void TestParseTypeSignature() { var s = StackParser.ParseTypeSignature("[int]"); // Assert.Equal(1, s.Count); Assert.Single(s); Assert.Equal(typeof(int), s.Pop()); s = StackParser.ParseTypeSignature("['int]"); Assert.Single(s); Assert.Equal(new Variable("int"), s.Pop()); s = StackParser.ParseTypeSignature("[bool 'a 'a]"); Assert.Equal(3, s.Count); Assert.Equal(typeof(bool), s.Pop()); Assert.Equal(new Variable("a"), s.Pop()); Assert.Equal(new Variable("a"), s.Pop()); Assert.Throws <ParseException>(() => StackParser.ParseTypeSignature("[BOO 'a 'a]")); }
public DetermineTypesInstruction(string consumes, string produces) : this(StackParser.ParseTypeSignature3(consumes), StackParser.ParseTypeSignature3(produces)) { }
public static Stack ToStack(this string repr) { return(StackParser.ParseStack(repr)); }
/** Parse a stack and convert symbols to instructions. */ public Stack ParseWithResolution(string s) { return(StackParser.ParseWithResolution(s, instructions)); }
public void TestParsePivot() { var s = "[[1 1 +]]".ToStack(); Assert.Equal(s, StackParser.ParsePivot("[+ 1 1 •]")); }