CVS: sml-dist/src/lexgen/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/lexgen/src/BackEnds/Dump In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30700/src/lexgen/src/BackEnds/Dump Added Files: dump-output.sml Log Message: ml-flex -> lexgen --- 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 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 fun dumpDFA states = (List.app prState states; print (Int.toString (List.length states)); print " states\n\n") fun outSS (label, ss) = (print "Start state: "; print label; print " => "; print (nameOf ss); print "\n") fun output (spec, _) = let val LO.Spec {dfa, startStates, ...} = spec in dumpDFA dfa; print "\n"; List.app outSS startStates 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