Hets - the Heterogeneous Tool Set

CopyrightChristian Maeder and Uni Bremen 2003-2005
LicenseGPLv2 or higher, see LICENSE.txt
MaintainerChristian.Maeder@dfki.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone

Common.Earley

Contents

Description

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.

Synopsis

Documentation

type Rule = (Id, Int, [Token]) Source #

type TokRules = Token -> Set Rule Source #

data Rules Source #

postfix and prefix rules

Constructors

Rules 

Fields

partitionRules :: [Rule] -> Rules Source #

presort rules

special tokens for special ids

varTok :: Token Source #

token for a fixed (or recursively resolved) argument expression

exprTok :: Token Source #

token for a fixed (or recursively resolved) operator expression

parenId :: Id Source #

parenthesis around one place

tupleId :: Id Source #

id for tuples with at least two arguments

unitId :: Id Source #

id for the emtpy tuple

protect :: Id -> Id Source #

interpret placeholders as literal places

listRules :: Int -> GlobalAnnos -> [Rule] Source #

construct the list rules

mixRule :: Int -> Id -> Rule Source #

construct a rule for a mixfix

getTokenPlaceList :: Id -> [Token] Source #

extract tokens with the non-terminal for places

getPlainPolyTokenList :: Id -> [Token] Source #

get the plain token list for prefix applications

getPolyTokenList :: Id -> [Token] Source #

get the token list for a mixfix rule

resolution chart

data Chart a Source #

the whole state for mixfix resolution

mixDiags :: [Diagnosis] -> Chart a -> Chart a Source #

add intermediate diagnostic messages

type ToExpr a = Id -> [a] -> Range -> a Source #

shortcut for a function that constructs an expression

initChart :: TokRules -> Rules -> Chart a Source #

create the initial chart

nextChart :: (a -> a -> a) -> ToExpr a -> GlobalAnnos -> Chart a -> (a, Token) -> Chart a Source #

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.

getResolved :: (a -> ShowS) -> Range -> ToExpr a -> Chart a -> Result a Source #

extract resolved result