Mathematical Language Evolution Design: Difference between revisions

From Event-B
Jump to navigationJump to search
imported>Mathieu
imported>Nicolas
Line 19: Line 19:
=== Parser Changes ===
=== Parser Changes ===


The new parser has a version attribute. Depending on the version, formulas are parsed differently. Thus, the KPARTITION node will not be recognized if version is V1. It is accepted only from version V2. Conversely, KPRJ1 is accepted for V1 but not for V2.
The new parser has a version attribute. Depending on the version, formulas are parsed differently. Thus, the KPARTITION node is illegal if version is V1. It is accepted only from version V2.
Concerning, identity and projections, they are recognized as non-generic with V1 and generic with V2.
The following table summarizes how tokens are processed depending on the parser version:
 
 
{| border="4"
|+ Token Recognition
! scope=col |
! scope=col |Parser V1
! scope=col |Parser V2
|-
! scope=row |"partition"
|illegal
|KPARTITION
|-
! scope=row |"id"
|KID
|KID_GEN
|-
! scope=row |"prj1"
|KPRJ1
|KPRJ1_GEN
|-
! scope=row |"prj2"
|KPRJ2
|KPRJ2_GEN
|}


==== Parsing ====
==== Parsing ====

Revision as of 11:07, 25 March 2009

Introduction

This document describes the modifications that occur to the Event-B mathematical language from the developer point of view. The old language will still be recognized, in order to provide backward compatibility.

Syntax Tree

Deprecated nodes (becoming atomic expressions):

  • KPRJ1
  • KPRJ2
  • KID

New nodes:

  • KPARTITION that represents the new partition predicate (relational predicate)
  • KPRJ1_GEN that represents the atomic version of the first projection
  • KPRJ2_GEN that represents the atomic version of the second projection
  • KID_GEN that represents the atomic version of the identity

Parser Changes

The new parser has a version attribute. Depending on the version, formulas are parsed differently. Thus, the KPARTITION node is illegal if version is V1. It is accepted only from version V2. Concerning, identity and projections, they are recognized as non-generic with V1 and generic with V2. The following table summarizes how tokens are processed depending on the parser version:


Token Recognition
Parser V1 Parser V2
"partition" illegal KPARTITION
"id" KID KID_GEN
"prj1" KPRJ1 KPRJ1_GEN
"prj2" KPRJ2 KPRJ2_GEN

Parsing

FormulaFactory has new parse() methods with a parser version argument. Existing methods default to the latest version. To cope with version problems, parsing is done in several steps:

  • try to parse with the given version (or latest by default)
  • if parse succeeds, the result is returned as usual
  • else, try to parse with older versions incrementally
    • if no version succeeds, return the failed result of the parse call with the latest version
    • else propose upgrading from the highest succeeding version to the latest

Multiple Predicates / Partition

A new predicate class is introduced: {class|MultiplePredicate} that is abstract and superclasses {class|Partition}. A {class|MultiplePredicate} is a predicate that applies to a list of two or more expressions. In a {class|Partition}, all expressions must have the same type, that is the type of the partitioned set (first child).

Visitors

IVisitor has three more methods:

  • enter KPARTITION
  • continue KPARTITION
  • exitKPARTITION

ISimpleVisitor has one more method:

  • visitMultiplePredicate

Sequent Prover

TODO

Affected client code

TODO


Upgrade