flp-0.1.0.0: A layout spec language for memory managers implemented in Rust.

Copyright(c) Alec Theriault 2017-2018
LicenseBSD-style
Maintaineralec.theriault@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Language.Rust.Data.Position

Contents

Description

Everything to do with describing a position or a contiguous region in a file.

Synopsis

Positions in files

data Position Source #

A position in a source file. The row and column information is kept only for its convenience and human-readability. Analogous to the information encoded in a cursor.

Constructors

Position 

Fields

NoPosition 
Instances
Eq Position Source # 
Instance details

Defined in Language.Rust.Data.Position

Data Position Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Position -> c Position #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Position #

toConstr :: Position -> Constr #

dataTypeOf :: Position -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Position) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Position) #

gmapT :: (forall b. Data b => b -> b) -> Position -> Position #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Position -> r #

gmapQ :: (forall d. Data d => d -> u) -> Position -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Position -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Position -> m Position #

Ord Position Source # 
Instance details

Defined in Language.Rust.Data.Position

Show Position Source #

Field names are not shown

Instance details

Defined in Language.Rust.Data.Position

Generic Position Source # 
Instance details

Defined in Language.Rust.Data.Position

Associated Types

type Rep Position :: Type -> Type #

Methods

from :: Position -> Rep Position x #

to :: Rep Position x -> Position #

NFData Position Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

rnf :: Position -> () #

Pretty Position Source # 
Instance details

Defined in Language.Rust.Pretty

type Rep Position Source # 
Instance details

Defined in Language.Rust.Data.Position

type Rep Position = D1 (MetaData "Position" "Language.Rust.Data.Position" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Position" PrefixI True) (S1 (MetaSel (Just "absoluteOffset") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: (S1 (MetaSel (Just "row") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "col") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int))) :+: C1 (MetaCons "NoPosition" PrefixI False) (U1 :: Type -> Type))

maxPos :: Position -> Position -> Position Source #

Maximum of two positions, bias for actual positions.

>>> maxPos (Position 30 5 8) (Position 37 5 15)
Position 37 5 15
>>> maxPos NoPosition (Position 30 5 8)
Position 30 5 8

minPos :: Position -> Position -> Position Source #

Maximum and minimum positions, bias for actual positions.

>>> minPos (Position 30 5 8) (Position 37 5 15)
Position 30 5 8
>>> minPos NoPosition (Position 30 5 8)
Position 30 5 8

initPos :: Position Source #

Starting position in a file.

incPos :: Position -> Int -> Position Source #

Advance column a certain number of times.

retPos :: Position -> Position Source #

Advance to the next line.

incOffset :: Position -> Int -> Position Source #

Advance only the absolute offset, not the row and column information. Only use this if you know what you are doing!

Spans in files

data Span Source #

Spans represent a contiguous region of code, delimited by two Positions. The endpoints are inclusive. Analogous to the information encoded in a selection.

Constructors

Span 

Fields

Instances
Eq Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

(==) :: Span -> Span -> Bool #

(/=) :: Span -> Span -> Bool #

Data Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Span -> c Span #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Span #

toConstr :: Span -> Constr #

dataTypeOf :: Span -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Span) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Span) #

gmapT :: (forall b. Data b => b -> b) -> Span -> Span #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Span -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Span -> r #

gmapQ :: (forall d. Data d => d -> u) -> Span -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Span -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Span -> m Span #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Span -> m Span #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Span -> m Span #

Ord Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

compare :: Span -> Span -> Ordering #

(<) :: Span -> Span -> Bool #

(<=) :: Span -> Span -> Bool #

(>) :: Span -> Span -> Bool #

(>=) :: Span -> Span -> Bool #

max :: Span -> Span -> Span #

min :: Span -> Span -> Span #

Show Span Source #

Field names are not shown

Instance details

Defined in Language.Rust.Data.Position

Methods

showsPrec :: Int -> Span -> ShowS #

show :: Span -> String #

showList :: [Span] -> ShowS #

Generic Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Associated Types

type Rep Span :: Type -> Type #

Methods

from :: Span -> Rep Span x #

to :: Rep Span x -> Span #

Semigroup Span Source #

smallest covering Span

Instance details

Defined in Language.Rust.Data.Position

Methods

(<>) :: Span -> Span -> Span #

sconcat :: NonEmpty Span -> Span #

stimes :: Integral b => b -> Span -> Span #

Monoid Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

mempty :: Span #

mappend :: Span -> Span -> Span #

mconcat :: [Span] -> Span #

NFData Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

rnf :: Span -> () #

Located Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: Span -> Span Source #

Pretty Span Source # 
Instance details

Defined in Language.Rust.Pretty

Parse (WhereClause Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (TyParam Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (TyParam Span) Source #

Parse (Ty Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Ty Span) Source #

Parse (TraitItem Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (Stmt Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Stmt Span) Source #

Parse (Pat Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Pat Span) Source #

Parse (Lit Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Lit Span) Source #

Parse (SourceFile Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (LifetimeDef Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (Item Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Item Span) Source #

Parse (ImplItem Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (Generics Span) Source # 
Instance details

Defined in Language.Rust.Parser

Parse (Expr Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Expr Span) Source #

Parse (Block Span) Source # 
Instance details

Defined in Language.Rust.Parser

Methods

parser :: P (Block Span) Source #

Parse (Attribute Span) Source # 
Instance details

Defined in Language.Rust.Parser

type Rep Span Source # 
Instance details

Defined in Language.Rust.Data.Position

type Rep Span = D1 (MetaData "Span" "Language.Rust.Data.Position" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Span" PrefixI True) (S1 (MetaSel (Just "lo") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Position) :*: S1 (MetaSel (Just "hi") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Position)))

unspan :: Spanned a -> a Source #

Extract the wrapped value from Spanned

prettySpan :: Span -> String Source #

Pretty print a Span

subsetOf :: Span -> Span -> Bool Source #

Check if a span is a subset of another span

(#) :: (Located a, Located b) => a -> b -> Span Source #

Convenience function lifting <> to work on all Located things

data Spanned a Source #

A "tagging" of something with a Span that describes its extent.

Constructors

Spanned a !Span 
Instances
Monad Spanned Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

(>>=) :: Spanned a -> (a -> Spanned b) -> Spanned b #

(>>) :: Spanned a -> Spanned b -> Spanned b #

return :: a -> Spanned a #

fail :: String -> Spanned a #

Functor Spanned Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

fmap :: (a -> b) -> Spanned a -> Spanned b #

(<$) :: a -> Spanned b -> Spanned a #

Applicative Spanned Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

pure :: a -> Spanned a #

(<*>) :: Spanned (a -> b) -> Spanned a -> Spanned b #

liftA2 :: (a -> b -> c) -> Spanned a -> Spanned b -> Spanned c #

(*>) :: Spanned a -> Spanned b -> Spanned b #

(<*) :: Spanned a -> Spanned b -> Spanned a #

Eq a => Eq (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

(==) :: Spanned a -> Spanned a -> Bool #

(/=) :: Spanned a -> Spanned a -> Bool #

Data a => Data (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Spanned a -> c (Spanned a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Spanned a) #

toConstr :: Spanned a -> Constr #

dataTypeOf :: Spanned a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Spanned a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Spanned a)) #

gmapT :: (forall b. Data b => b -> b) -> Spanned a -> Spanned a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Spanned a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Spanned a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Spanned a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Spanned a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Spanned a -> m (Spanned a) #

Ord a => Ord (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

compare :: Spanned a -> Spanned a -> Ordering #

(<) :: Spanned a -> Spanned a -> Bool #

(<=) :: Spanned a -> Spanned a -> Bool #

(>) :: Spanned a -> Spanned a -> Bool #

(>=) :: Spanned a -> Spanned a -> Bool #

max :: Spanned a -> Spanned a -> Spanned a #

min :: Spanned a -> Spanned a -> Spanned a #

Show a => Show (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

showsPrec :: Int -> Spanned a -> ShowS #

show :: Spanned a -> String #

showList :: [Spanned a] -> ShowS #

Generic (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Associated Types

type Rep (Spanned a) :: Type -> Type #

Methods

from :: Spanned a -> Rep (Spanned a) x #

to :: Rep (Spanned a) x -> Spanned a #

NFData a => NFData (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

rnf :: Spanned a -> () #

Located (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: Spanned a -> Span Source #

type Rep (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

type Rep (Spanned a) = D1 (MetaData "Spanned" "Language.Rust.Data.Position" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Spanned" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) SourceUnpack SourceStrict DecidedStrict) (Rec0 Span)))

class Located a where Source #

Describes nodes that can be located - their span can be extracted from them. In general, we expect that for a value constructed as Con x y z where Con is an arbitrary constructor

(spanOf x <> spanOf y <> spanOf z) `subsetOf` spanOf (Con x y z) == True

Methods

spanOf :: a -> Span Source #

Instances
Located Span Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: Span -> Span Source #

Located TokenTree Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Located TokenStream Source #

Span is not stored on TokenStream - it is computed

Instance details

Defined in Language.Rust.Syntax.AST

Located a => Located [a] Source #

O(n) time complexity

Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: [a] -> Span Source #

Located a => Located (Maybe a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: Maybe a -> Span Source #

Located a => Located (NonEmpty a) Source #

O(n) time complexity

Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: NonEmpty a -> Span Source #

Located (Spanned a) Source # 
Instance details

Defined in Language.Rust.Data.Position

Methods

spanOf :: Spanned a -> Span Source #

Located a => Located (WherePredicate a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Located a => Located (WhereClause a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: WhereClause a -> Span Source #

Located a => Located (UseTree a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: UseTree a -> Span Source #

Located a => Located (VariantData a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: VariantData a -> Span Source #

Located a => Located (Variant a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Variant a -> Span Source #

Located a => Located (TyParamBound a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Located a => Located (TyParam a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: TyParam a -> Span Source #

Located a => Located (Ty a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Ty a -> Span Source #

Located a => Located (TraitRef a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: TraitRef a -> Span Source #

Located a => Located (TraitItem a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: TraitItem a -> Span Source #

Located a => Located (StructField a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: StructField a -> Span Source #

Located a => Located (Stmt a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Stmt a -> Span Source #

Located a => Located (PolyTraitRef a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Located a => Located (PathSegment a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: PathSegment a -> Span Source #

Located a => Located (PathParameters a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Located a => Located (Path a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Path a -> Span Source #

Located a => Located (Pat a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Pat a -> Span Source #

Located a => Located (Mac a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Mac a -> Span Source #

Located a => Located (Lit a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Lit a -> Span Source #

Located a => Located (LifetimeDef a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: LifetimeDef a -> Span Source #

Located a => Located (Lifetime a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Lifetime a -> Span Source #

Located a => Located (Label a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Label a -> Span Source #

Located a => Located (Item a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Item a -> Span Source #

Located a => Located (ImplItem a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: ImplItem a -> Span Source #

Located a => Located (Generics a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Generics a -> Span Source #

Located a => Located (ForeignItem a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: ForeignItem a -> Span Source #

Located a => Located (FnDecl a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: FnDecl a -> Span Source #

Located a => Located (FieldPat a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: FieldPat a -> Span Source #

Located a => Located (Field a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Field a -> Span Source #

Located a => Located (Expr a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Expr a -> Span Source #

Located a => Located (Block a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Block a -> Span Source #

Located a => Located (Attribute a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Attribute a -> Span Source #

Located a => Located (Arm a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Arm a -> Span Source #

Located a => Located (Arg a) Source # 
Instance details

Defined in Language.Rust.Syntax.AST

Methods

spanOf :: Arg a -> Span Source #

Located (f a) => Located (Reversed f a) Source # 
Instance details

Defined in Language.Rust.Parser.Reversed

Methods

spanOf :: Reversed f a -> Span Source #