1 /*
2 * #%L
3 * prolobjectlink-jpi
4 * %%
5 * Copyright (C) 2019 Prolobjectlink Project
6 * %%
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 * #L%
25 */
26 package io.github.prolobjectlink.prolog;
27
28 import java.io.File;
29 import java.util.Set;
30
31 /**
32 * Prolog parser interface used for build terms from string with Prolog syntax.
33 *
34 * @author Jose Zalacain
35 * @since 1.0
36 */
37 interface PrologParser extends PrologMapper {
38
39 /**
40 * Parse the string with Prolog syntax and create an equivalent Prolog term
41 * instance.
42 *
43 * @param term prolog term in string format.
44 * @return a Prolog term from prolog text
45 * @since 1.0
46 */
47 public PrologTerm parseTerm(String term);
48
49 /**
50 * Parse the comma separate terms in the given string with prolog syntax and
51 * return an array of terms formed by the comma separate terms.
52 *
53 * @param stringTerms comma separate terms with prolog syntax
54 * @return an array of terms formed by the comma separate terms.
55 * @since 1.0
56 */
57 public PrologTerm[] parseTerms(String stringTerms);
58
59 /**
60 * Parse the string with Prolog syntax and create an equivalent Prolog list term
61 * instance.
62 *
63 * @param stringList prolog term in string format.
64 * @return a Prolog term from prolog text.
65 * @since 1.0
66 */
67 public PrologList parseList(String stringList);
68
69 /**
70 * Parse the string with Prolog syntax and create an equivalent Prolog structure
71 * term instance.
72 *
73 * @param stringStructure prolog term in string format.
74 * @return a Prolog term from prolog text.
75 * @since 1.0
76 */
77 public PrologStructure parseStructure(String stringStructure);
78
79 /**
80 * Parse the string with Prolog syntax and create an equivalent Prolog clause
81 * instance.
82 *
83 * @param clause prolog clause in string format.
84 * @return a Prolog clause from prolog text.
85 * @since 1.0
86 */
87 public PrologClause parseClause(String clause);
88
89 /**
90 * Parse the Prolog text contained at specific file path and return a Prolog
91 * clause set found in the file.
92 *
93 * @param file file path to be parsed.
94 * @return a Prolog clause set found in the file.
95 * @since 1.0
96 */
97 public Set<PrologClause> parseProgram(String file);
98
99 /**
100 * Parse the Prolog text contained at specific file and return a Prolog clause
101 * set found in the file.
102 *
103 * @param in file to be parsed.
104 * @return a Prolog clause set found in the file.
105 * @since 1.0
106 */
107 public Set<PrologClause> parseProgram(File in);
108
109 }