In this tutorial we're going to build a set of parser combinators.
We'll answer the above question in 2 steps.
- What is a parser?
- and, what is a parser combinator?
So first question: What is parser?
public interface IConstraint<T> | |
{ | |
bool Satisfies(T value); | |
} | |
public class Constrained<T, Constraint> | |
where Constraint : IConstraint<T>, new() | |
{ | |
public static bool TryCreate(T val, out Constrained<T, Constraint> result) | |
{ | |
var c = new Constraint(); |
public static class Option | |
{ | |
public static Option<T> Some<T>(T item) | |
=> new Option<T>(item); | |
public static Option<T> None<T>() | |
=> new Option<T>(); | |
} | |
public struct Option<T> | |
{ | |
private readonly T value; |
<!doctype html> | |
<title>Site Maintenance</title> | |
<style> | |
body { text-align: center; padding: 150px; } | |
h1 { font-size: 50px; } | |
body { font: 20px Helvetica, sans-serif; color: #333; } | |
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
a { color: #dc8100; text-decoration: none; } | |
a:hover { color: #333; text-decoration: none; } | |
</style> |