├── README.md
├── LICENCE
├── styles.css
├── glue.js
├── index.html
├── parser.js
└── interpreter.js
/README.md:
--------------------------------------------------------------------------------
1 | Prolog interpreter
2 | ---------------
3 |
4 | Simple prolog interpreter using ES6 generators.
5 |
6 | For more details see https://curiosity-driven.org/prolog-interpreter
7 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | Copyright 2014 Curiosity driven
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
--------------------------------------------------------------------------------
/styles.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Curiosity driven
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | textarea { width: 90%; height: 400px; }
18 | input[type='text'] { width: 70%; }
--------------------------------------------------------------------------------
/glue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Curiosity driven
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | document.getElementById('submit').addEventListener('click', function() {
18 | var rules = parser(lexer(document.getElementById('rules').value)).parseRules();
19 |
20 | var db = new Database(rules);
21 |
22 | var goalText = document.getElementById('query').value;
23 |
24 | var goal = parser(lexer(goalText)).parseTerm();
25 |
26 | var list = document.getElementById('answers');
27 | list.innerHTML = '';
28 |
29 | for (var item of db.query(goal)) {
30 | var li = document.createElement('LI');
31 | li.textContent = item;
32 | list.appendChild(li);
33 | }
34 |
35 | if (list.innerHTML === '') {
36 | list.innerHTML = 'No solutions';
37 | }
38 | });
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |