3 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
5 // Centre for Speech Technology Research \\
6 // University of Edinburgh, UK \\
7 // Copyright (c) 1996,1997 \\
8 // All Rights Reserved. \\
9 // Permission is hereby granted, free of charge, to use and distribute \\
10 // this software and its documentation without restriction, including \\
11 // without limitation the rights to use, copy, modify, merge, publish, \\
12 // distribute, sublicense, and/or sell copies of this work, and to \\
13 // permit persons to whom this work is furnished to do so, subject to \\
14 // the following conditions: \\
15 // 1. The code must retain the above copyright notice, this list of \\
16 // conditions and the following disclaimer. \\
17 // 2. Any modifications must be clearly marked as such. \\
18 // 3. Original authors' names are not deleted. \\
19 // 4. The authors' names are not used to endorse or promote products \\
20 // derived from this software without specific prior written \\
22 // THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
23 // DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
24 // ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
25 // SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
26 // FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
27 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
28 // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
29 // ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
32 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
34 // Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
35 // -------------------------------------------------------------------- \\
36 // A Scheme reader which returns the s expression as s atring suitable \\
37 // for passing on to a scheme interpreter, eg for sending to festival. \\
39 //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
42 package cstr.festival.scheme ;
50 public class ReflectingSchemeReader extends SchemeReader
54 public ReflectingSchemeReader(Reader r)
59 private int parseSexp(StringBuffer b)
65 while (tk.ttype == StreamTokenizer.TT_EOL)
71 if (tk.ttype == StreamTokenizer.TT_EOF)
92 int se_type = parseSexp(b);
100 if (tk.ttype == StreamTokenizer.TT_WORD)
112 for(int i=s; i<b.length(); i++)
113 if (b.charAt(i) == '"')
118 else if (b.charAt(i) == '\n')
123 else if (b.charAt(i) == '\r')
128 else if (b.charAt(i) == '\t')
133 else if (b.charAt(i) == '\\')
142 if (tk.ttype >= ' ' && tk.ttype <= '\u00ff')
144 b.append((char)tk.ttype);
149 System.out.println("UNEXPECTED "+tk.ttype+" "+tk.sval);
153 public Object nextExpr()
156 return (Object)nextExprString();
159 public String nextExprString()
162 StringBuffer exp = new StringBuffer(80);
164 int type = parseSexp(exp);
166 return type == SE_EOF ? (String)null : exp.toString();