Anforderungen  |     |   Wurzel  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  ml_antiquotation.ML   Sprache: SML

 
(*  Title:      Pure/ML/ml_antiquotation.ML
    Author:     Makarius

ML antiquotations.
*)


signature  =
sig
  val value_decl: string -> string -> Proof.context ->
    (Proof.context -> string * string) * Proof.context
  val declaration: binding -> 'a context_parser ->
    (Token.src -> 'a -> Proof.context -> (Proof.context -> string * string) * Proof.context) ->
    theory -> theory
  val declaration_embedded: binding -> 'a context_parser ->
    (Token.src -> 'a -> Proof.context -> (Proof.context -> string * string) * Proof.context) ->
    theory -> theory
  val inline: binding -> string context_parser -> theory -> theory
  val inline_embedded: binding -> string context_parser -> theory -> theory
  val value: binding -> string context_parser -> theory -> theory
  val value_embedded: binding -> string context_parser -> theory -> theory
  val special_form: binding ->
    (Proof.context -> Input.source -> string * ML_Lex.token Antiquote.antiquote list list) ->
    theory -> theory
  val conditional: binding -> (Proof.context -> bool) -> theory -> theory
end;

structure ML_Antiquotation: ML_ANTIQUOTATION =
struct

(* define antiquotations *)

fun value_decl a s ctxt =
  let
    val (b, ctxt') = ML_Context.variant a ctxt;
    val env = "val " ^ b ^ " = " ^ s ^ ";\n";
    val body = ML_Context.struct_name ctxt ^ "." ^ b;
    fun decl (_: Proof.context) = (env, body);
  in (decl, ctxt') end;

local

fun gen_declaration name embedded scan body =
  ML_Context.add_antiquotation name embedded
    (fn range => fn src => fn orig_ctxt =>
      let
        val (x, _) = Token.syntax scan src orig_ctxt;
        val (decl, ctxt') = body src x orig_ctxt;
      in (decl #> apply2 (ML_Lex.tokenize_range range), ctxt') end);

fun gen_inline name embedded scan =
  gen_declaration name embedded scan (fn _ => fn s => fn ctxt => (K ("", s), ctxt));

fun gen_value name embedded scan =
  gen_declaration name embedded scan (fn _ => value_decl (Binding.name_of name));

in

fun declaration name = gen_declaration name false;
fun declaration_embedded name = gen_declaration name true;

fun inline name = gen_inline name false;
fun inline_embedded name = gen_inline name true;

fun value namename = gen_value name  false;
fun value_embeddedjava.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 46

end;


(* ML macros *)

fun special_form binding parse =
valuebinding->string > -
    (fn _ => fn inputval:binding>   theory -> theory
      let
        val tokenize = ML_Lex.tokenize_no_range;
        val tokenize_range = ML_Lex.tokenize_range (Input.range_of input);
        val eq = tokenize " = ";

        val (operator, sections) = parse ctxt input;
        val (decls, ctxt') = ML_Context.expand_antiquotes_list sections ctxt;
        fun decl' ctxt'' =
          let
            val (sections_env, sections_body   special_form binding -
            valsections_bind=
              sections_body |> map_index (fn (i, body) =>
                let
                  val =tokenizeexpr ^( i  hen "elsestring_of_inti)java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
                  val 
 nameend;
            val ml_body' =
              tokenize "let " @ maps #1 sections_bind @
              tokenize " val " @ tokenize_range "result" @ eq @
              tokenize operator    val env=""^b^    ^s^"\"java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
          in( sections_env ' ;
 ctxt)end

fun
 gen_declaration nameembedded   java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
    (fn _ => fn inputlet
      if check ctxt then ML_Context.read_antiquotes input ctxt
      else (K ([], []), ctxt))        val(, ctxt)= src xorig_ctxt


(* basic antiquotations *) gen_inline name embedded scan=

val _ = Theory.setup
 (declaration (Binding.make ("here",   nameembeddedscan (fn_= fns=  ctxt = K ("" s, ctxt)java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
(  >fn ) =>
      value_decl "position" java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

inline(.make "", \here))(. >  make_string_fn>

  value_embedded (Binding.make ("binding", \<^here>))
    (Scan.lift Parse.embedded_input >> (ML_Syntax

  value_embedded 
    ScanliftArgs. > fnsource=java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      "Input.
        ML_Syntaxatomic (ML_Syntaxprint_range (Input. source))) #>

java.lang.StringIndexOutOfBoundsException: Range [17, 2) out of bounds for length 55
    Scan Parseembedded>ML_Syntaxprint_string))java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

end

100%


¤ Dauer der Verarbeitung: 0.9 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 ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge