Hi all,
I've been playing with MTASC for a project that involves compiling some machine-generated ActionScript.
Unfortunately, this machine-generated code, while correct, for various
reasons violates some of the additional restrictions that MTASC places
on the source it compiles, so MTASC won't compile it.
The two issues that I've run into (so far) are:
1. MTASC does not allow named nested functions.
This one I think I can work around simply with a bulk search/replace that changes all occurrences of:
function outer() {
function inner() {
...
}
}
to:
function outer() {
var inner = function() {
...
}
}
2. MTASC doesn't allow referring to a variable in a nested function before that variable is declared, e.g.:
function outer() {
var f = function() {
y++;
}
var y;
...
}
This code causes an "Unknown variable" error and has got me completely stuck.
What would be great is a "-lenient" command line flag that relaxes these (and possibly other) restrictions.
How hard would it be to implement such a flag? Any pointers on what would be required?
By the way, I tried the attached patch to fix #2 but got "Fatal error:
exception Match_failure("
typer.ml", 537, 4)". I don't know ML at all...
so I would greatly appreciate help in creating a patch for myself that
I could use to disable this forward reference check for the time being.
Thanks!
-Archie
--
Archie L. Cobbs
diff -ur mtasc-cvs-20080209223901.orig/ocaml/mtasc/typer.ml mtasc-cvs-20080209223901/ocaml/mtasc/typer.ml
--- mtasc-cvs-20080209223901.orig/ocaml/mtasc/typer.ml 2008-02-13 21:02:29.000000000 -0600
+++ mtasc-cvs-20080209223901/ocaml/mtasc/typer.ml 2008-02-13 21:03:28.000000000 -0600
@@ -535,8 +535,7 @@
| [] -> assert false
in
(match last p with
- | x when String.length x > 0 && x.[0] >= 'A' && x.[0] <= 'Z' -> error (Custom ("Unknown class " ^ String.concat "." p)) pos
- | _ -> error (Custom ("Unknown variable " ^ List.hd p)) pos)
+ | x when String.length x > 0 && x.[0] >= 'A' && x.[0] <= 'Z' -> error (Custom ("Unknown class " ^ String.concat "." p)) pos)
| (p,use) :: l ->
try
let r = search_package p in
--
MTASC : no more coffee break while compiling