-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Funny Prolog interpreter can be used an a new scripting language inside the Java VM. It was designed especially to use with the javax.script Java package functionality. To avoid duplication of the JavaDoc, this page contains only Funny Prolog Virtual Machine (FProVM) functionality description.
Content of the page is:
FProVM consists of:
- String and term syntax trees
- Fact and rule repository
- External plugins repository
- Global stack
- Parser and Printer
- Standard resolution plugin
Both of the trees are based on Pure Library class chav1961.purelib.basic.AndOrTree and used to convert any string and term mnemonics to it's internal form (long ids). Using long ids instead of strings and terms is a common practice to speed up resolution performance.
This repository is in-memory database, that can be serialized to persistent store and deserialized from it. Repository contains chains of facts and rules support usual set of operations with them (seek, prepend/append, remove)
This repository support list of external plugins for interpreter. External plugin is any class implements chav1961.funnypro.core.interfaces.FProPluginList interface. All the plugins connects to FProVM by standard Java SPI protocol, file name for this protocol is META-INF/services/chav1961.funnypro.core.interfaces.FProPluginList.
Any external plugin needs support chav1961.funnypro.core.interfaces.IResolvable interface asccording to it's life cycle (see JavaDoc). FProVM correctly includes your plugin into resolution machine and allows you extend the standard Funny Prolog interpreter functionality by simple way.
GLobal stack is a standard implementation of most of all Prolog machines. It contains a set of methods to manipulate data in it and to use this stack in the unification and backtracking processes.
A special class for quick parsing Prolog sentences to it's internal form and convert the internal form of the Prolog entites to it's mnemonic.
Resolution machine is aslo an external plugin. This plugin implements most of basic functionality of the resolution machine and supports a set of built-in predicates and operatiors in the Prolog database.
The complete list of built-in operators at the current release:
- :-op(1200,xfx,:-).
- :-op(1200,fx,:-).
- :-op(1200,fx,?-).
- :-op(1100,xfy,;).
- :-op(1100,xfx,|).
- :-op(1050,xfy,->).
- :-op(1000,xfy,,).
- :-op(900,fy,not).
- :-op(900,fy,+).
- :-op(700,xfx,=).
- :-op(700,xfx,=).
- :-op(700,xfx,==).
- :-op(700,xfx,==
- :-op(700,xfx,=..).
- :-op(700,xfx,is).
- :-op(700,xfx,=:=).
- :-op(700,xfx,==).
- :-op(700,xfx,<).
- :-op(700,xfx,=<).
- :-op(700,xfx,>).
- :-op(700,xfx,>=).
- :-op(700,xfx,@<).
- :-op(700,xfx,@<=).
- :-op(700,xfx,@>).
- :-op(700,xfx,@>=).
- :-op(500,yfx,+).
- :-op(500,yfx,-).
- :-op(400,yfx,*).
- :-op(400,yfx,/).
- :-op(400,yfx,//).
- :-op(400,yfx,mod).
- :-op(200,xfx,**).
- :-op(200,xfy,^).
- :-op(200,fy,-).
The complete list of built-in predicates at the current release:
- trace.
- notrace.
- spy.
- !.
- fail.
- true.
- repeat.
- asserta(?).
- assertz(?).
- assert(?).
- retract(?).
- call(?).
- var(?).
- nonvar(?).
- atom(?).
- integer(?).
- float(?).
- number(?).
- atomic(?).
- compound(?).
- functor(?,?,?).
- arg(?,?,?).
- name(?,?).
- bagof(?,?,?).
- setof(?,?,?).
- findall(?,?,?).
- memberOf(?,?).
(c) 2017, Alexander V. Chernomyrdin aka chav1961, Funny Prolog interpreter