Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..0611571 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +fifth-postulate.nl \ No newline at end of file diff --git a/guide/.nojekyll b/guide/.nojekyll new file mode 100644 index 0000000..f173110 --- /dev/null +++ b/guide/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/guide/404.html b/guide/404.html new file mode 100644 index 0000000..3c68f72 --- /dev/null +++ b/guide/404.html @@ -0,0 +1,218 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +There are a lot of resources on the internet about parser combinators. We have a curated list of resources on the wiki page accompanying this workshop.
+ +In this section you will find solutions some of the exercises of this workshop.
+The reason we included these answers is to be self-contained. We would much prefer if you would discuss your solutions with others and discuss the reasons why you decided to answer the questions in the manner you did.
+{"banan", "bananana", "ban", ...}
addition ::= number ("+" number)?
+
+S -> U -> T
.t
is the twentiest letter in the alphabet. Including the digits '0' through '9' we have 30 options. So base 30 is an option. Note that there are other options as well.parse
that accepts a string and returns a list of paris of T
and string
.Some of the questions in this chapter ask for an implementation. See the example code accompanying this material for possible ways of implementing the succeed
and fail
parsers.
succeed("Hello, World!")
is a parser that does not consume the any input and always returns "Hello, World"
.() -> string -> [()]
.string -> [(string, string)]
.startsWith
function but does allow indexing into the string I would implement it by examining the 0th character of the string.string -> string -> [(string, string)]
. At least this is what the examples show. It would be better if the examples would return the actual character. Then the signature would be char -> string -> [(char, string)]
.characterA = character('A')
.string -> string -> [(string, string)]
.(char -> boolean) -> string -> [(char, string)]
character(target) = satisfy(actual => actual == target)
(string -> [(A, string)]) -> (string -> [(B, string)]) -> string -> [((A, B), string)]
. Or with the parser T
alias: parser A -> parser B -> parser (A, B)
.parser T -> parser T
.(A -> B) -> parser A -> parser B
.(() -> parser T) -> parser T
.parser T -> parser [T]
.(T, [T] -> [T]
.many1(parser) = map(combine, and(parser, many(parser)))
.parser T -> parser ()
.parser T -> parser T
.parser T -> parser T
.greedy1(parser) = map(combine, and(parser, greedy(parser)))
.[parser T] -> parser [T]
. This forces all the parsers to return similar things.[parser T] -> parser T
.parser ()
.parser T -> parser T
.parser L -> parser T -> parser R -> parser T
.parser string -> parser T -> parser [T]
.parser T -> parser [T]
.parser Tree
.string -> T
. A dictionary.parser ((string -> T) -> string)
. This signature assumes that a key is not present in the dictionary, the key is used as a default.++ +This paragraph intentionally is left blank
+
The sources for this workshop and related files can be found at
+ + +You are looking at the guide accompanying a workshop about parser combinators.
+Parser combinators is an interesting topic that allows a developer to parse complex input into rich data-structures in a modular fashion. This form of parsing is possible in any language that supports higher order functions. Luckily that includes a lot of languages, like Java, Python, JavaScript and many more.
+We believe in learning by doing, so you can expect to be asked to open your favourite editor or integrated development environment and gain first-hand practical experience with parser combinators, by following along this guide. Exercises along the way help cement your new found knowledge making parser combinators a valuable tool in your toolkit.
+ +