Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- m :: Precedence -> Either AasamError ContextFree
- type Precedence = Set PrecedenceProduction
- data PrecedenceProduction
- type ContextFree = (NonTerminal, Set CfgProduction)
- type CfgProduction = (NonTerminal, CfgString)
- type CfgString = [Either Terminal NonTerminal]
- newtype Terminal = Terminal Text
- newtype NonTerminal = NonTerminal Text
- newtype AasamError = AasamError [Text]
Documentation
m :: Precedence -> Either AasamError ContextFree Source #
Takes a distfix precedence grammar. If there is an error, produces an AasamError
, else produces a corresponding unambiguous context-free grammar.
All possible errors are enumerated in the documentation for Precedence
.
type Precedence = Set PrecedenceProduction Source #
The type of a distfix precedence grammar. The following must be true of any parameter to m
.
- All precedences must be positive integers.
- No initial word may also be a subsequent word of another production.
- No initial sequence of words may also be the whole sequence of another production.
- No precedence of a production of one fixity may also be the precedence of a production of another fixity.
- The set of precedences must be either empty or the set of integers between 1 and greatest precedence, inclusive.
data PrecedenceProduction Source #
The type of a distfix precedence production.
Int parameters are precedences.
NonEmpty Text parameters are lists of terminal symbols expressed as strings. A particular data constructor implies a corresponding interspersal pattern of non-terminals in the terminal list when the production is interpreted. For example,
Infixl 1 (fromList ["?", ":"])
corresponds to the left-associative production, E -> E ? E : E.
Prefix Int (NonEmpty Text) | |
Postfix Int (NonEmpty Text) | |
Infixl Int (NonEmpty Text) | |
Infixr Int (NonEmpty Text) | |
Closed (NonEmpty Text) |
Instances
type ContextFree = (NonTerminal, Set CfgProduction) Source #
The type of a context-free grammar. On the left the starting non-terminal, and on the right is the set of productions in the grammar.
type CfgProduction = (NonTerminal, CfgString) Source #
The type of a context-free production. The left and right items correspond respectively to the left and right hand sides of a production rule.
type CfgString = [Either Terminal NonTerminal] Source #
newtype NonTerminal Source #
NonTerminal Text |
Instances
Show NonTerminal Source # | |
Defined in Grammars showsPrec :: Int -> NonTerminal -> ShowS show :: NonTerminal -> String showList :: [NonTerminal] -> ShowS | |
Eq NonTerminal Source # | |
Defined in Grammars (==) :: NonTerminal -> NonTerminal -> Bool (/=) :: NonTerminal -> NonTerminal -> Bool | |
Ord NonTerminal Source # | |
Defined in Grammars compare :: NonTerminal -> NonTerminal -> Ordering (<) :: NonTerminal -> NonTerminal -> Bool (<=) :: NonTerminal -> NonTerminal -> Bool (>) :: NonTerminal -> NonTerminal -> Bool (>=) :: NonTerminal -> NonTerminal -> Bool max :: NonTerminal -> NonTerminal -> NonTerminal min :: NonTerminal -> NonTerminal -> NonTerminal |
newtype AasamError Source #
The type of errors. Contains a list of strings, each of which describes an error of the input grammar.
AasamError [Text] |
Instances
Show AasamError Source # | |
Defined in Aasam showsPrec :: Int -> AasamError -> ShowS show :: AasamError -> String showList :: [AasamError] -> ShowS | |
Eq AasamError Source # | |
Defined in Aasam (==) :: AasamError -> AasamError -> Bool (/=) :: AasamError -> AasamError -> Bool | |
Ord AasamError Source # | |
Defined in Aasam compare :: AasamError -> AasamError -> Ordering (<) :: AasamError -> AasamError -> Bool (<=) :: AasamError -> AasamError -> Bool (>) :: AasamError -> AasamError -> Bool (>=) :: AasamError -> AasamError -> Bool max :: AasamError -> AasamError -> AasamError min :: AasamError -> AasamError -> AasamError |