happy-arbitrary
Safe HaskellNone
LanguageHaskell2010

Language.Happy.Sized

Description

Trees of a given size in tokens. Every symbol knows the fewest and the most tokens it can make. A node picks one of the productions that can make its budget, and shares the budget among its children so that each of them can make its share. Both favour symbols that reach more of the grammar.

Synopsis

Documentation

data Range Source #

The fewest and the most tokens a symbol makes. Nothing as the most means there's no limit.

Constructors

Range Int (Maybe Int) 

Instances

Instances details
Show Range Source # 
Instance details

Defined in Language.Happy.Sized

Methods

showsPrec :: Int -> Range -> ShowS #

show :: Range -> String #

showList :: [Range] -> ShowS #

Eq Range Source # 
Instance details

Defined in Language.Happy.Sized

Methods

(==) :: Range -> Range -> Bool #

(/=) :: Range -> Range -> Bool #

genSized :: Rules -> Map Text token -> Sym -> Int -> Gen (GenTree token) Source #

Draws a tree of the start symbol with n tokens, or as close to it as the grammar allows.

ranges :: Rules -> Set Text -> Map Sym Range Source #

Returns the size range of every nonterminal that makes a finite tree.