products/sources/formale sprachen/PVS/while image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: compiler.pvs   Sprache: PVS

Original von: PVS©

%------------------------------------------------------------------------------
% A Compiler for while
%
% All references are to HR and F Nielson "Semantics with Applications:
% A Formal Introduction", John Wiley & Sons, 1992. (revised edition
% available: http://www.daimi.au.dk/~hrn )
%
%     Author: David Lester, Manchester University, NIA, Université Perpignan
%
%     Version 1.0            25/12/07  Initial Version
%------------------------------------------------------------------------------

compiler[V:TYPE+]: THEORY

BEGIN

  IMPORTING AExp[V], BExp[V], Stm[V], Instruction[V], list_props_aux

  a: VAR AExp
  b: VAR BExp
  S: VAR Stm

  CA(a): RECURSIVE Code =
     cases a of
       N(n)       : cons(PUSH(n),null),
       V(x)       : cons(FETCH(x),null),
       Add(a1,a2) : append(CA(a2),append(CA(a1),cons(ADD,null))),
       Sub(a1,a2) : append(CA(a2),append(CA(a1),cons(SUB,null))),
       Mul(a1,a2) : append(CA(a2),append(CA(a1),cons(MUL,null)))
     endcases
     MEASURE a by <<

  CB(b) : RECURSIVE Code =
     cases b of
       TT         : cons(PUSH_TRUE,null),
       FF         : cons(PUSH_FALSE,null),
       Eq(a1,a2)  : append(CA(a2),append(CA(a1),cons(EQ,null))),
       Le(a1,a2)  : append(CA(a2),append(CA(a1),cons(LE,null))),
       Neg(b)     : append(CB(b),cons(NEG,null)),
       Band(b1,b2): append(CB(b2),append(CB(b1),cons(B_AND,null)))
     endcases
     MEASURE b by <<

  CS(S) : RECURSIVE Code =
     cases S of
       Assign(x,a)          : append(CA(a),cons(STORE(x),null)),
       Skip                 : cons(NOOP,null),
       Sequence(S1,S2)      : append(CS(S1),CS(S2)),
       Conditional(b,S1,S2) : append(CB(b),cons(BRANCH(CS(S1),CS(S2)),null)),
       While(b,S1)          : cons(LOOP(CB(b),CS(S1)),null)
     endcases
     MEASURE S by <<

  nonnull_CA: LEMMA NOT null?(CA(a))
  nonnull_CB: LEMMA NOT null?(CB(b))
  nonnull_CS: LEMMA NOT null?(CS(S))

END compiler

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤





Download des
Quellennavigators
Download des
sprechenden Kalenders

in der Quellcodebibliothek suchen




Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.


Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff