CSc 4340/6340, Introduction to Compilers
Spring 2012
PROJECT (DatalogQ/Datalog) - Grammar

DatalogQ Grammar

ddb ::= idb_rules DOLLAR
idb_rules ::= idb_rule | idb_rule idb_rules
idb_rule ::= NAME LPAREN regular_arg_list RPAREN IMPLIES idb_body PERIOD
idb_body ::= literal | literal COMMA idb_body
literal ::= NOTOP predicate | predicate
predicate ::= NAME LPAREN arg_list RPAREN | regular_arg COMPARISON regular_arg
arg_list ::= arg | arg COMMA arg_list
arg ::= regular_arg | complex_arg
regular_arg ::= NUMBER | STRING | VARIABLE
simple_arg ::= NUMBER | STRING | VARIABLE | STAR | HASH
complex_arg ::= 
  LBRACKET star_list_or_hash_list RBRACKET COLON NAME LPAREN simple_arg_list RPAREN
regular_arg_list ::= regular_arg | regular_arg COMMA regular_arg_list
simple_arg_list ::= simple_arg | simple_arg COMMA simple_arg_list
star_list_or_hash_list ::= star_list | hash_list
star_list ::= STAR | STAR COMMA star_list
hash_list ::= HASH | HASH COMMA hash_list

Datalog Grammar (for undergraduates)

ddb ::= idb_rules DOLLAR
idb_rules ::= idb_rule | idb_rule idb_rules
idb_rule ::= NAME LPAREN arg_list RPAREN IMPLIES idb_body PERIOD
idb_body ::= literal | literal COMMA idb_body
literal ::= NOTOP predicate | predicate
predicate ::= NAME LPAREN arg_list RPAREN | arg COMPARISON arg
arg_list ::= arg | arg COMMA arg_list
arg ::= NUMBER | STRING | VARIABLE