Uses 419K of libraries. Click here for Pure Java version (99L/1K/4K).
1 | !752 |
2 | !1002813 // gnu prolog |
3 | |
4 | import gnu.prolog.vm.*; |
5 | import gnu.prolog.term.*; |
6 | import gnu.prolog.database.*; |
7 | |
8 | static int query(Interpreter intp, Term term) ctex { |
9 | try { |
10 | Interpreter.Goal goal = intp.prepareGoal(term); |
11 | ret intp.execute(goal); |
12 | // todo: stop goal? |
13 | } catch (Exception e) { |
14 | print("fail " + e); |
15 | ret 0; |
16 | } |
17 | } |
18 | |
19 | p { |
20 | new Environment env; |
21 | |
22 | S streamName = "someinput"; |
23 | Reader reader = new StringReader("here."); |
24 | |
25 | new PrologTextLoader(env.getPrologTextLoaderState(), reader, streamName); |
26 | |
27 | List<PrologTextLoaderError> errors = env.getLoadingErrors(); |
28 | for (PrologTextLoaderError error : errors) { |
29 | printStackTrace(error); |
30 | } |
31 | |
32 | Interpreter interpreter = env.createInterpreter(); |
33 | env.runInitialization(interpreter); |
34 | |
35 | //print(interpreter.runOnce(AtomTerm.get("here"))); |
36 | //print(interpreter.runOnce(AtomTerm.get("there"))); |
37 | print(query(interpreter, AtomTerm.get("true"))); |
38 | print(query(interpreter, AtomTerm.get("there"))); |
39 | print(query(interpreter, AtomTerm.get("here"))); |
40 | } |
Began life as a copy of #1002814
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date |
---|---|---|---|
1212 | stefan | Ok, KINDA works... | 2016-02-27 01:50:51 |
Snippet ID: | #1002815 |
Snippet name: | GNU Prolog Test 2 (loading text) |
Eternal ID of this version: | #1002815/1 |
Text MD5: | e87edd51ec87a42405a593bcefd6b89f |
Transpilation MD5: | b9157e4b71db63b8f3a43e977ef4e27c |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-27 01:50:26 |
Source code size: | 1063 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 850 / 1045 |
Referenced in: | [show references] |