GDL Parser

This is a parser for GDL (game description language). GDL is a subset Datalog, but when used for GGP (general game playing) it is sent in KIF (knowledge interchange format). This parser focuses on GDL and not KIF for the purpose of GGP and is currently being used in ggp-rs.

The parser converts a GDL string to an AST but does not do any semantic analysis on this AST. It makes use of the rust-peg parser generator. The AST is based off of the AST used in GGP Base which can be seen here.

You can find the specification for GDL here and the specification for KIF here.

Installation

You can install the package from crates.io by adding the following to the dependencies section of your Cargo.toml:

gdl-parser = "*"

Usage

``` extern crate gdlparser; use gdlparser::parse;

println!("{:?}", parse("(role red) (role black)")); ```

Documentation

You can find the API docs here.

Grammar

Here is the EBNF of the grammar. I came up with this EBNF myself by examining the parsing code in GGP Base, so if there are any bugs please report them.

``` description := { rule | sentence }

rule := '(' '<=' sentence { literal } ')'

sentence := proplit | ( '(' rellit ')' )

literal := ( '(' (orlit | notlit | distinctlit | rellit) ')' ) | proplit notlit := 'not' literal orlit := 'or' { literal } distinctlit := 'distinct' term term proplit := constant rellit := constant { term }

term := ( '(' functerm ')' ) | varterm | constterm functerm := constant { term } varterm := '?' constant constterm := constant

(* ident is any string of letters, digits, and underscores *) constant := ident ```

License

MIT