Dear Mozart Gurus,

I am doing some reflexive Metaprogramming, where
a Mozart program generates a string, which it then
parses itself by calling the Mozart parser.

Everything works fine for small inputs when parsing
as follows:

{Compiler.virtualStringToValue 'my program blabblaballablalalbala'}

I get into trouble though, when my program grows beyound
100000 characters (and this is what I need).

I know from Leif Kornstead (a while ago) that the Mozart
parser is not always linear in running time because of some
program analysis. Leif produced me a work around,
that I attach. It calls the Mozart parser without any
analysis.

The problem is that Leif's Hacks doesn't work when
allowing for function definitions in the program. And
this I need too.

Does some of you know the Mozart parser well enough,
in order to extend Leif's hack, so that it does also work with
functions? It is clear to me that the case of functions is left out there.

Many thanks in advance
Joachim Niehren






functor
import
   Parser(virtualString) at 'x-oz://boot/Parser'
export
   toValue:VSToValue
define
   fun {Trans X}
      case X of fAtom(A _) then A
      [] fInt(I _) then I
      [] fFloat(F _) then F
      [] fRecord(Label Args) then ArgCounter in
         ArgCounter = {NewCell 1}
         {List.toRecord {Trans Label}
          {Map Args
           fun {$ Arg}
              case Arg of fColon(F T) then
                 {Trans F}#{Trans T}
              else N NewN in
                 {Exchange ArgCounter ?N NewN}
                 NewN = N + 1
                 N#{Trans Arg}
              end
           end}}
      end
   end

   fun {VSToValue VS}
      case {Parser.virtualString VS options(defines: {NewDictionary})}
      of [ParseTree]#_ then {Trans ParseTree}
      end
   end
end

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to