006: elm/parser episode artwork

EPISODE · May 25, 2020 · 1H 4M

006: elm/parser

from Elm Radio · host Dillon Kearns

What is a parser?yacc/lexAST (Abstract Syntax Tree) vs. CST (Concrete Syntax Tree)JSON decoding vs. parsingJSON decoding is validating a data structure that has already been parsed. Assumes a valid structure.elm/parserHaskell parsec library - initially used for the Elm compiler, now uses custom parserWhat is a parser?One character at a timeTakes input string, turns it into structued data (or error)ComittingBacktrackable parserschompIf and chompWhileParser.oneOfBenchmarkingelm-explorations/benchmarkBenchmark before making assumptions about where performance bottlenecks areWrite unit tests for your parserGFM table parsing live streamParser.succeedElm regex vs elm parserIndications that you might be better off with parserLots of regex capture groupsWant very precise error messagesGetting source code locationsParser.getRow and getColParser.getSourceParser.loopLoop docs in elm/parserLooping allows you to track state and parse groups of expressionsLoop over repeated expression type, tell it termination condition with Step type (Loop and Done)Error MessagesYou can fail with Parser.problemParser.Advanced module is designed to give you more precise context and error messages on failureParser.Advanced.inContextGetting Started with a Parser ProjectWrite lots of unit tests with elm-test!There's likely a specification doc if you're parsing a language or formal syntaxCommonMark SpecGitHub-Flavored Markdown Specdillonkearns/elm-markdown test results directory from executing spec examplesLook at examples of parser projectsdillonkearns/elm-markdownelm-in-elm parserelm-in-elm conference talkmdgriffith/elm-markup - good reference for parsing, fault-tolerant parsing, and giving nice error messagesTereza's YAML parserTereza's elm conf talk "Demystifying Parsers"Jeroen's elm/parser Ellie"It's not hacking if you have tests."Look at elm/parser docs and resourceselm/parser project's semantics document describes backtrackable behavior in detail

We discuss parsers, how to build them in Elm, and how to try to make your error messages as nice as Elm's.

NOW PLAYING

006: elm/parser

0:00 1:04:49

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Frequently Asked Questions

How long is this episode of Elm Radio?

This episode is 1 hour and 4 minutes long.

When was this Elm Radio episode published?

This episode was published on May 25, 2020.

What is this episode about?

What is a parser?yacc/lexAST (Abstract Syntax Tree) vs. CST (Concrete Syntax Tree)JSON decoding vs. parsingJSON decoding is validating a data structure that has already been parsed. Assumes a valid structure.elm/parserHaskell parsec library -...

Can I download this Elm Radio episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!