Skip to content
Browse files

[feature] syntax: syntax helper

  • Loading branch information...
1 parent 6e9d74e commit 415cfc302a111a9942116e2acb3c8e47c16466e8 @BourgerieQuentin BourgerieQuentin committed with OpaOnWindowsNow Nov 22, 2011
Showing with 108 additions and 1 deletion.
  1. +2 −1 opa/_tags
  2. +23 −0 opa/s3Passes.ml
  3. +13 −0 opa/s3Passes.mli
  4. +70 −0 opa/syntaxHelper.ml
View
3 opa/_tags
@@ -54,9 +54,10 @@
# s3 main
<s3Passes.{ml,mli}>: use_pplib, use_libqmlcompil, use_opalib, use_qmlslicer, use_passlib, use_opapasses, use_qml2ocaml, use_opalang, use_libbsl, use_qmlfakecompiler, use_qmlflatcompiler, use_ocamllang, use_qmlpasses, use_qml2js
<{main,gen_opa_manpage}.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib
+<syntaxHelper.ml>: use_opalib, use_opalang, use_opapasses, use_libqmlcompil, use_qml2ocaml, use_passlib
# linking
-<{main,opa_parse,checkopacapi,gen_opa_manpage}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi
+<{main,opa_parse,checkopacapi,gen_opa_manpage,syntaxHelper}.{byte,native}>: thread, use_dynlink, use_graph, use_str, use_cryptokit, use_unix, use_nums, use_zip, use_buildinfos, use_libbase, use_ulex, use_libtrx, use_libqmlcompil, use_libbsl, use_opalib, use_opalang, use_opapasses, use_qmlfakecompiler, use_qmlflatcompiler, use_qml2ocaml, use_qmljsimp, use_qml2js, use_opabsl_for_compiler, use_qmlslicer, use_jslang, use_qmlcpsrewriter, use_ocamllang, use_passlib, use_compilerlib, use_pplib, use_qmlpasses, use_opacapi
<opa_InsertRemote.ml>: with_mlstate_debug
<main_utils.ml>: with_mlstate_debug
View
23 opa/s3Passes.ml
@@ -460,6 +460,26 @@ let pass_RegisterAppSrcCode =
PassHandler.make_env options (special_files, user_files)
)
+let pass_Print =
+ PassHandler.make_pass
+ (fun e ->
+ let options = e.PH.options in
+ let module Printer = (val OpaPrint.getDefaultFamilly () : OpaPrint.Familly) in
+ if not (File.exists options.O.build_dir) then Unix.mkdir options.O.build_dir 0o740;
+ List.iter
+ (function pfile ->
+ let fn = Filename.concat options.O.build_dir
+ pfile.SurfaceAstPassesTypes.parsedFile_filename in
+ OManager.verbose "Convert %s to %s"
+ pfile.SurfaceAstPassesTypes.parsedFile_filename fn;
+ let oc = open_out fn in
+ let fmt = Format.formatter_of_out_channel oc in
+ Printer.string#code fmt pfile.SurfaceAstPassesTypes.parsedFile_lcode;
+ ignore (close_out oc)
+ ) (snd (fst e.PH.env));
+ e
+ )
+
let pass_LoadObjects k =
PH.make_pass
(fun env ->
@@ -2187,3 +2207,6 @@ let () =
| "ByeBye" -> None
| _ -> None)
+
+
+
View
13 opa/s3Passes.mli
@@ -97,6 +97,18 @@ val pass_Parse :
)
opa_pass
+val pass_Print :
+ (
+ ((
+ ( SurfaceAst.parsing_directive SurfaceAstPassesTypes.parsed_file list
+ * SurfaceAst.parsing_directive SurfaceAstPassesTypes.parsed_file list
+ )
+ )
+ * env_OpenFiles) as 'parsed_files
+ ,
+ 'parsed_files
+ ) opa_pass
+
val pass_RegisterAppSrcCode :
(
(
@@ -109,6 +121,7 @@ val pass_RegisterAppSrcCode :
'parsed_files
) opa_pass
+
val pass_BslLoading :
((((SurfaceAst.nonuid, SurfaceAst.parsing_directive)
SurfaceAst.code_elt) ObjectFiles.parsed_code) as 'parsed_code
View
70 opa/syntaxHelper.ml
@@ -0,0 +1,70 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+(** The main program for the OPA compiler. S3 version. *)
+
+(* Opening the generic pass system. *)
+module PH = PassHandler
+
+(* FIXME: define a module InfixOperators in PassHandler *)
+(* this could by the only case an 'open' is allowed *)
+let (|+>) = PH.(|+>)
+let (|>) = PH.(|>)
+let (<?>) = PH.(<?>)
+let (&) = PH.(&)
+let (|?>) = PH.(|?>)
+let (or) = PH.(or)
+
+(* Shorthands for accessing options of compilation *)
+module If = Main_utils.If
+
+(* The deprecated passes *)
+(* FIXME: adapt to the new PassHandler *)
+module S2 = Passes
+
+(* S3 implementations. *)
+module S3 = S3Passes
+
+(* Set title of generic pass system. *)
+let _ = PH.set_title "SyntaxConverter"
+
+(* Load warnings of opa s3 applications *)
+let _ = WarningClass.load_set S3Warnings.warning_set
+
+(* Run all passes *)
+let _ =
+ PH.init
+
+ |+> ("Welcome", S3.pass_Welcome)
+
+ |+> ("CheckOptions", S3.pass_CheckOptions)
+
+ |+> ("AddStdlibFiles", S3.pass_AddStdlibFiles)
+
+ |> PH.old_handler
+ "OpenFiles" S2.pass_OpenFiles
+
+ |+> ("PreProcess", S3.pass_PreProcess)
+
+ |+> ("Parse", S3.pass_Parse)
+
+ |+> ("Print", S3.pass_Print)
+
+ |> PH.return
+
+let () = OManager.exit 0

0 comments on commit 415cfc3

Please sign in to comment.
Something went wrong with that request. Please try again.