HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerere-0.2.0.2Haskell2010

RERE.CFG

Context free grammars, where each production is a regular-expression.

  • 2 types
  • 1 value
  • Packagerere-0.2.0.2
  • Exports3
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceCFG.hs

Context-free grammars

2 declarations
typetype CFG (n :: Nat) a = Vec n (CFGBase n a)
#

Context-free grammar represented as n equations of RE (CFGBase) with n variables.

Conversion to recursive regular expressions

1 declaration
valuecfgToRE :: (SNatI n, Ord a) => Vec ('S n) Name -> CFG ('S n) a -> RE a
#

Convert CFG (with names for productions) into RE. Note: the start symbol have to be last equation.

Example3 expressions
let a = Eps \/ ch_ 'a' <> Var (Left FZ)let b = Eps \/ ch_ 'b' <> Var (Left (FS FZ))let cfg = b ::: a ::: VNil

[ begin{aligned} {mathit{b}} &= {varepsilon}cupmathtt{b}{mathit{a}} -- {mathit{a}} &= {varepsilon}cupmathtt{a}{mathit{b}} -- end{aligned}