Fix formatting of escaping table.

The visual formatting of this table got corrupted when we
clang-formatted everything. Turn clang formatting off for this table to
preserve the structure.

Clarify some comments in the parser.

Change-Id: I93b00ff12789eed97f61923c704a5ecaeea4de0f
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/4640
Reviewed-by: Brett Wilson <brettw@google.com>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Brett Wilson <brettw@google.com>
diff --git a/tools/gn/escape.cc b/tools/gn/escape.cc
index f2b1324..aa6b967 100644
--- a/tools/gn/escape.cc
+++ b/tools/gn/escape.cc
@@ -22,22 +22,24 @@
 #endif
 
 // A "1" in this lookup table means that char is valid in the Posix shell.
+// clang-format off
 const char kShellValid[0x80] = {
-    // 00-1f: all are invalid
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0,
-    // ' ' !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
+// 00-1f: all are invalid
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+// ' ' !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
-    //  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
+//  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0,
-    //  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
+//  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    //  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
+//  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
-    //  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
+//  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    //  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~
+//  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
+// clang-format on
 
 // Uses the stack if the space needed is small and the heap otherwise.
 class StackOrHeapBuffer {
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index e10ed41..0065afd 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -221,6 +221,12 @@
   always unequal by definition.
 )*";
 
+// Precedence constants.
+//
+// Currently all operators are left-associative so this list is sequential. To
+// implement a right-assocative operators in a Pratt parser we would leave gaps
+// in between the constants, and right-associative operators get a precedence
+// of "<left-associated-precedence> - 1".
 enum Precedence {
   PRECEDENCE_ASSIGNMENT = 1,  // Lowest precedence.
   PRECEDENCE_OR = 2,
@@ -241,9 +247,8 @@
 // seen as either a prefix or infix operator, and if it's infix, what its
 // precedence is.
 //
-// Refs:
-// - http://javascript.crockford.com/tdop/tdop.html
-// -
+// References:
+// http://javascript.crockford.com/tdop/tdop.html
 // http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
 
 // Indexed by Token::Type.
diff --git a/tools/gn/parser.h b/tools/gn/parser.h
index 5ecbd9d..a537170 100644
--- a/tools/gn/parser.h
+++ b/tools/gn/parser.h
@@ -144,6 +144,8 @@
 struct ParserHelper {
   PrefixFunc prefix;
   InfixFunc infix;
+
+  // Used only for infix operators.
   int precedence;
 };