|
Project Information
Links
|
The Java Prolog Parser was developed as a part of the Prol engine (it is an embeddable Prolog Java engine) but lately it was separated as a free-standing open source project to allow for everyone to develop own Prolog engines in Java.
The parser allows to parse prolog sources written in the Edinburgh style (pay your attention, it supports only '%' comments). It can use below Java objects as char data sources:
- java.lang.String
- java.io.InputStream
- java.nio.channels.ReadableByteChannel
- java.io.Reader
The 'Hello World' examplefinal PrologParser parser = new PrologParser(null);
try {
final PrologStructure structure = (PrologStructure) parser.nextSentence("hello :- world.");
System.out.println(structure.getElement(0).getText()+' '+structure.getElement(1).getText());
}catch(Exception unexpected){
throw new RuntimeException(unexpected);
}
|