public PrologElement readClause() {
   reset_var_number();
   PrologElement clausa, left, right;
   boolean marseille_if = false;
   String dir_name;
   if (symbol_control == 1) {
     clausa = readElement();
     if (clausa == null) return null;
     return readRightSide(clausa, false);
   }
   if (symbol_control == 11 && root.if_atom_caption.equals(symbol)) {
     marseille_if = true;
     get_symbol();
   }
   switch (symbol_control) {
     case 22:
       get_symbol();
       if (symbol_control != 11) {
         root.message("Syntax error (directory expected).");
         return null;
       }
       dir_name = "";
       get_symbol();
       if (symbol_control != 21) {
         root.message("Syntax error (atom after dot expected).");
         return null;
       }
       get_symbol();
       left = root.atom(dir_name, symbol);
       if (left == null) {
         root.message("Unknown atom: " + symbol);
         return null;
       }
       break;
     case 11:
       left = atomC(symbol);
       if (left == null) return null;
       break;
     default:
       return null;
   }
   get_symbol();
   switch (symbol_control) {
     case 6:
       right = root.earth();
       get_symbol();
       break;
     case 1:
       right = readElement();
       if (right == null) return null;
       right = readRightSide(right, false);
       if (right == null) return null;
       get_symbol();
       break;
     default:
       right = root.earth();
       break;
   }
   clausa = root.pair(root.pair(left, right), root.earth());
   if (symbol_control == 21) return clausa;
   if (symbol_control != 11
       || (!root.if_atom_caption.equals(symbol) && !marseille_if)
       || (marseille_if && !root.and_atom_caption.equals(symbol))) return null;
   PrologElement el = clausa;
   while (symbol_control != 21) {
     left = readElement();
     if (left == null) return null;
     get_symbol();
     switch (symbol_control) {
       case 6:
         right = root.earth();
         get_symbol();
         el.setRight(root.pair(root.pair(left, right), root.earth()));
         break;
       case 1:
         right = readElement();
         if (right == null) return null;
         right = readRightSide(right, false);
         if (right == null) return null;
         get_symbol();
         el.setRight(root.pair(root.pair(left, right), root.earth()));
         break;
       default:
         if (left.isAtom()) el.setRight(root.pair(root.pair(left, root.earth()), root.earth()));
         else el.setRight(root.pair(left, root.earth()));
         break;
     }
     el = el.getRight();
     if (symbol_control != 21
         && symbol_control != 23
         && (symbol_control != 11 || !root.and_atom_caption.equals(symbol))) return null;
   }
   return clausa;
 }
 public PrologElement readRightSide(PrologElement LEFT, boolean secondary) {
   PrologElement left, right;
   get_symbol();
   if (root.separator_caption.length() > 0) {
     switch (symbol_control) {
       case 1:
         left = readElement();
         if (left == null) return null;
         left = readRightSide(left, false);
         if (left == null) return null;
         LEFT = root.pair(LEFT, left);
         get_symbol();
         break;
       case 6:
         LEFT = root.pair(LEFT, root.earth());
         get_symbol();
         break;
       default:
         break;
     }
   }
   switch (symbol_control) {
     case 52:
       if (secondary) return root.pair(LEFT, root.earth());
       root.message("Syntax error (bracket mismatch).");
       return null;
     case 2:
       if (!secondary) return root.pair(LEFT, root.earth());
       root.message("Syntax error (bracket mismatch).");
       return null;
     case 3:
       right = readElement();
       if (right == null) return null;
       if (right.isEarth()) {
         root.message("Syntax error (earth not allowed here).");
         return null;
       }
       get_symbol();
       if ((symbol_control != 2 && !secondary) || (symbol_control != 52 && secondary)) {
         root.message("Syntax error (closing bracket expected).");
         return null;
       }
       return root.pair(LEFT, right);
     default:
       break;
   }
   if (root.separator_caption.length() > 0) {
     if (symbol_control == 23) get_symbol();
     else {
       root.message("Syntax error (separator expected).");
       return null;
     }
   }
   switch (symbol_control) {
     case 11:
       left = atomC(symbol);
       if (left == null) root.message("Unknown atom: " + symbol);
       break;
     case 22:
       get_symbol();
       if (symbol_control != 11) {
         root.message("Syntax error (directory expected).");
         return null;
       }
       String dir_name = "" + symbol;
       get_symbol();
       if (symbol_control != 21) {
         root.message("Syntax error (atom after dot expected).");
         return null;
       }
       get_symbol();
       left = root.atom(dir_name, symbol);
       if (left == null) root.message("Unknown atom: " + symbol);
       break;
     case 10:
       left = root.integer(int_symbol);
       break;
     case 56:
     case 6:
       left = root.earth();
       break;
     case 5:
       left = root.slash();
       break;
     case 4:
       left = root.fail();
       break;
     case 7:
       left = root.var(get_var_number(symbol));
       break;
     case 8:
       left = root.text(symbol);
       break;
     case 18:
       left = root.Double(double_symbol);
       break;
     case 51:
       left = readElement();
       if (left == null) return null;
       right = readRightSide(left, true);
       if (right == null) return null;
       left = right;
       break;
     case 1:
       left = readElement();
       if (left == null) return null;
       left = readRightSide(left, false);
       if (left == null) return null;
       break;
     case 21:
       left = atomC(symbol);
       if (left == null) root.message("Dot atom does not exist.");
       break;
     default:
       return null;
   }
   if (left == null) return null;
   left = readRightSide(left, secondary);
   if (left == null) return null;
   return root.pair(LEFT, left);
 }