Copyright | Christian Maeder and Uni Bremen 2003-2005 |
---|---|
License | GPLv2 or higher, see LICENSE.txt |
Maintainer | Christian.Maeder@dfki.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Generic mixfix analysis, using an Earley parser
The grammer has a single non-terminal for terms (the double underscore). A rule of the grammer carries an identifier, a precedence number, and the actual token list of the identifier to match against the input token list..
The parser can be instantiated for any term type. A function parameter determines how applications from identifiers and arguments are constructed.
- type Rule = (Id, Int, [Token])
- type TokRules = Token -> Set Rule
- data Rules = Rules {}
- emptyRules :: Rules
- partitionRules :: [Rule] -> Rules
- varTok :: Token
- exprTok :: Token
- parenId :: Id
- exprId :: Id
- varId :: Id
- tupleId :: Id
- unitId :: Id
- protect :: Id -> Id
- listRules :: Int -> GlobalAnnos -> [Rule]
- mixRule :: Int -> Id -> Rule
- getTokenPlaceList :: Id -> [Token]
- getPlainPolyTokenList :: Id -> [Token]
- getPolyTokenList :: Id -> [Token]
- data Chart a
- mixDiags :: [Diagnosis] -> Chart a -> Chart a
- solveDiags :: Chart a -> [Diagnosis]
- type ToExpr a = Id -> [a] -> Range -> a
- rules :: Chart a -> Rules
- addRules :: Chart a -> TokRules
- initChart :: TokRules -> Rules -> Chart a
- nextChart :: (a -> a -> a) -> ToExpr a -> GlobalAnnos -> Chart a -> (a, Token) -> Chart a
- getResolved :: (a -> ShowS) -> Range -> ToExpr a -> Chart a -> Result a
Documentation
emptyRules :: Rules
partitionRules :: [Rule] -> Rules
presort rules
special tokens for special ids
listRules :: Int -> GlobalAnnos -> [Rule]
construct the list rules
getTokenPlaceList :: Id -> [Token]
extract tokens with the non-terminal for places
getPlainPolyTokenList :: Id -> [Token]
get the plain token list for prefix applications
getPolyTokenList :: Id -> [Token]
get the token list for a mixfix rule
resolution chart
data Chart a
the whole state for mixfix resolution
solveDiags :: Chart a -> [Diagnosis]
nextChart :: (a -> a -> a) -> ToExpr a -> GlobalAnnos -> Chart a -> (a, Token) -> Chart a
make one scan, complete, and predict step.
The first function adds a type to the result.
The second function filters based on argument and operator info.
If filtering yields Nothing
further filtering by precedence is applied.