// Copyright 2005 the Contributors, as shown in the revision logs. // Licensed under the Apache Public Source License 2.0 ("the License"). // You may not use this file except in compliance with the License. package edu.berkeley.sbp.tib; //import org.ibex.util.*; //import org.ibex.io.*; import java.util.*; import java.io.*; public class TibDoc { /* public static enum Style { H, UL, TT, SO, IT, Q, B, PRE, LIST, EMDASH; } public static AST h(AST a) { return new Gather(a, Style.H); } public static AST ul(AST a) { return new Gather(a, Style.UL); } public static AST tt(AST a) { return new Gather(a, Style.TT); } public static AST so(AST a) { return new Gather(a, Style.SO); } public static AST it(AST a) { return new Gather(a, Style.IT); } public static AST q(AST a) { return new Gather(a, Style.Q); } public static AST b(AST a) { return new Gather(a, Style.B); } public static AST pre(AST a) { return new Gather(a, Style.PRE); } public static AST list(AST a) { return new Gather(a, Style.LIST); } public static AST emdash() { return new Gather(Style.EMDASH); } public static AST seq(AST a) { return new Gather(a); } public static class Latex { public static void emit(PrintWriter p, AST a) { prefix(p); emit(p, a, ""); suffix(p); } public static void emit2(PrintWriter p, AST ast, String head) { for(AST a = ast.getFirstChild(); a != null; a = a.getNextSibling()) emit(p, a, head); } public static void emit(PrintWriter p, AST ast, String head) { if (!(ast instanceof Gather)) { if (ast.getNumberOfChildren()==0) { p.print(ast.getText()); } else { emit2(p, ast, head); } return; } Gather a = (Gather)ast; if (a.style==null) { emit2(p, a, head); return; } switch(a.style) { case H: p.println(); p.println(); p.print("\\"+head+"section{"); emit2(p, a, "sub"+head); p.println("}"); break; case B: p.print("{\\bf{"); emit2(p, a, head); p.print("}}"); break; case UL: p.print("{\\ul{"); emit2(p, a, head); p.print("}}"); break; case IT: p.print("{\\it{"); emit2(p, a, head); p.print("}}"); break; case TT: p.print("{\\tt{"); emit2(p, a, head); p.print("}}"); break; case SO: p.print("{\\overstrike{"); emit2(p, a, head); p.print("}}"); break; case Q: p.print("``"); emit2(p, a, head); p.print("''"); break; case EMDASH: p.print(" \\emdash "); break; case LIST: p.println(); p.println("\\startitemize[symbol]"); emit2(p, a, head); p.println("\\stopitemize"); break; case PRE: if (a.getFirstChild() != null) { p.println(); p.println("\\begin{verbatim}"); p.println(a.getFirstChild().getText()); p.println("\\end{verbatim}"); } } } public static void prefix(PrintWriter p) { p.println("% generated by TIBDOC"); for(int i=0; i