@@ -0,0 +1,833 @@
+package com.dwarfartisan.parsec;%0A%0Aimport java.io.EOFException;%0Aimport java.util.Optional;%0A%0A/**%0A * Created by Mars Liu on 16/9/18.%0A * Option accept a parsec&lt;T, E, Status, Tran&gt; and%0A * return new one parsec&lt;Optional&lt;T&gt;, E, Status, Tran&gt;.%0A * If the parser fail, Option parsec just return option.empty without Exception thrown.%0A */%0Apublic class Option%3CT, E, Status, Tran%3E implements Parsec%3COptional%3CT%3E, E, Status, Tran%3E %7B%0A    private Parsec%3CT, E, Status, Tran%3E parser;%0A%0A    public Option(Parsec%3CT, E, Status, Tran%3E parser) %7B%0A        this.parser = parser;%0A    %7D%0A%0A    @Override%0A    public Optional%3CT%3E parse(State%3CE, Status, Tran%3E s) throws EOFException, ParsecException %7B%0A        try%7B%0A            return Optional.of(parser.parse(s));%0A        %7D catch (Exception e) %7B%0A            return Optional.empty();%0A        %7D%0A    %7D%0A%7D%0A

add optional