Safe Haskell | Safe-Inferred |
---|
Abstract syntax tree for Boogie 2
- newtype Program = Program [Decl]
- data Type
- nullaryType :: Id -> Type
- noType :: Type
- data UnOp
- data BinOp
- data QOp
- type Expression = Pos BareExpression
- data BareExpression
- = FF
- | TT
- | Numeral Integer
- | Var Id
- | Application Id [Expression]
- | MapSelection Expression [Expression]
- | MapUpdate Expression [Expression] Expression
- | Old Expression
- | IfExpr Expression Expression Expression
- | Coercion Expression Type
- | UnaryExpression UnOp Expression
- | BinaryExpression BinOp Expression Expression
- | Quantified QOp [Id] [IdType] Expression
- mapSelectExpr :: Pos BareExpression -> [Expression] -> Pos BareExpression
- data WildcardExpression
- = Wildcard
- | Expr Expression
- type Statement = Pos BareStatement
- data BareStatement
- = Predicate SpecClause
- | Havoc [Id]
- | Assign [(Id, [[Expression]])] [Expression]
- | Call [Id] Id [Expression]
- | CallForall Id [WildcardExpression]
- | If WildcardExpression Block (Maybe Block)
- | While WildcardExpression [SpecClause] Block
- | Break (Maybe Id)
- | Return
- | Goto [Id]
- | Skip
- type LStatement = Pos BareLStatement
- type BareLStatement = ([Id], Statement)
- type Block = [LStatement]
- singletonBlock :: Pos a -> [Pos ([a1], Pos a)]
- type Body = ([[IdTypeWhere]], Block)
- type BasicBlock = (Id, [Statement])
- type BasicBody = ([IdTypeWhere], Map Id [Statement])
- data SpecType
- = Inline
- | Precondition
- | Postcondition
- | LoopInvariant
- | Where
- data SpecClause = SpecClause {}
- data Contract
- = Requires Bool Expression
- | Modifies Bool [Id]
- | Ensures Bool Expression
- type Decl = Pos BareDecl
- data BareDecl
- = TypeDecl [NewType]
- | ConstantDecl Bool [Id] Type ParentInfo Bool
- | FunctionDecl Id [Id] [FArg] FArg (Maybe Expression)
- | AxiomDecl Expression
- | VarDecl [IdTypeWhere]
- | ProcedureDecl Id [Id] [IdTypeWhere] [IdTypeWhere] [Contract] (Maybe Body)
- | ImplementationDecl Id [Id] [IdType] [IdType] [Body]
- type Id = String
- data NewType = NewType {}
- type IdType = (Id, Type)
- data IdTypeWhere = IdTypeWhere {}
- noWhere :: IdTypeWhere -> (Id, Type)
- type FArg = (Maybe Id, Type)
- dummyFArg :: [Char]
- type ParentEdge = (Bool, Id)
- type ParentInfo = Maybe [ParentEdge]
Documentation
Program: a list of top-level declarations
nullaryType :: Id -> TypeSource
nullaryType
id
: type denoted by id
without arguments
Binary operators
type Expression = Pos BareExpressionSource
Expression with a source position attached
data BareExpression Source
Expression
FF | false |
TT | true |
Numeral Integer |
|
Var Id |
|
Application Id [Expression] |
|
MapSelection Expression [Expression] |
|
MapUpdate Expression [Expression] Expression |
|
Old Expression | |
IfExpr Expression Expression Expression |
|
Coercion Expression Type | |
UnaryExpression UnOp Expression | |
BinaryExpression BinOp Expression Expression | |
Quantified QOp [Id] [IdType] Expression |
|
mapSelectExpr :: Pos BareExpression -> [Expression] -> Pos BareExpressionSource
mapSelectExpr
m args
: map selection expression with position of m
attached
type Statement = Pos BareStatementSource
Statement with a source position attached
data BareStatement Source
Statement
Predicate SpecClause | Predicate statement (assume or assert) |
Havoc [Id] |
|
Assign [(Id, [[Expression]])] [Expression] |
|
Call [Id] Id [Expression] |
|
CallForall Id [WildcardExpression] |
|
If WildcardExpression Block (Maybe Block) |
|
While WildcardExpression [SpecClause] Block |
|
Break (Maybe Id) |
|
Return | |
Goto [Id] |
|
Skip | only used at the end of a block |
type LStatement = Pos BareLStatementSource
Statement labeled by multiple labels with a source position attached
type BareLStatement = ([Id], Statement)Source
Statement labeled by multiple labels
type Block = [LStatement]Source
Statement block
singletonBlock :: Pos a -> [Pos ([a1], Pos a)]Source
Block consisting of a single non-labeled statement
type Body = ([[IdTypeWhere]], Block)Source
Procedure body: consists of local variable declarations and a statement block
type BasicBlock = (Id, [Statement])Source
Basic block is a list of statements labeled by a single label; the list contains no jump, if or while statements, except for the last statement, which can be a goto or return
type BasicBody = ([IdTypeWhere], Map Id [Statement])Source
Procedure body transformed to basic blocks: consists of local variable declarations and a set of basic blocks (represented as a map from their labels to statement lists)
Types of specification clauses
Procedure contract clause
Top-level declaration
TypeDecl [NewType] | |
ConstantDecl Bool [Id] Type ParentInfo Bool |
|
FunctionDecl Id [Id] [FArg] FArg (Maybe Expression) |
|
AxiomDecl Expression | |
VarDecl [IdTypeWhere] | |
ProcedureDecl Id [Id] [IdTypeWhere] [IdTypeWhere] [Contract] (Maybe Body) |
|
ImplementationDecl Id [Id] [IdType] [IdType] [Body] |
|
Definition of a type
noWhere :: IdTypeWhere -> (Id, Type)Source
Strip the where clause
Argument name used for unnamed function arguments (does not matter, because it is never referred to from function's body)
type ParentEdge = (Bool, Id)Source
Parent edge of a constant declaration (uniqueness, parent name)
type ParentInfo = Maybe [ParentEdge]Source
Parent information in a constant declaration (Nothing means no information, while empty list means no parents)