file : ('file', parent,
            ((fc_rule), (fc_extras_line)),
            ((bc_rule), (bc_extras_line), (plan_extras_line)))

parent : None
       | ('parent', extending_symbol, (without_symbols))

fc_rule: ('fc_rule', name, (fc_premise), (assertion))

fc_premise : ('fc_premise', kb_name, entity_name, (pattern),
              starting_lineno, ending_lineno)
           | ('fc_first', (fc_premise), starting_lineno)
           | ('fc_forall', (fc_premise), (fc_premise)_opt,
              starting_lineno, ending_lineno)
           | ('fc_notany', (fc_premise), starting_lineno)
           | python_premise

assertion : ('assert', kb_name, entity_name, (pattern),
             starting_lineno, ending_lineno)
          | ('python_assertion', python_code, starting_lineno, ending_lineno)

python_premise : ('python_eq', pattern, python_code,
                  starting_lineno, ending_lineno)
               | ('python_in', pattern, python_code,
                  starting_lineno, ending_lineno)
               | ('python_check', python_code, starting_lineno, ending_lineno)
               | ('python_block', python_code, starting_lineno, ending_lineno)

counting : ('counting', quoted_pattern_var_name,
                        <from>python_code_opt, <by>python_code_opt)

bc_rule: ('bc_rule', name, goal, (bc_premise), (python_code),
                     (plan_vars_needed))

goal : ('goal', <entity_name>IDENTIFIER, (pattern), <taking>(python_line),
        starting_lineno, ending_lineno)

bc_premise : ('bc_premise', <required>_bool,
                            <kb>name_opt, <entity>name, (pattern),
                            plan_spec_opt, starting_lineno, ending_lineno)
           | ('bc_first', <required>_bool, (bc_premise), starting_lineno)
           | ('bc_forall', (bc_premise), (bc_premise)_opt,
              starting_lineno, ending_lineno)
           | ('bc_notany', (bc_premise), starting_lineno)
           | python_premise

name : quoted_STRING
     | "context.lookup_data('PATTERN_VAR_NAME')"

plan_spec : ('as', <unquoted>pattern_var_name)
          | ('plan_spec', <step>NUMBER_opt, <unquoted>plan_var_name,
                          (python_line), (<unquoted>plan_var_needed),
                          lineno, lexpos)

pattern : variable
        | "pattern_literal(<data>)"
        | "pattern_tuple((<pattern>))"
        | "pattern_tuple((<pattern>), <variable>)"

variable: "contexts.variable('<var_name>')"
        | "contexts.anonymous()"

data : None | True | False | NUMBER | quoted_STRING | TUPLE

python_code : ((python_line), (<unquoted>plan_var_needed), lineno, lexpos)

