Source

pyDatalog / pyDatalog / grammar.txt

The default branch has multiple heads

Full commit

/* http://railroad.my28msec.com/rr/ui  */

constant ::= [a-f] [0-9a-fA-F_]* | ["'] char ["']
variable::= [A-F_] [0-9a-fA-F_]*
simple_predicate ::= [a-fA-F_] [0-9a-fA-F_]*

predicate ::= simple_predicate | simple_predicate '.' simple_predicate

literal ::= predicate '(' (  expression (',' expression)*  )? ')'

  
function ::= predicate '[' expression (',' expression)*   ']'


expression ::= (constant 
  | variable 
  | function
  | '(' expression ')'  
  | '(' lambda-expression ')' 
  | expression ([+*/-] | '//') expression
  )

body ::= ( '~' '(' body ')' | 
           | literal 
           | '(' (variable | function) ('<' | '<=' | '==' | '~=' | '>='  | '>' | 'in' | 'not in' ) expression ')'
           ) 
         ( '&' ( '~' '(' body ')' |
           | literal 
           | '(' (variable | function) ('<' | '<=' | '==' | '~=' | '>='  | '>' | 'in' | 'not in' ) expression ')'
           ) 
         )*

head_function ::= predicate '[' (constant|variable)(',' (constant|variable))*   ']'

head ::= literal 
      | '(' head_function  '==' (variable | constant) ')'
      | '(' head_function '==' ('len' | 'sum' | 'concat' | 'min' | 'max' | 'rank' | 'running_sum' ) '(' arguments ')' ')'

fact ::= ( predicate '(' (  constant (',' constant)*  )? ')' | predicate '[' constant (',' constant )*   ']' '==' constant )

datalog_statement ::= ('+' | '-') fact
  | head '<=' body
  | '-' '(' head '<=' body ')'
  | head_function '=' expression