Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Roqc/test-suite/output/   (Beweissystem des Inria Version 9.1.0©)  Datei vom 15.8.2025 mit Größe 1 kB image not shown  

Quelle  StringNotationErrors.v   Sprache: Coq

 
Require Import PrimInt63 PrimString.

Inductive smallstring := SmallString (_:string).

Declare Scope smallstring_scope.
Open Scope smallstring_scope.

Module V1.

  Definition of_smallstring '(SmallString v) := v.


  Definition to_smallstring v :=
    if PrimInt63.leb (length v) 10 then Ok (SmallString v)
    else Error (cat "not a small string: " v).

  String Notation smallstring to_smallstring of_smallstring : smallstring_scope.

  Check "hello".

  Fail Check "too long string".

  (* printing function doesn't check so we print something that doesn't parse *)
  Check SmallString "too long string".

End V1.

Module V2.
  Inductive smallstring_error := NotSmallString (_:string).

  Definition to_smallstring v :=
    if PrimInt63.leb (length v) 10 then Ok (SmallString v)
    else Error (NotSmallString v).

  Definition of_smallstring '(SmallString v) :=
    match to_smallstring v with
    | Ok _ => Ok v
    | Error e => Error e
    end.

  String Notation smallstring to_smallstring of_smallstring : smallstring_scope.

  Check "hello".

  Fail Check "too long string".

  (* printing function produces an error message but its content is ignored *)
  Check SmallString "too long string".
End V2.

Messung V0.5
C=89 H=99 G=94

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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 und die Messung sind noch experimentell.