From: Petra M. <Pet...@mc...> - 2008-04-17 02:05:38
|
Hi Pablo, If you want to print in LaTeX markup, you not only need the AST but the operator table, for example, too. You could use the original section manager (that contains all that information) to get the latex FileSource source = new FileSource("bbook.tex"); String name = source.getName(); SectionManager manager = new SectionManager(); manager.put(new Key(name, Source.class), source); LatexString latex = (LatexString) manager.get(new Key(name, LatexString.class)); rather than creating a new one and transfering the data from one to the other. Petra Pablo Rodriguez Monetti wrote: > Hi czt'ers! I would like to transform Java AST objects into a .tex > file, so I make some attempts (using the release 1.0 of czt) with a > program similar to the following: > > > // > ***************************************************************************************************************** > import net.sourceforge.czt.print.util.LatexString; > import net.sourceforge.czt.session.*; > import net.sourceforge.czt.z.ast.*; > import net.sourceforge.czt.z.impl.*; > import net.sourceforge.czt.base.ast.*; > import net.sourceforge.czt.base.ast.Term; > import net.sourceforge.czt.util.ReflectionUtils; > import java.io.*; > > public class TexPrinting{ > > public static void main(String[] args) { > FileSource source = new FileSource("bbook.tex"); > SectionManager manager = new SectionManager(); > manager.put(new Key(source.getName(), Source.class), source); > try{ > Spec spec = (Spec) manager.get(new Key(source.getName(), > Spec.class)); > manager = new SectionManager(); > manager.put(new Key("bbook", Spec.class), spec); > LatexString latex = (LatexString) manager.get(new > Key("bbook", LatexString.class)); > System.out.println(latex); > } > catch(Exception e){ > System.out.println (e); > } > } > > } > // > ***************************************************************************************************************** > > > > The results were correct (so quite useful for the tool I am developing) > but it also prints the following warning messages: > > 11/03/2008 15:10:25 net.sourceforge.czt.parser.util.WarningManager warn > ADVERTENCIA: Cannot get operator table for Specification; try to print > anyway ... > 11/03/2008 15:10:25 > net.sourceforge.czt.print.z.CUP$Unicode2Latex$actions setupMarkupTable > ADVERTENCIA: Cannot get latex markup for section Specification caused by > net.sourceforge.czt.session.SourceLocator$SourceLocatorException: Cannot > find source location for section Specification > > > I was trying to modify my local version of czt in order to avoid the > printing of these warnings but the attempt was not successfull. Any > suggestions? Which (source?) files I should modify? > > Thanks, > > Pablo > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > CZT-Users mailing list > CZT...@li... > https://lists.sourceforge.net/lists/listinfo/czt-users |