| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This modul supplies simple and mixfix identifiers. A simple identifier is a lexical token given by a string and a start position.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Synopsis | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| positions from Common.Lib.Parsec.Pos starting at (1,1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Pos = SourcePos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nullPos :: Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unknown position (0, 0) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isNullPos :: Pos -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Tokens as Strings with positions that are ignored for Eq and Ord | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data Token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type SIMPLE_ID = Token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| simple ids are just tokens | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkSimpleId :: String -> Token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a Token with nullPos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showTok :: Token -> ShowS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| show the plain string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toPos :: Token -> [Token] -> Token -> [Pos] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shortcut to get positions of surrounding and interspersed tokens | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeholder stuff | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| place :: String | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| the special place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPlace :: Token -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is a place token | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| identifiers with positions (usually ignored) of compound lists | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data Id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| show stuff | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noShow :: Bool -> ShowS -> ShowS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shortcut to suppress output for input condition | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showSepList :: ShowS -> (a -> ShowS) -> [a] -> ShowS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| intersperse seperators | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showIds :: [Id] -> ShowS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shows a compound list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showId :: Id -> ShowS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shows an Id, puts final places behind a compound list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| splitting identifiers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| splitMixToken :: [Token] -> ([Token], [Token]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| splits off the front and final places | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getListBrackets :: Id -> ([Token], [Token], [Id]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return open and closing list bracket and a compound list from a bracket Id (parsed by caslListBrackets) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reconstructing token lists | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expandPos :: (Token -> a) -> (String, String) -> [a] -> [Pos] -> [a] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reconstruct a list with surrounding strings and interspersed commas with proper position information that should be preserved by the input function | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getPlainTokenList :: Id -> [Token] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reconstruct the token list of an Id including square brackets and commas of (nested) compound lists. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getCompoundTokenList :: [Id] -> [Pos] -> [Token] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reconstruct tokens of compound list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conversion from SIMPLE_ID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| simpleIdToId :: SIMPLE_ID -> Id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a SIMPLE_ID as Id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSingle :: [a] -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| efficiently test for a singleton list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSimpleId :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test for a SIMPLE_ID | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fixity stuff | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeCount :: Id -> Int | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| number of place in Id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOrdAppl :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has no (toplevel) place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isMixfix :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has a place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPrefix :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ends with a place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isPostfix :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| starts with a place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isInfix2 :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is a classical infix Id with three tokens, the middle one is a non-place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isInfix :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| starts and ends with a place | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSurround :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has a place but neither starts nor ends with one | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isNonCompound :: Id -> Bool | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| has no compound list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| position stuff | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| posOfId :: Id -> Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| compute a meaningful single position from an Id for diagnostics | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headPos :: [Pos] -> Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| first Pos or nullPos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getMyPos :: PosItem a => a -> Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get a reasonable position | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| posOf :: PosItem a => [a] -> Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get a reasonable position for a list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firstPos :: PosItem a => [a] -> [Pos] -> Pos | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| get a reasonable position for a list with an additional position list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class PosItem a where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Produced by Haddock version 0.6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||