Copyright | (c) Klaus Luettich and Christian Maeder and Uni Bremen 2002-2003 |
---|---|
License | GPLv2 or higher, see LICENSE.txt |
Maintainer | Christian.Maeder@dfki.de |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
This module supplies positions, simple and mixfix identifiers. A simple identifier is a lexical token given by a string and a start position.
- A
place
is a special token within mixfix identifiers. - A mixfix identifier may have a compound list. This compound list follows the last non-place token!
- Identifiers fixed for all logics
Synopsis
- data Pos = SourcePos {
- sourceName :: String
- sourceLine :: !Int
- sourceColumn :: !Int
- newtype Range = Range {
- rangeToList :: [Pos]
- nullRange :: Range
- isNullRange :: Range -> Bool
- appRange :: Range -> Range -> Range
- concatMapRange :: (a -> Range) -> [a] -> Range
- newPos :: String -> Int -> Int -> Pos
- incSourceColumn :: Pos -> Int -> Pos
- showPos :: Pos -> ShowS
- data Token = Token {}
- type SIMPLE_ID = Token
- mkSimpleId :: String -> Token
- addStringToTok :: Token -> String -> Token
- nullTok :: Token
- mkNumStr :: String -> Int -> String
- mkNumVar :: String -> Int -> Token
- isSimpleToken :: Token -> Bool
- catPosAux :: [Token] -> [Pos]
- catRange :: [Token] -> Range
- toRange :: Token -> [Token] -> Token -> Range
- place :: String
- isPlace :: Token -> Bool
- placeTok :: Token
- equalS :: String
- exEqual :: String
- typeTok :: Token
- data Id = Id {}
- isNullId :: Id -> Bool
- mkId :: [Token] -> Id
- mkInfix :: String -> Id
- genNamePrefix :: String
- genToken :: String -> Token
- genNumVar :: String -> Int -> Token
- genName :: String -> Id
- mkGenName :: Id -> Id
- isGeneratedToken :: Token -> Bool
- appendString :: Id -> String -> Id
- prependString :: String -> Id -> Id
- appendId :: Id -> Id -> Id
- injToken :: Token
- injName :: Id
- mkUniqueName :: Token -> [Id] -> Id
- projToken :: Token
- projName :: Id
- mkUniqueProjName :: Id -> Id -> Id
- mkUniqueInjName :: Id -> Id -> Id
- isInjName :: Id -> Bool
- typeId :: Id
- applId :: Id
- eqId :: Id
- exEq :: Id
- noShow :: Bool -> ShowS -> ShowS
- showSepList :: ShowS -> (a -> ShowS) -> [a] -> ShowS
- showIds :: [Id] -> ShowS
- showId :: Id -> ShowS
- splitMixToken :: [Token] -> ([Token], [Token])
- getListBrackets :: Id -> ([Token], [Token], [Id])
- expandPos :: (Token -> a) -> (String, String) -> [a] -> Range -> [a]
- getPlainTokenList :: Id -> [Token]
- getTokenList :: String -> Id -> [Token]
- simpleIdToId :: SIMPLE_ID -> Id
- stringToId :: String -> Id
- isSingle :: [a] -> Bool
- isSimpleId :: Id -> Bool
- idToSimpleId :: Id -> Token
- placeCount :: Id -> Int
- isMixfix :: Id -> Bool
- begPlace :: Id -> Bool
- endPlace :: Id -> Bool
- isPostfix :: Id -> Bool
- isInfix :: Id -> Bool
- posOfId :: Id -> Range
- tokenRange :: Token -> [Pos]
- mkTokPos :: String -> Pos -> [Pos]
- outerRange :: Range -> [Pos]
- sortRange :: [Pos] -> [Pos] -> [Pos]
- joinRanges :: [[Pos]] -> [Pos]
- idRange :: Id -> [Pos]
- addComponents :: Id -> ([Id], Range) -> Id
- class GetRange a where
- getPosList :: GetRange a => a -> [Pos]
- getRangeSpan :: GetRange a => a -> Range
Documentation
SourcePos | |
|
Instances
Eq Pos Source # | |
Data Pos Source # | |
Defined in Common.Id gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pos -> c Pos gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Pos dataTypeOf :: Pos -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Pos) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pos) gmapT :: (forall b. Data b => b -> b) -> Pos -> Pos gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pos -> r gmapQ :: (forall d. Data d => d -> u) -> Pos -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Pos -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pos -> m Pos gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pos -> m Pos | |
Ord Pos Source # | |
Show Pos Source # | |
Generic Pos | |
FromJSON Pos | |
Defined in ATC.Id parseJSON :: Value -> Parser Pos parseJSONList :: Value -> Parser [Pos] | |
ToJSON Pos | |
Defined in ATC.Id | |
ShATermConvertible Pos | |
Defined in ATC.Id toShATermAux :: ATermTable -> Pos -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [Pos] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, Pos) fromShATermList' :: Int -> ATermTable -> (ATermTable, [Pos]) | |
type Rep Pos | |
Defined in ATC.Id type Rep Pos = D1 ('MetaData "Pos" "Common.Id" "main" 'False) (C1 ('MetaCons "SourcePos" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "sourceLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "sourceColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)))) |
position lists with trivial equality
Range | |
|
Instances
Eq Range Source # | |
Data Range Source # | |
Defined in Common.Id gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Range -> c Range gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Range dataTypeOf :: Range -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Range) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Range) gmapT :: (forall b. Data b => b -> b) -> Range -> Range gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r gmapQ :: (forall d. Data d => d -> u) -> Range -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Range -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Range -> m Range gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Range -> m Range gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Range -> m Range | |
Ord Range Source # | |
Show Range Source # | |
Generic Range | |
GetRange Range Source # | |
FromJSON Range | |
Defined in ATC.Id parseJSON :: Value -> Parser Range parseJSONList :: Value -> Parser [Range] | |
ToJSON Range | |
Defined in ATC.Id | |
ShATermConvertible Range | |
Defined in ATC.Id toShATermAux :: ATermTable -> Range -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [Range] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, Range) fromShATermList' :: Int -> ATermTable -> (ATermTable, [Range]) | |
Pretty Range Source # | |
type Rep Range | |
isNullRange :: Range -> Bool Source #
concatMapRange :: (a -> Range) -> [a] -> Range Source #
incSourceColumn :: Pos -> Int -> Pos Source #
increment the column counter
Tokens as String
s with positions that are ignored for Eq
and Ord
tokens as supplied by the scanner
Instances
Eq Token Source # | |
Data Token Source # | |
Defined in Common.Id gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Token -> c Token gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Token dataTypeOf :: Token -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Token) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Token) gmapT :: (forall b. Data b => b -> b) -> Token -> Token gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Token -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Token -> r gmapQ :: (forall d. Data d => d -> u) -> Token -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Token -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Token -> m Token gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Token -> m Token gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Token -> m Token | |
Ord Token Source # | |
Read Token Source # | |
Show Token Source # | |
Generic Token | |
GetRange Token Source # | |
FromJSON Token | |
Defined in ATC.Id parseJSON :: Value -> Parser Token parseJSONList :: Value -> Parser [Token] | |
ToJSON Token | |
Defined in ATC.Id | |
ShATermConvertible Token | |
Defined in ATC.Id toShATermAux :: ATermTable -> Token -> IO (ATermTable, Int) toShATermList' :: ATermTable -> [Token] -> IO (ATermTable, Int) fromShATermAux :: Int -> ATermTable -> (ATermTable, Token) fromShATermList' :: Int -> ATermTable -> (ATermTable, [Token]) | |
SymbolName Token Source # | |
Pretty Token Source # | |
ListCheck Token Source # | |
Defined in CASL.ToDoc | |
HasName Qid Source # | |
ATermConvertibleSML Token Source # | |
Defined in ATC.Sml_cats from_sml_ShATerm :: ATermTable -> Token from_sml_ShATermList :: ATermTable -> [Token] | |
ProjectSublogicM CommonLogicSL NAME Source # | |
Defined in CommonLogic.Logic_CommonLogic projectSublogicM :: CommonLogicSL -> NAME -> Maybe NAME Source # | |
MinSublogic CommonLogicSL NAME Source # | |
Defined in CommonLogic.Logic_CommonLogic minSublogic :: NAME -> CommonLogicSL Source # | |
type Rep Token | |
Defined in ATC.Id type Rep Token = D1 ('MetaData "Token" "Common.Id" "main" 'False) (C1 ('MetaCons "Token" 'PrefixI 'True) (S1 ('MetaSel ('Just "tokStr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "tokPos") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Range))) |
mkSimpleId :: String -> Token Source #
construct a token without position from a string
addStringToTok :: Token -> String -> Token Source #
add a string to a token
isSimpleToken :: Token -> Bool Source #
test if the first character indicates a legal simple CASL identifier
toRange :: Token -> [Token] -> Token -> Range Source #
shortcut to get positions of surrounding and interspersed tokens
placeholder stuff
equality symbols
mixfix identifiers with compound lists and its range
mixfix and compound identifiers
Instances
genNamePrefix :: String Source #
a prefix for generated names
isGeneratedToken :: Token -> Bool Source #
tests whether a Token is already a generated one
appendString :: Id -> String -> Id Source #
append a number to the first token of a (possible compound) Id, or generate a new identifier for invisible ones
prependString :: String -> Id -> Id Source #
prepend a string to the first token of an Id
show stuff
showSepList :: ShowS -> (a -> ShowS) -> [a] -> ShowS Source #
intersperse seperators
splitting identifiers
getListBrackets :: Id -> ([Token], [Token], [Id]) Source #
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] -> Range -> [a] Source #
reconstruct a list with surrounding strings and interspersed commas with proper position information that should be preserved by the input function
getPlainTokenList :: Id -> [Token] Source #
reconstruct the token list of an Id
including square brackets and commas of (nested) compound lists.
getTokenList :: String -> Id -> [Token] Source #
reconstruct the token list of an Id
.
Replace top-level places with the input String
conversion from SIMPLE_ID
stringToId :: String -> Id Source #
a string as Id
isSimpleId :: Id -> Bool Source #
test for a SIMPLE_ID
idToSimpleId :: Id -> Token Source #
fixity stuff
position stuff
tokenRange :: Token -> [Pos] Source #
compute start and end position of a Token (or leave it empty)
outerRange :: Range -> [Pos] Source #
joinRanges :: [[Pos]] -> [Pos] Source #
idRange :: Id -> [Pos] Source #
compute start and end position of a declared Id (or leave it empty). Do not use for applied identifiers where place holders are replaced.
class GetRange a where Source #
This class is derivable with DrIFT.
Its main purpose is to have a function that operates on
constructors with a Range
field. During parsing, mixfix
analysis and ATermConversion this function might be very useful.
Nothing
Instances
getPosList :: GetRange a => a -> [Pos] Source #
getRangeSpan :: GetRange a => a -> Range Source #