Skip to content
Snippets Groups Projects
Commit 4718c650 authored by Julien Signoles's avatar Julien Signoles
Browse files

moving E-ACSL reference manual from trunk to plugins/e-acsl

parent f874a3ed
No related branches found
No related tags found
No related merge requests found
Showing
with 1658 additions and 0 deletions
\begin{syntax}
ghost-type-specifier ::= C-type-specifier ;
| { logic-type-name } \
declaration ::= C-declaration ;
| { "/*@" "ghost" } ;
{ ghost-declaration "*/" } \
direct-declarator ::= C-direct-declarator ;
| direct-declarator ;
"(" parameter-type-list? ")";
{"/*@" "ghost"};
{"("parameter-list")"};
{"*/"}; ghost args
\
postfix-expression ::= C-postfix-expression ;
| postfix-expression ;
"(" argument-expression-list? ")";
{"/*@" "ghost"} ;
{ "(" argument-expression-list ")"};
{ "*/"} ; call with ghosts
\
statement ::= C-statement ;
| { statements-ghost } \
{ statements-ghost } ::= { "/*@" "ghost" };
{ ghost-statement+ "*/" } \
ghost-selection-statement ::= C-selection-statement ;
| "if" "(" expression ")";
statement;
{"/*@" "ghost" "else"};
{ C-statement+ };
{ "*/"} \
struct-declaration ::= C-struct-declaration ;
| {"/*@" "ghost" };
{C-struct-declaration "*/"} ; ghost field
\end{syntax}
%; whizzy-master "main.tex"
\chapter{Introduction}
This document is a reference manual for
\ifthenelse{\boolean{PrintImplementationRq}}%
{the \eacsl implementation provided by the \eacsl plug-in~\cite{eacsl-plugin}
(version\eacslversion) of the \framac framework~\cite{framac}.}%
{E-ACSL.}
\eacsl is an acronym for ``Executable ANSI/ISO C
Specification Language''. It is an ``executable'' subset of
\emph{stable} \acsl~\cite{acsl} implemented~\cite{acslimplem} in the \framac
platform~\cite{framac}. ``Stable'' means that no experimental \acsl feature is
supported by \eacsl. Contrary to \acsl, each \eacsl specification is
executable: it may be evaluated at runtime.
In this document, we assume that the reader has a good knowledge of both
ACSL~\cite{acsl} and the ANSI C programming language~\cite{standardc99,KR88}.
\section{Organization of this document}
This document is organized in the very same way that the reference manual of
\acsl~\cite{acsl}.
Instead of being a fully new reference manual, this document points out the
differences between \eacsl and \acsl. Each \eacsl construct which is not pointed
out must be considered to have the very same semantics than its \acsl
counterpart. For clarity, each relevant grammar rules are given in BNF form
in separate figures like the \acsl reference manual does. In these rules,
constructs with semantic changes are displayed in \markdiff{blue}.
\ifthenelse{\boolean{PrintImplementationRq}}{%
Not all of the features mentioned in this document are currently
implemented in the \framac's \eacsl plug-in. Those who aren't yet are signaled
as in the following line:
\begin{quote}
\notimplemented[Additional remarks on the feature may appear as footnote.]%
{This feature is not currently supported by \framac's \eacsl plug-in.}
\end{quote}
As a summary, Figure~\ref{fig:notyet} synthetizes main features that are not
currently implemented into the \framac's \eacsl plug-in.
\begin{figure}[htbp]\label{fig:notyet}
\begin{center}
\begin{tabular}{|l|l|}
\hline
typing
& mathematical reals \\
\hline
terms
& \lstinline|\\true| and \lstinline|\\false| \\
& bitwise operators \\
& let binding \\
& typeof \\
& t-sets \\
& \lstinline|base\_addr|, \lstinline|offset| and
\lstinline|block\_length|
\\
\hline
predicates
& exclusive or operator \\ % \lstinline|^^|
& let bindings \\
& quantifications over non-integer types \\
& \lstinline|valid| and \lstinline|valid\_range| \\
& \lstinline|initialized| and \lstinline|specified|
\\
\hline
annotations
& behavior-specific annotations \\
& loop annotations \\
& global annotations
\\
\hline
behavior clauses
& assigns \\
& decreases \\
& abrupt termination \\
& complete and disjoint behaviors
\\
\hline
\end{tabular}
\end{center}
\caption{Summary of not-yet-implemented features.}
\end{figure}
}%
{}
\section{Generalities about Annotations}\label{sec:gener-about-annot}
\nodiff
\section{Notations for grammars}
\nodiff
\begin{syntax}
declaration ::= [ { "//@" "iterator" id "("wildcard-param","
wildcard-param")" ":" } ] ;
[ { "nexts" terms ";" "guards" predicates ";" } ]
\
[ { wildcard-param } ] ::= { parameter } ;
| [ { "_" } ]
\
[ { terms } ] ::= [ { term (, term)* } ]
\
[ { predicates } ] ::= [ { predicate (, predicate)* } ]
\end{syntax}
\chapter{Libraries}
\label{chap:lib}
\emph{Disclaimer:} this chapter is yet empty. It is left here to give an idea of
what the final document will look and to be consistent with the \acsl reference
manual~\cite{acsl}.
struct btree {
int val;
struct btree *left, *right;
};
/*@ iterator access(_, struct btree *t):
@ nexts t->left, t->right;
@ guards \valid(t->left), \valid(t->right); */
/*@ predicate is_even(struct btree *t) =
@ \forall struct btree *tt; access(tt, t) ==> tt->val % 2 == 0; */
\begin{syntax}
tset ::= { "\empty" } ; empty set
| tset "->" id ;
| tset "." id ;
| "*" tset ;
| "&" tset ;
| tset "[" tset "]" ;
| [ { term ".." term } ] ; range
| { "\union" "(" tset ("," tset)* ")" } ; union of locations
| { "\inter" "(" tset ("," tset)* ")" }; intersection
| tset "+" tset ;
| "(" tset ")" ;
| [ { "{" tset "|" binder ";" guards ("&&" pred)? "}" } ]; set comprehension
| { "{" term "}" } ; explicit singleton
| term ; implicit singleton
\
pred ::= { "\subset" "(" tset "," tset ")" } ; set inclusion
\end{syntax}
\begin{syntax}
C-global-decl ::= { "/*@" logic-def+ "*/" }
\
[ { logic-def } ] ::= { logic-const-def } ;
| { logic-function-def } ;
| { predicate-def } ;
\
[ { type-expr } ] ::= { id };
\
[ { logic-const-def } ] ::= { "logic" type-expr id "=" term ";" }
\
[ { logic-function-def } ] ::= { "logic" type-expr id parameters "=" term ";" }
\
[ { predicate-def } ] ::= { "predicate" id parameters? "=" pred ";" }
\
{ parameters } ::= { "(" parameter (, parameter)* ")" }
\
{ parameter } ::= { type-expr id }
\end{syntax}
\begin{syntax}
statement ::= { "/*@" loop-annot "*/" } ;
"while" "(" expr ")" statement ;
| { "/*@" loop-annot "*/" } ;
"for";
"(" expr ";" expr ";" expr ")";
statement ;
| { "/*@" loop-annot "*/" } ;
"do" statement ;
"while" "(" expr ")" ";"
\
{ loop-annot } ::= { loop-clause* } ;
{ loop-behavior* } ;
{ loop-variant? }
\
{ loop-clause } ::= { loop-invariant } ;
| { loop-assigns }
\
[ { loop-invariant } ] ::= [ { "loop" "invariant" pred ";" } ]
\
{ loop-assigns } ::= { "loop" "assigns" locations ";" } ;
\
{ loop-behavior } ::= { "for" id ("," id)* ":" } ;
{ loop-clause* } ; annotation for behavior $id$
\
{ loop-variant } ::= { "loop" "variant" term ";" } ;
| { "loop" "variant" term "for" id ";" } ; variant for relation $id$
\end{syntax}
%%% Environnements dont le corps est suprim, et
%%% commandes dont la dfinition est vide,
%%% lorsque PrintRemarks=false
\usepackage{comment}
\newcommand{\framac}{\textsc{Frama-C}\xspace}
\newcommand{\acsl}{\textsc{ACSL}\xspace}
\newcommand{\eacsl}{\textsc{E-ACSL}\xspace}
\newcommand{\C}{\textsc{C}\xspace}
\newcommand{\jml}{\textsc{JML}\xspace}
\newcommand{\nodiff}{\emph{No difference with \acsl.}}
\newcommand{\except}[1]{\emph{No difference with \acsl, but #1.}}
\newcommand{\limited}[1]{\emph{Limited to #1.}}
\newcommand{\absent}{\emph{No such feature in \eacsl.}}
\newcommand{\absentwhy}[1]{\emph{No such feature in \eacsl: #1.}}
\newcommand{\absentexperimental}{\emph{No such feature in \eacsl, since it is
still experimental in \acsl.}}
\newcommand{\absentexcept}[1]{\emph{No such feature in \eacsl, but #1.}}
\newcommand{\difficultwhy}[2]{\emph{#1 is usually difficult to implement, since
it requires #2. Thus you would not wonder if most tools do not support it
(or support it partially).}}
\newcommand{\difficultswhy}[2]{\emph{#1 are usually difficult to implement,
since they require #2. Thus you would not wonder if most tools do not
support them (or support them partially).}}
\newcommand{\difficult}[1]{\emph{#1 is usually difficult to implement. Thus
you would not wonder if most tools do not support it (or support
it partially).}}
\newcommand{\difficults}[1]{\emph{#1 are usually difficult to implement. Thus
you would not wonder if most tools do not support them (or support
them partially).}}
\newcommand{\changeinsection}[2]{\textbf{Section \ref{sec:#1}:} #2.}
\newcommand{\todo}[1]{{\large \textbf{TODO: #1.}}}
\newcommand{\markdiff}[1]{{\color{blue}{#1}}}
\newenvironment{markdiffenv}[1][]{%
\begin{changebar}%
\markdiff\bgroup%
}%
{\egroup\end{changebar}}
% true = prints remarks for the ACSL working group.
% false = prints no remark for the distributed version of ASCL documents
\newboolean{PrintRemarks}
\setboolean{PrintRemarks}{false}
% true = prints marks signaling the state of the implementation
% false = prints only the ACSL definition, without remarks on implementation.
\newboolean{PrintImplementationRq}
\setboolean{PrintImplementationRq}{true}
% true = remarks about the current state of implementation in Frama-C
% are in color.
% false = they are rendered with an underline
\newboolean{ColorImplementationRq}
\setboolean{ColorImplementationRq}{true}
%% \ifthenelse{\boolean{PrintRemarks}}%
%% {\newenvironment{todo}{%
%% \begin{quote}%
%% \begin{tabular}{||p{0.8\textwidth}}TODO~:\itshape}%
%% {\end{tabular}\end{quote}}}%
%% {\excludecomment{todo}}
\ifthenelse{\boolean{PrintRemarks}}%
{\newenvironment{remark}[1]{%
\begin{quote}\itshape%
\begin{tabular}{||p{0.8\textwidth}}Remarque de {#1}~:}%
{\end{tabular}\end{quote}}}%
{\excludecomment{remark}}
\newcommand{\oldremark}[2]{%
\ifthenelse{\boolean{PrintRemarks}}{%
%\begin{quote}\itshape%
%\begin{tabular}{||p{0.8\textwidth}}Vieille remarque de {#1}~: #2%
%\end{tabular}\end{quote}%
}%
{}}
\newcommand{\highlightnotreviewed}{%
\color{blue}%
}%
\newcommand{\notreviewed}[2][]{%
\ifthenelse{\boolean{PrintRemarks}}{%
\begin{changebar}%
{\highlightnotreviewed #2}%
\ifthenelse{\equal{#1}{}}{}{\footnote{#1}}%
\end{changebar}%
}%
{}}
\ifthenelse{\boolean{PrintRemarks}}{%
\newenvironment{notreviewedenv}[1][]{%
\begin{changebar}%
\highlightnotreviewed%
\ifthenelse{\equal{#1}{}}{}{\def\myrq{#1}}%
\bgroup}%
{\egroup%
\ifthenelse{\isundefined{\myrq}}{}{\footnote{\myrq}}\end{changebar}}}%
{\excludecomment{notreviewedenv}}
%%% Commandes et environnements pour la version relative l'implementation
\newcommand{\highlightnotimplemented}{%
\ifthenelse{\boolean{ColorImplementationRq}}{\color{red}}%
{\ul}%
}%
\newcommand{\notimplemented}[2][]{%
\ifthenelse{\boolean{PrintImplementationRq}}{%
\begin{changebar}%
{\highlightnotimplemented #2}%
\ifthenelse{\equal{#1}{}}{}{\footnote{#1}}%
\end{changebar}%
}%
{#2}}
\newenvironment{notimplementedenv}[1][]{%
\ifthenelse{\boolean{PrintImplementationRq}}{%
\begin{changebar}%
\highlightnotimplemented%
\ifthenelse{\equal{#1}{}}{}{\def\myrq{#1}}%
\bgroup
}{}}%
{\ifthenelse{\boolean{PrintImplementationRq}}{%
\egroup%
\ifthenelse{\isundefined{\myrq}}{}{\footnote{\myrq}}\end{changebar}}{}}
%%% Environnements et commandes non conditionnelles
\newcommand{\experimental}{\textsc{Experimental}}
\newsavebox{\fmbox}
\newenvironment{cadre}
{\begin{lrbox}{\fmbox}\begin{minipage}{0.98\textwidth}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}}
\newcommand{\keyword}[1]{\lstinline|#1|\xspace}
\newcommand{\keywordbs}[1]{\lstinline|\\#1|\xspace}
\newcommand{\integer}{\keyword{integer}}
\newcommand{\real}{\keyword{real}}
\newcommand{\bool}{\keyword{boolean}}
\newcommand{\assert}{\keyword{assert}}
\newcommand{\terminates}{\keyword{terminates}}
\newcommand{\assume}{\keyword{assume}}
\newcommand{\requires}{\keyword{requires}}
\newcommand{\ensures}{\keyword{ensures}}
\newcommand{\exits}{\keyword{exits}}
\newcommand{\returns}{\keyword{returns}}
\newcommand{\breaks}{\keyword{breaks}}
\newcommand{\continues}{\keyword{continues}}
\newcommand{\assumes}{\keyword{assumes}}
\newcommand{\assigns}{\keyword{assigns}}
\newcommand{\reads}{\keyword{reads}}
\newcommand{\decreases}{\keyword{decreases}}
\newcommand{\boundseparated}{\keywordbs{bound\_separated}}
\newcommand{\Exists}{\keywordbs{exists}~}
\newcommand{\Forall}{\keywordbs{forall}~}
\newcommand{\bslambda}{\keywordbs{lambda}~}
\newcommand{\freed}{\keywordbs{freed}}
\newcommand{\fresh}{\keywordbs{fresh}}
\newcommand{\fullseparated}{\keywordbs{full\_separated}}
\newcommand{\distinct}{\keywordbs{distinct}}
\newcommand{\Max}{\keyword{max}}
\newcommand{\nothing}{\keywordbs{nothing}}
\newcommand{\numof}{\keyword{num\_of}}
\newcommand{\offsetmin}{\keywordbs{offset\_min}}
\newcommand{\offsetmax}{\keywordbs{offset\_max}}
\newcommand{\old}{\keywordbs{old}}
\newcommand{\at}{\keywordbs{at}}
\newcommand{\If}{\keyword{if}~}
\newcommand{\Then}{~\keyword{then}~}
\newcommand{\Else}{~\keyword{else}~}
\newcommand{\For}{\keyword{for}~}
\newcommand{\While}{~\keyword{while}~}
\newcommand{\Do}{~\keyword{do}~}
\newcommand{\Let}{\keywordbs{let}~}
\newcommand{\Break}{\keyword{break}}
\newcommand{\Return}{\keyword{return}}
\newcommand{\Continue}{\keyword{continue}}
\newcommand{\exit}{\keyword{exit}}
\newcommand{\main}{\keyword{main}}
\newcommand{\void}{\keyword{void}}
\newcommand{\struct}{\keyword{struct}}
\newcommand{\union}{\keywordbs{union}}
\newcommand{\inter}{\keywordbs{inter}}
\newcommand{\typedef}{\keyword{typedef}}
\newcommand{\result}{\keywordbs{result}}
\newcommand{\separated}{\keywordbs{separated}}
\newcommand{\sizeof}{\keyword{sizeof}}
\newcommand{\strlen}{\keywordbs{strlen}}
\newcommand{\Sum}{\keyword{sum}}
\newcommand{\valid}{\keywordbs{valid}}
\newcommand{\validrange}{\keywordbs{valid\_range}}
\newcommand{\offset}{\keywordbs{offset}}
\newcommand{\blocklength}{\keywordbs{block\_length}}
\newcommand{\baseaddr}{\keywordbs{base\_addr}}
\newcommand{\comparable}{\keywordbs{comparable}}
\newcommand{\N}{\ensuremath{\mathbb{N}}}
\newcommand{\ra}{\ensuremath{\rightarrow}}
\newcommand{\la}{\ensuremath{\leftarrow}}
% BNF grammar
\newcommand{\indextt}[1]{\index{#1@\protect\keyword{#1}}}
\newcommand{\indexttbs}[1]{\index{#1@\protect\keywordbs{#1}}}
\newif\ifspace
\newif\ifnewentry
\newcommand{\addspace}{\ifspace ~ \spacefalse \fi}
\newcommand{\term}[2]{\addspace\hbox{\lstinline|#1|%
\ifthenelse{\equal{#2}{}}{}{\indexttbase{#2}{#1}}}\spacetrue}
\newcommand{\nonterm}[2]{%
\ifthenelse{\equal{#2}{}}%
{\addspace\hbox{\textsl{#1}\ifnewentry\index{grammar entries!\textsl{#1}}\fi}\spacetrue}%
{\addspace\hbox{\textsl{#1}\footnote{#2}\ifnewentry\index{grammar entries!\textsl{#1}}\fi}\spacetrue}}
\newcommand{\repetstar}{$^*$\spacetrue}
\newcommand{\repetplus}{$^+$\spacetrue}
\newcommand{\repetone}{$^?$\spacetrue}
\newcommand{\lparen}{\addspace(}
\newcommand{\rparen}{)}
\newcommand{\orelse}{\addspace$\mid$\spacetrue}
\newcommand{\sep}{ \\[2mm] \spacefalse\newentrytrue}
\newcommand{\newl}{ \\ & & \spacefalse}
\newcommand{\alt}{ \\ & $\mid$ & \spacefalse}
\newcommand{\is}{ & $::=$ & \newentryfalse}
\newenvironment{syntax}{\begin{tabular}{@{}rrll@{}}\spacefalse\newentrytrue}{\end{tabular}}
\newcommand{\synt}[1]{$\spacefalse#1$}
\newcommand{\emptystring}{$\epsilon$}
\newcommand{\below}{See\; below}
% colors
\definecolor{darkgreen}{rgb}{0, 0.5, 0}
% theorems
\newtheorem{example}{Example}[chapter]
% for texttt
\newcommand{\bs}{\ensuremath{\backslash}}
%; whizzy section -pdf -initex "pdflatex -ini"
\documentclass[a4paper,web]{frama-c-book}
\usepackage{hevea}
\usepackage{ifthen}
\input{./macros_modern}
\input{eacslversion.tex}
%Do not touch the following line. It is used in a Makefile hack to
%produce the ACSL documents for the ACSL working group.
%--\setboolean{PrintRemarks}{false}
%Do not touch the following line. It is used in a Makefile hack to
%produce the ACSL document shipped with the Frama-C distribution.
%--\setboolean{PrintImplementationRq}{false}
%\setboolean{ColorImplementationRq}{false}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{color}
\usepackage{xspace}
\usepackage{makeidx}
\usepackage[normalem]{ulem}
\usepackage[leftbars]{changebar}
\usepackage{alltt}
\makeindex
\newcommand{\acslversion}{1.5\xspace}
\newcommand{\version}{\acslversion-4+dev\xspace}
\renewcommand{\textfraction}{0.01}
\renewcommand{\topfraction}{0.99}
\renewcommand{\bottomfraction}{0.99}
\begin{document}
\sloppy
\hbadness=10000
\ifthenelse{\boolean{PrintImplementationRq}}%
{\coverpage{\vbox{\mbox{E-ACSL Version \version}\\[5mm]
\mbox{\huge{Implementation in Frama-C plug-in E-ACSL
version \eacslversion{}}}}}}%
{\coverpage{\vbox{\mbox{E-ACSL}\\[2mm]\vbox{\mbox{\huge{Executable ANSI/ISO C
Specification Language}}}\\[2mm]
\mbox{Version \version}}}}
\begin{titlepage}
\includegraphics[height=14mm]{cealistlogo.jpg}
\vfill
\title{E-ACSL\\[5mm]\huge{Executable ANSI/ISO C Specification Language}}%
{Version \version{}\ifthenelse{\boolean{PrintImplementationRq}}%
{~--~Frama-C plug-in E-ACSL version \eacslversion}{}}
\author{Julien Signoles}
CEA LIST, Software Reliability Laboratory\\
\vfill
\begin{flushleft}
\textcopyright 2011-2012 CEA LIST
This work has been supported by the `Hi-Lite' FUI project (FUI AAP 9).
\end{flushleft}
\end{titlepage}
%%Contents should open on right
\cleardoublepage
\phantomsection
\label{chap:contents}
\tableofcontents
\chapter*{Foreword}
This is a preliminary design of the \eacsl language, a deliverable of
the task 3.4 of the FUI-9 project Hi-Lite
(\url{http://www.open-do.org/projects/hi-lite}).
This is the version \version{} of \eacsl design based on \acsl version
\acslversion~\cite{acsl}. Several features may still evolve in the future.
\section*{Acknowledgements}
We gratefully thank all the people who contributed to this document:
Patrick Baudin,
Bernard Botella,
Loc Correnson,
Pascal Cuoq,
Johannes Kanig,
Benjamin Monate,
Yannick Moy and
Virgile Prevosto.
\include{intro_modern}
\include{speclang_modern}
\include{libraries_modern}
\include{concl_modern}
\appendix
\chapter{Appendices}
\label{chap:appendix}
\include{changes_modern}
\cleardoublepage
\addcontentsline{toc}{chapter}{\bibname}
\bibliographystyle{plain}
\bibliography{./biblio}
\cleardoublepage
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
\cleardoublepage
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\end{document}
\begin{syntax}
declaration ::= C-declaration ;
| { "/*@" "model" C-declaration "*/" } ; model variable
\
struct-declaration ::= C-struct-declaration ;
| { "/*@" "model" C-struct-declaration "*/" } ; model field
\end{syntax}
\begin{syntax}
term ::= "\old" "(" term ")" ; old value
| "\result" ; result of a function
\
pred ::= "\old" "(" pred ")"
\end{syntax}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:
\begin{syntax}
rel-op ::= "==" | "!=" | "<=" | ">=" | ">" | "<"
\
pred ::= "\true" | "\false" ;
| term (rel-op term)+ ; comparisons
| { id "(" term ("," term)* ")" } ; predicate application
| "(" pred ")" ; parentheses
| [ pred "&&" pred ] ; conjunction
| [ pred "||" pred ] ; disjunction
| [ pred "==>" pred ] ; implication
| pred "<==>" pred ; equivalence
| "!" pred ; negation
| [ { pred "^^" pred } ] ; exclusive or
| [ term "?" pred ":" pred ] ; ternary condition
| [ pred "?" pred ":" pred ];
| { "\let" id "=" term ";" pred }; local binding
| { "\let" id "=" pred ";" pred };
| [ "\forall" binders ";" ] ;
[ integer-guards "==>" pred ]; univ. integer quantification
| [ "\exists" binders ";" ];
[ integer-guards "&&" pred ] ; exist. integer quantification
| [ { "\forall" binders ";" } ] ;
[ { iterator-guard "==>" pred } ]; univ. iterator quantification
| [ { "\exists" binders ";" } ];
[ { iterator-guard "&&" pred } ] ; exist. iterator quantification
| [ { "\forall" binders ";" pred } ]; univ. quantification
| [ { "\exists" binders ";" pred } ]; exist. quantification
| id ":" pred ; syntactic naming
\
[ integer-guards ] ::= [ interv ("&&" interv)* ]
\
[ interv ] ::= [ (term integer-guard-op)+ ] ;
[ id ] ;
[ (integer-guard-op term)+ ]
\
[ integer-guard-op ] ::= [ "<=" | "<" ]
\
[ { iterator-guard } ] ::= [ { id "(" term"," term ")" } ]
\end{syntax}
This diff is collapsed.
\begin{syntax}
statement ::= "/*@" statement-contract "*/" statement
\
[ statement-contract ] ::= {("for" id ("," id)* ":")?} requires-clause* ;
simple-clause* behavior-body*
\end{syntax}
FRAMAC_MODERN=frama-c-book.cls frama-c-cover.pdf frama-c-left.pdf frama-c-right.pdf
frama-c-book.cls: ../frama-c-book.cls
@rm -f $@
@cp $< .
@chmod a-w $@
@echo "import $<"
frama-c-cover.pdf: ../frama-c-cover.pdf
@rm -f $@
@cp $< .
@chmod a-w $@
@echo "import $<"
frama-c-right.pdf: ../frama-c-right.pdf
@rm -f $@
@cp $< .
@chmod a-w $@
@echo "import $<"
frama-c-left.pdf: ../frama-c-left.pdf
@rm -f $@
@cp $< .
@chmod a-w $@
@echo "import $<"
\begin{syntax}
bin-op ::= "+" | "-" | "*" | [ "/" ] | [ "%" ];
| "==" | "!=" | "<=" | ">=" | ">" | "<" ;
| [ "&&" ] | [ "||" ] | ; boolean operations
| { "&" } | { "|" } | { "-->" }
| { "<-->" } | { "^" } ; bitwise operations
\
unary-op ::= "+" | "-" ; unary plus and minus
| "!" ; boolean negation
| "~" ; bitwise complementation
| [ "*" ]; pointer dereferencing
| "&" ; address-of operator
\
term ::= { "\true" } | { "\false" };
| integer ; integer constants
| { real } ; real constants
| id ; variables
| unary-op term ;
| term bin-op term ;
| term "[" term "]" ; array access
| { "{" term "\with" "[" term "]" "=" term "}" } ; array functional modifier
| term "." id ; structure field access
| { "{" term "\with" "."id "=" term "}" } ; field functional modifier
| term "->" id ;
| [ "(" type-expr ")" term ] ; cast
| { id "(" term ("," term)* ")" } ; function application
| "(" term ")" ; parentheses
| [ term "?" term ":" term ] ; ternary condition
| { "\let" id "=" term ";" term } ; local binding
| "sizeof" "(" term ")" ;
| "sizeof" "(" C-type-expr ")" ;
| id ":" term ; syntactic naming
\end{syntax}
(* $Id: transf.mll,v 1.11 2009-03-03 09:53:08 uid562 Exp $ *)
{ open Lexing;;
let idx = Buffer.create 5
let full_kw = Buffer.create 5
let modern = ref false
let escape_keyword s =
let buf = Buffer.create 5 in
String.iter
(function
c when ('A' <= c && c <= 'Z') ||
('a' <= c && c <= 'z') ||
('0' <= c && c <= '9')
-> Buffer.add_char buf c
| c -> Buffer.add_string buf
(Printf.sprintf "\\char%d" (int_of_char c))) s;
Buffer.contents buf
let make_keyword () =
let keyword = Buffer.contents full_kw in
let index = Buffer.contents idx in
print_string "\\addspace";
if !modern then
Printf.printf
"\\lstinline$%s$" keyword
else
Printf.printf "\\texttt{%s}" (escape_keyword keyword);
if index <> "" then
Printf.printf "\\indextt%s{%s}"
(if keyword.[0] = '\\' then "bs" else "") index;
print_string "\\spacetrue";
Buffer.clear idx;
Buffer.clear full_kw
}
rule main = parse
"\\begin{syntax}" {
print_string "\\begin{syntax}";
syntax lexbuf }
| "\\@" {
print_string "@";
main lexbuf }
| _ {
print_char (lexeme_char lexbuf 0); main lexbuf }
| eof {
() }
and syntax = parse
"\\end{syntax}" {
print_string "\\end{syntax}";
main lexbuf }
| ";" ([^ '\n']* as s) '\n' [' ''\t']* '|' {
print_string "& \\textrm{";
print_string s;
print_string "} \\alt{}";
syntax lexbuf }
| ";" ([^ '\n']* as s) '\n' [' ''\t']* '\\' [' ''\t']* '\n' {
print_string "& \\textrm{";
print_string s;
print_string "} \\sep{}";
syntax lexbuf }
| ";" ([^ '\n']* as s) '\n' {
print_string "& \\textrm{";
print_string s;
print_string "} \\newl{}";
syntax lexbuf }
| "@" {
print_string "}";
main lexbuf }
| '\'' {
Buffer.clear idx;
Buffer.clear full_kw;
inquote lexbuf }
| '"' {
Buffer.clear idx;
Buffer.clear full_kw;
indoublequote lexbuf }
| "below" { print_string "\\below"; syntax lexbuf }
| "epsilon" { print_string "\\emptystring"; syntax lexbuf }
| ['A'-'Z''a'-'z''-'] + {
print_string "\\nonterm{";
print_string (lexeme lexbuf);
print_string"}";
check_nonterm_note lexbuf }
| '\\' ['a'-'z''A'-'Z'] + {
print_string (lexeme lexbuf);
syntax lexbuf }
| ['_' '^'] _ {
print_string (lexeme lexbuf);
syntax lexbuf }
| "*" { print_string "\\repetstar{}"; syntax lexbuf }
| "+" { print_string "\\repetplus{}"; syntax lexbuf }
| "?" { print_string "\\repetone{}"; syntax lexbuf }
| "(" { print_string "\\lparen{}"; syntax lexbuf }
| ")" { print_string "\\rparen{}"; syntax lexbuf }
| "::=" { print_string "\\is{}"; syntax lexbuf }
| "|" { print_string "\\orelse{}"; syntax lexbuf }
| "\\" { print_string "\\sep{}"; syntax lexbuf }
| "{" { print_string "\\begin{notimplementedenv}"; check_implementation_note lexbuf }
| "}" { print_string "\\end{notimplementedenv}"; syntax lexbuf }
| "[" { print_string "\\begin{markdiffenv}"; syntax lexbuf }
| "]" { print_string "\\end{markdiffenv}"; syntax lexbuf }
| _ {
print_char (lexeme_char lexbuf 0);
syntax lexbuf }
and inquote = parse
['A'-'Z' 'a'-'z' '0'-'9' '?'] as c {
Buffer.add_char full_kw c;
Buffer.add_char idx c;
inquote lexbuf }
| '\'' {
make_keyword ();
syntax lexbuf }
| '_' {
Buffer.add_char full_kw '_';
Buffer.add_string idx "\\_";
inquote lexbuf
}
| _ as c {
Buffer.add_char full_kw c;
inquote lexbuf }
and indoublequote = parse
['A'-'Z' 'a'-'z' '0'-'9' '?'] as c {
Buffer.add_char full_kw c;
Buffer.add_char idx c;
indoublequote lexbuf }
| '"' {
make_keyword();
syntax lexbuf }
| '_' {
Buffer.add_char full_kw '_';
Buffer.add_string idx "\\_";
indoublequote lexbuf
}
| _ as c {
Buffer.add_char full_kw c;
indoublequote lexbuf }
and check_implementation_note = parse
| "[" { print_string "["; implementation_note lexbuf }
| "" { syntax lexbuf }
and implementation_note = parse
"]" { print_string "]"; syntax lexbuf }
| _ { print_char (lexeme_char lexbuf 0);
implementation_note lexbuf }
and check_nonterm_note = parse
| "[" { print_string "{"; nonterm_note lexbuf }
| "" { print_string "{}"; syntax lexbuf }
and nonterm_note = parse
"]" { print_string "}"; syntax lexbuf }
| _ { print_char (lexeme_char lexbuf 0);
nonterm_note lexbuf }
{
let () = Arg.parse
[ "-modern", Arg.Set modern, "set modern style"; ]
(fun f ->
let cin = open_in f in
let lb = from_channel cin in
main lb;
close_in cin)
"transf [-modern] file";
exit 0
}
(* $Id: transfmain.ml,v 1.1 2007-05-29 08:23:19 uid562 Exp $ *)
let main() =
let lexbuf = Lexing.from_channel stdin in
print_string "% automatically generated DO NOT EDIT\n";
Transf.main lexbuf; flush stdout; exit 0;;
Printexc.print main ();;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment