45 points schindlabua 3 hours ago 21 comments
tikimcfee 1 hour ago | parent
Nice visuals btw. If I may be so bold: slightly smaller font and header would make scrolling through the bottom readable code snippets a little easier!
raddan 42 minutes ago | parent
I like combinator style parsers because 1) it’s really easy to think of a discrete parsing task as a function 2) tokenizing is mostly irrelevant 3) for pedagogical reasons, they make it easier for students to grasp the point of curried functions and partial application.
I even maintain a (mostly mature) parser combinator library for TypeScript for students in my research group to use.
monster_truck 1 hour ago | parent
adrianhqs 1 hour ago | parent
lacoolj 1 hour ago | parent
mrkeen 59 minutes ago | parent
type Parser<T> = (input: string) => [T, string]
This implies that it accepts a string and will return a T. Parsers might return a T.The article also starts with the concept of a 'partial parser', from which other (non-partial?) parsers can be constructed?
Or, and this is where the real power of partial parsers comes in: we wrap the chain up as a new parser of its own.
Nope, there's no distinction. If you combine partial parsers, you end up with a partial parser. If you combine full parsers (whatever that means) you end up with full parsers.(Ironically there is a fitting definition of 'partial' here: the function isn't well defined on all inputs. For some inputs, T is returned, on other inputs, maybe an error is thrown, who knows..)
schindlabua 56 minutes ago | parent
raddan 55 minutes ago | parent
rhdunn 34 minutes ago | parent
1. an item (`T`) for a successful parse;
2. an error (`ParseError`) for an unrecoverable parse error;
3. a partial item (`T with ParseError`) for a recoverable parse error or warning (known statically).
You may also want to differentiate between:
1. leaf nodes (numbers, identifiers, string literals, etc.);
2. composite/nested nodes (addition, multiplication, variable assignment, etc.).
pyrale 29 minutes ago | parent
If you always define T as some useful stuff or unit, your experience with parser combinators and their composition is going to be miserable.
debugnik 9 minutes ago | parent
If by partial we mean the parser can fail, not necessarily. optional(elem) and repeat(elem) are total if elem doesn't consume input on error, at least for a reasonable semantics of parser combinators (although we usually consider it a programmer error if elem matches the empty string in repeat(elem)).
justinnk 57 minutes ago | parent
„A Parser for Things is a function from Strings to Lists of Pairs of Things and Strings!“
stevefan1999 49 minutes ago | parent
mbaranturkmen 43 minutes ago | parent
marginalia_nu 41 minutes ago | parent
Seems like we're needlessly reintroducing limitations from the paper medium that don't exist in digital media for weird aesthetic reasons?
BackacheDescent 40 minutes ago | parent
smusamashah 18 minutes ago | parent
9dev 17 minutes ago | parent
64 bytes from 1.1.1.1: icmp_seq=3 ttl=52 time=47.1 ms
everything after the colon is key-value data, and throwing in a generic parser for `pKeyVal()` would make an even better point of how elegant the approach is.boomlinde 6 minutes ago | parent