CVS: sml-dist/src/ml-flex/src/BackEnds/Dump dump-output.sml,NONE,1.1
Matthias Blume <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml-dist/src/ml-flex/src/BackEnds/Dump In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27912/src/ml-flex/src/BackEnds/Dump Added Files: dump-output.sml Log Message: sources for ml-flex added; integration partially done --- NEW FILE: dump-output.sml --- (* dump-output.sml * * COPYRIGHT (c) 2005 * John Reppy (http://www.cs.uchicago.edu/~jhr) * Aaron Turon ([email protected]) * All rights reserved. * * Dump (to stdout) the complete DFA *) structure DumpOutput : OUTPUT = struct structure RE = RegExp structure LO = LexOutputSpec fun dumpDFA states = let fun nameOf (LO.State{id, ...}) = "Q" ^ Int.toString id fun prState (s as LO.State{id, label, final, next}) = let val name = (case final of [] => nameOf s | id::_ => concat[nameOf s, " (act ", Int.toString id, ")"] (* end case *)) fun prEdge (symSet, st) = print(concat[ " -- ", RE.toString (RE.mkSymSet symSet), " --> ", nameOf st, "\n" ]) fun prRE re = print (concat[" ", RE.toString re, "\n"]) in print(concat[name, ": "(*, RE.toString label*), "\n"]); Vector.app prRE label; List.app prEdge (!next); print "\n" end in (List.app prState states; print (Int.toString (List.length states)); print " states\n\n") end fun output (spec, _) = let val LO.Spec {machines, ...} = spec fun outMachine (LO.Machine {label, states, ...}) = (print "Start state: "; print label; print "\n"; dumpDFA states) in List.app outMachine machines end end ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642