flatparse-0.1.0.1: High-performance parsing from strict bytestrings

FlatParse.Examples.BasicLambda.Parser

Description

This module contains a simple lambda calculus parser. This parser is not optimized for maximum performance; instead it's written in a style which emulates the look and feel of conventional monadic parsers. An optimized implementation would use low-level switch expressions more often.

Synopsis

Documentation

data Tm Source #

A term in the language. The precedences of different constructs are the following, in decreasing order of strength:

• Identifiers, literals and parenthesized expressions
• Function application (left assoc)
• Multiplication (left assoc)
• Equality, less-than (non-assoc)
• lam, let, if (right assoc)

Constructors

 Var Name x App Tm Tm t u Lam Name Tm lam x. t Let Name Tm Tm let x = t in u BoolLit Bool true or false. IntLit Int A positive Int literal. If Tm Tm Tm if t then u else v Add Tm Tm t + u Mul Tm Tm t * u Eq Tm Tm t == u Lt Tm Tm t < u

Instances

Instances details
 Source # Instance detailsDefined in FlatParse.Examples.BasicLambda.Parser MethodsshowsPrec :: Int -> Tm -> ShowS #show :: Tm -> String #showList :: [Tm] -> ShowS #

Parse an identifier. This parser uses isKeyword to check that an identifier is not a keyword.

Parse an identifier, throw a precise error on failure.

Parse a literal, identifier or parenthsized expression.

Parse an App-level expression.

Parse a Mul-level expression.

Parse an Add-level expression.

Parse an Eq or Lt-level expression.

Parse a Let.

Parse a Lam.

Parse an If.

Parse any Tm.

Parse a complete source file.