01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: // This file is part of KeY - Integrated Deductive Software Design
09: // Copyright (C) 2001-2005 Universitaet Karlsruhe, Germany
10: // Universitaet Koblenz-Landau, Germany
11: // Chalmers University of Technology, Sweden
12: //
13: // The KeY system is protected by the GNU General Public License.
14: // See LICENSE.TXT for details.
15: //
16:
17: package de.uka.ilkd.key.parser;
18:
19: import java.io.Reader;
20:
21: import antlr.RecognitionException;
22: import antlr.TokenStreamException;
23: import de.uka.ilkd.key.java.Recoder2KeY;
24: import de.uka.ilkd.key.java.Services;
25: import de.uka.ilkd.key.logic.Namespace;
26: import de.uka.ilkd.key.logic.NamespaceSet;
27: import de.uka.ilkd.key.logic.Term;
28: import de.uka.ilkd.key.logic.TermFactory;
29: import de.uka.ilkd.key.logic.sort.Sort;
30: import de.uka.ilkd.key.pp.AbbrevMap;
31:
32: /** Defaut implementation of SimpleTermParser. This class wraps the
33: * default KeY-Term-Parser in the SimpleTermParser interface.
34: *
35: * @author Hubert Schmid
36: */
37:
38: public final class DefaultTermParser implements SimpleTermParser {
39:
40: /* --- methods --- */
41:
42: public Term parse(Reader in, Sort sort, Services services,
43: Namespace var_ns, Namespace func_ns, Namespace sort_ns,
44: Namespace progVar_ns, AbbrevMap scm) throws ParserException {
45: return parse(in, sort, services, new NamespaceSet(var_ns,
46: func_ns, sort_ns, new Namespace(), new Namespace(),
47: progVar_ns), scm);
48: }
49:
50: public Term parse(Reader in, Sort sort, Services services,
51: NamespaceSet nss, AbbrevMap scm) throws ParserException {
52: try {
53: KeYParser parser = new KeYParser(ParserMode.TERM,
54: new KeYLexer(in, services.getExceptionHandler()),
55: "", TermFactory.DEFAULT, new Recoder2KeY(services,
56: nss), services, nss, scm);
57:
58: return parser.term();
59: } catch (RecognitionException re) {
60: throw new ParserException(re.getMessage(), new Location(re
61: .getFilename(), re.getLine(), re.getColumn()));
62: } catch (TokenStreamException tse) {
63: throw new ParserException(tse.getMessage(), null);
64: }
65: }
66:
67: }
|