Syntax Commentary 3

+  fileState.frag = initFrag ? initFrag : sourceLocManager->createFileFragment(stringc << "#" << cnt++);
+      static_cast(objArrayStack)->push(static_cast(obj));
+  travObjList0(fragments, fragments, SourceLocManager::FileFragment, FOREACH_OBJARRAYSTACK_NC, ObjArrayStack);
+//     cerr << "frag " << frag << " in " << frag->fileInfo->name.c_str() << ": range " << frag->charOffset << " - " << (frag->charOffset + frag->numChars) << " P " << frag->isBeingProcessed() << endl;

These lines and others are too long; please stay within 72 columns
[I hope we do this :-) ].


+    if (pp_expand_ctx)
+      ppUpdateTokenInformation(*pp_expand_ctx, this, frag());

+  if (handleEof())
+    yyterminate();

+        if (!frag->serializationOnly_isComplete())
+          manager.xmlUserFatalError("missing attributes to FileFragment tag");

+        if (!fileInfo->serializationOnly_isComplete())
+          manager.xmlUserFatalError("missing attributes to FileInfo tag");

+    if (frag->isBeingProcessed())
+      printXml_bool(beingProcessed, true);

Please never put a naked 'then' clause on its own line.  Scott wants
the curlies in there.

 if (handleEof()) {
   yyterminate();
 }

+  for (; line < lineOffsets.length(); line++)
+    frag->updateLineInfo(lineOffsets[line] - lineOffsets[line-1]);

Same with 'for'; use curlies here.

   for (; line < lineOffsets.length(); line++) {
     frag->updateLineInfo(lineOffsets[line] - lineOffsets[line-1]);
   }

Though sometimes Scott doesn't seem to mind if it is very simple to
put them on the same line thus:

 if (handleEof()) yyterminate();


+    if (frag->charOffset <= charOffset && (frag->isBeingProcessed()
+        || charOffset < frag->charOffset + frag->numChars))

The indentation is so in conflict with the parenthetical nesting that
it is very hard to read.  This is much better:

   if (frag->charOffset <= charOffset &&
       (frag->isBeingProcessed() ||
        charOffset < frag->charOffset + frag->numChars))

+            || col <= frag->lastNumCols + (
+                line == frag->lineOffset + 1 ? frag->firstColOfs : 0)

Same with this one as well.  Try it this way

     || col <= frag->lastNumCols +
               (line == frag->lineOffset + 1
                ? frag->firstColOfs
                : 0)

Same with this one:

    // true if this file contains the specified location
    bool hasLoc(SourceLoc sl) const
-      { return toInt(startLoc) <= sl &&
-                                  sl <= toInt(startLoc) + numChars; }
+      { return toInt(startLoc) <= sl && (beingProcessed
+                                  || sl < toInt(startLoc) + numChars); }

The way Scott had it set up the two occurrences of 'sl' lined up
vertically for readability:

-      { return toInt(startLoc) <= sl &&
-                                  sl <= toInt(startLoc) + numChars; }

This is now really hard to read:

+      { return toInt(startLoc) <= sl && (beingProcessed
+                                  || sl < toInt(startLoc) + numChars); }

Split at the '&&' and line up 'sl' again.  Now you can see the two
halves of the predicate opposing one another.

{ return toInt(startLoc) <= sl &&
        (beingProcessed || sl < toInt(startLoc) + numChars); }


+  if (0!=strcmp(fname, expFname) ||
+      line != expLine ||
+      col != expCol) {
+    xfailure(stringc << "expected " << expFname << ":" << expLine << ":" << expCol
+        << ", but got " << fname << ":" << line << ":" << col);
+      }

The last curly is indented two stops (four spaces) too far.

+  SourceLocManager::FileFragment *pfrag4 =
+  frag = mgr.createFileFragment(fname, line, 7 + 15);

Please don't combine assignments like this; just break it out into
two.  Additionally, the indentation is confusing.

+    int line = lineidx + 1, col = offset - lineOffsets[lineidx] + 1;

Please just put separate declarators on their own lines:

   int line = lineidx + 1;
   int col = offset - lineOffsets[lineidx] + 1;


+  if (!target)
+    xfailure("Unknown source location. Has the file been fully parsed?");

Is this something that the user can make happen?  If so, it shouldn't
be an xfailure() (which is something that should not be able to happen
at all; basically an assertion failure) but instead should be a user
error.  If the user could make this happen, use xfatal() from
smbase/exc.h.
 #define xfatal(msg) throw_XFatal(stringc << msg)

-    printf("expected %s:%d:%d, but got %s:%d:%d\n",
-           expFname, expLine, expCol,
-           fname, line, col);
-    exit(2);

In general we are trying to move to throwing exceptions instead of
using exit().


{
  char const *fname;
  int line, col;
+  if (loc==10390)
+    cerr << __FUNCTION__ << ": loc("<>> print (1 << (4*8-1)) - 1
   2147483647


    // invariant: lineLengthSum() + numLines-1 == numChars
+    // ls: still true in new impl?

These kinds of comments scare me; you are no longer sure of some of
the off-by-one-checking invariants?  Do they only sometimes pass?