Skip to content

raydac/java-prolog-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Apache 2.0 Maven central Java 8.0+ PayPal donation Yandex.Money donation

Preword

During my development of Java prolog engine (JProl) I had developed parser to parse sources written in Edinburgh style, I decided to extract the module into separated project and 1.0.0 version was published. In 2018 I had decided to make deep refactoring and 2.0.0 version was published. The Parser allows build custom prolog parsers with support of operators and some modern prolog features.

Features

It supports

  • prolog operators
  • line and block commentaries
  • underline splitted numbers
  • curly blocks

How to use?

Parser implements stream which sequentially reads prolog terms from reader. By default PrologParser is abstract class but there is GenericPrologParser class provides minimalistic implementation.

Reader reader = new StringReader("hello(world). some({1,2,3}). power(X,Y,Z) :- Z is X ** Y."); PrologParser parser = new GenericPrologParser(reader, new DefaultParserContext(ParserContext.FLAG_CURLY_BRACKETS, Op.SWI)); parser.forEach(System.out::println); 

Supported Prolog terms

The parser supports

  • atoms (class PrologAtom)
  • numbers (classes PrologInt and PrologFloat), they are based on big numbers so that their size is not restricted
  • lists (class PrologList)
  • structures (class PrologStruct)
  • variables (class PrologVar)

Supported quotations:

  • single quote '
  • double quote "
  • back tick

Bracketed empty-functor structures represented by structure with functor either {} or () (depends on bracket type).

About

Java based Edinburgh Prolog parser

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published