
! This is a small include file for Inform stories to check for "Missing Comma Syndrome" (MCS).
! Because the Inform compiler recognises property names as values, it does not generate
! errors if a comma is missed between property definitions.  This can result in objects
! being unreferrable by the player, or in nonsense nouns referring to unexpected objects, as
! well as all kinds of other hangs and unexpected behaviour.

! To use, simply include the file, and then with debug mode on, type the debug verb ("debugmcs")
! It's not foolproof, and may generate some false positives with Library objects,
! but is intended as a useful additional check.  If the verb gives a blank response, you're probably fine.
! Cedric Knight Apr 2001

#ifdef DEBUG;
[ CheckRoutines o p  i g;
  if (o==selfobj or thedark) rfalse; ! funny cases in parserm
  if (o provides p) {
     g=0;
     for (i=0: i*2<o.#p: i++) {
               if (metaclass(o.&p-->i)~=Routine && o.&p-->i~=NULL) g=1;
               }
     if (g) {print "Likely problem with "; @print_obj o; print ".",(property) p,"^";}
     }
  ];

[ CheckSR o p;
  if (o provides p) {
     if (o.#p>2 || metaclass(o.&p-->0)~=String) CheckRoutines(o, p);
     }
  ];

[ DebugMCSSub o i f;
  objectloop(o) {
     CheckRoutines(o, before); CheckRoutines(o, after);
     CheckSR(o, article, "article"); CheckSR(o, cant_go);
     CheckRoutines(o, daemon); CheckRoutines(o, describe);
     CheckSR(o, description); CheckSR(o, each_turn); CheckSR(o, grammar); CheckSR(o, initial);
     CheckSR(o, inside_description);
     CheckRoutines(o, invent); CheckRoutines(o, life); CheckRoutines(o, orders);
     CheckRoutines(o, parse_name); CheckSR(o, plural);
     CheckRoutines(o, react_after); CheckRoutines(o, react_before);
     CheckSR(o, short_name); CheckRoutines(o, time_out);
     CheckSR(o, when_open); CheckSR(o, when_closed); CheckSR(o, when_on); CheckSR(o, when_off);
     f=0;
     for (i=0: i*2<o.#name: i++)
       if (o.&name-->i < 0-->4 || o.&name-->i > 0-->2) f=1;
     if (f) print "Name of ",(the) o, " contains non-dictionary words.^";
     }

  f=0;
  objectloop(o) {
     if (~~(o provides name or parse_name || (metaclass(o)==Class) ||
           o==compass or out_obj or in_obj or TheDark or LibraryMessages or InformParser or InformLibrary))
             { if (~~f) print "^No names for: "; else print ", "; f++;
              @print_obj o; print "(",o,")";}
     }
  if (f) print ".^";
  ];
Verb meta "debugmcs" * ->DebugMCS;
#endif;

