gdl-parser 0.0.3

A parser for GDL (game description language)
docs.rs failed to build gdl-parser-0.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: gdl-parser-0.0.8

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 gdl_parser;
use gdl_parser::parse;

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

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.

program := { rule | sentence }

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

sentence := prop_lit | ( '(' rel_lit ')' )

literal := ( '(' (or_lit | not_lit | distinct_lit | rel_lit) ')' ) | prop_lit
not_lit := 'not' literal
or_lit := 'or' { literal }
distinct_lit := 'distinct' term term
prop_lit := constant
rel_lit := constant { term }

term := ( '(' func_term ')' ) | var_term | const_term
func_term := constant { term }
var_term := '?' constant
const_term := constant

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