src/Pure/System/scala_compiler.ML
changeset 72294 25c6423ec538
parent 71906 a63072d875d1
child 73761 ef1a18e20ace
equal deleted inserted replaced
72293:584aea0b29bb 72294:25c6423ec538
     4 Scala compiler operations.
     4 Scala compiler operations.
     5 *)
     5 *)
     6 
     6 
     7 signature SCALA_COMPILER =
     7 signature SCALA_COMPILER =
     8 sig
     8 sig
     9   val toplevel: string -> unit
     9   val toplevel: bool -> string -> unit
    10   val static_check: string * Position.T -> unit
    10   val static_check: string * Position.T -> unit
    11 end;
    11 end;
    12 
    12 
    13 structure Scala_Compiler: SCALA_COMPILER =
    13 structure Scala_Compiler: SCALA_COMPILER =
    14 struct
    14 struct
    15 
    15 
    16 (* check declaration *)
    16 (* check declaration *)
    17 
    17 
    18 fun toplevel source =
    18 fun toplevel interpret source =
    19   let val errors =
    19   let val errors =
    20     \<^scala>\<open>scala_toplevel\<close> source
    20     (interpret, source)
       
    21     |> let open XML.Encode in pair bool string end
       
    22     |> YXML.string_of_body
       
    23     |> \<^scala>\<open>scala_toplevel\<close>
    21     |> YXML.parse_body
    24     |> YXML.parse_body
    22     |> let open XML.Decode in list string end
    25     |> let open XML.Decode in list string end
    23   in if null errors then () else error (cat_lines errors) end;
    26   in if null errors then () else error (cat_lines errors) end;
    24 
    27 
    25 fun static_check (source, pos) =
    28 fun static_check (source, pos) =
    26   toplevel ("package test\nclass __Dummy__ { __dummy__ => " ^ source ^ " }")
    29   toplevel false ("package test\nclass __Dummy__ { __dummy__ => " ^ source ^ " }")
    27     handle ERROR msg => error (msg ^ Position.here pos);
    30     handle ERROR msg => error (msg ^ Position.here pos);
    28 
    31 
    29 
    32 
    30 (* antiquotations *)
    33 (* antiquotations *)
    31 
    34