acme, sam: fix regexp code for bigger Runemax

R=r
http://codereview.appspot.com/1765042
diff --git a/src/cmd/acme/regx.c b/src/cmd/acme/regx.c
index a58437b..9ad07d3 100644
--- a/src/cmd/acme/regx.c
+++ b/src/cmd/acme/regx.c
@@ -20,7 +20,7 @@
 typedef struct Inst Inst;
 struct Inst
 {
-	uint	type;	/* < 0x10000 ==> literal, otherwise action */
+	uint	type;	/* < OPERATOR ==> literal, otherwise action */
 	union {
 		int sid;
 		int subid;
@@ -58,28 +58,30 @@
 /*
  * Actions and Tokens
  *
- *	0x100xx are operators, value == precedence
- *	0x200xx are tokens, i.e. operands for operators
+ *	0x10000xx are operators, value == precedence
+ *	0x20000xx are tokens, i.e. operands for operators
  */
-#define	OPERATOR	0x10000	/* Bitmask of all operators */
-#define	START		0x10000	/* Start, used for marker on stack */
-#define	RBRA		0x10001	/* Right bracket, ) */
-#define	LBRA		0x10002	/* Left bracket, ( */
-#define	OR		0x10003	/* Alternation, | */
-#define	CAT		0x10004	/* Concatentation, implicit operator */
-#define	STAR		0x10005	/* Closure, * */
-#define	PLUS		0x10006	/* a+ == aa* */
-#define	QUEST		0x10007	/* a? == a|nothing, i.e. 0 or 1 a's */
-#define	ANY		0x20000	/* Any character but newline, . */
-#define	NOP		0x20001	/* No operation, internal use only */
-#define	BOL		0x20002	/* Beginning of line, ^ */
-#define	EOL		0x20003	/* End of line, $ */
-#define	CCLASS		0x20004	/* Character class, [] */
-#define	NCCLASS		0x20005	/* Negated character class, [^] */
-#define	END		0x20077	/* Terminate: match found */
+#define	OPERATOR	0x1000000	/* Bit set in all operators */
+#define	START		(OPERATOR+0)	/* Start, used for marker on stack */
+#define	RBRA		(OPERATOR+1)	/* Right bracket, ) */
+#define	LBRA		(OPERATOR+2)	/* Left bracket, ( */
+#define	OR		(OPERATOR+3)	/* Alternation, | */
+#define	CAT		(OPERATOR+4)	/* Concatentation, implicit operator */
+#define	STAR		(OPERATOR+5)	/* Closure, * */
+#define	PLUS		(OPERATOR+6)	/* a+ == aa* */
+#define	QUEST		(OPERATOR+7)	/* a? == a|nothing, i.e. 0 or 1 a's */
+#define	ANY		0x2000000	/* Any character but newline, . */
+#define	NOP		(ANY+1)	/* No operation, internal use only */
+#define	BOL		(ANY+2)	/* Beginning of line, ^ */
+#define	EOL		(ANY+3)	/* End of line, $ */
+#define	CCLASS		(ANY+4)	/* Character class, [] */
+#define	NCCLASS		(ANY+5)	/* Negated character class, [^] */
+#define	END		(ANY+0x77)	/* Terminate: match found */
 
-#define	ISATOR		0x10000
-#define	ISAND		0x20000
+#define	ISATOR		OPERATOR
+#define	ISAND		ANY
+
+#define	QUOTED	0x4000000	/* Bit set for \-ed lex characters */
 
 /*
  * Parser Information
@@ -453,7 +455,7 @@
 			exprp++;
 			return '\n';
 		}
-		return *exprp++|0x10000;
+		return *exprp++|QUOTED;
 	}
 	return *exprp++;
 }
@@ -493,7 +495,7 @@
 			classp[n+2] = c2;
 			n += 3;
 		}else
-			classp[n++] = c1;
+			classp[n++] = c1 & ~QUOTED;
 	}
 	classp[n] = 0;
 	if(nclass == Nclass){
diff --git a/src/cmd/sam/regexp.c b/src/cmd/sam/regexp.c
index 3234d73..2e369fe 100644
--- a/src/cmd/sam/regexp.c
+++ b/src/cmd/sam/regexp.c
@@ -9,7 +9,7 @@
 
 struct Inst
 {
-	long	type;	/* < 0x10000 ==> literal, otherwise action */
+	long	type;	/* < OPERATOR ==> literal, otherwise action */
 	union {
 		int rsid;
 		int rsubid;
@@ -53,28 +53,30 @@
 /*
  * Actions and Tokens
  *
- *	0x100xx are operators, value == precedence
- *	0x200xx are tokens, i.e. operands for operators
+ *	0x10000xx are operators, value == precedence
+ *	0x20000xx are tokens, i.e. operands for operators
  */
-#define	OPERATOR	0x10000	/* Bitmask of all operators */
-#define	START		0x10000	/* Start, used for marker on stack */
-#define	RBRA		0x10001	/* Right bracket, ) */
-#define	LBRA		0x10002	/* Left bracket, ( */
-#define	OR		0x10003	/* Alternation, | */
-#define	CAT		0x10004	/* Concatentation, implicit operator */
-#define	STAR		0x10005	/* Closure, * */
-#define	PLUS		0x10006	/* a+ == aa* */
-#define	QUEST		0x10007	/* a? == a|nothing, i.e. 0 or 1 a's */
-#define	ANY		0x20000	/* Any character but newline, . */
-#define	NOP		0x20001	/* No operation, internal use only */
-#define	BOL		0x20002	/* Beginning of line, ^ */
-#define	EOL		0x20003	/* End of line, $ */
-#define	CCLASS		0x20004	/* Character class, [] */
-#define	NCCLASS		0x20005	/* Negated character class, [^] */
-#define	END		0x20077	/* Terminate: match found */
+#define	OPERATOR	0x1000000	/* Bit set in all operators */
+#define	START		(OPERATOR+0)	/* Start, used for marker on stack */
+#define	RBRA		(OPERATOR+1)	/* Right bracket, ) */
+#define	LBRA		(OPERATOR+2)	/* Left bracket, ( */
+#define	OR		(OPERATOR+3)	/* Alternation, | */
+#define	CAT		(OPERATOR+4)	/* Concatentation, implicit operator */
+#define	STAR		(OPERATOR+5)	/* Closure, * */
+#define	PLUS		(OPERATOR+6)	/* a+ == aa* */
+#define	QUEST		(OPERATOR+7)	/* a? == a|nothing, i.e. 0 or 1 a's */
+#define	ANY		0x2000000	/* Any character but newline, . */
+#define	NOP		(ANY+1)	/* No operation, internal use only */
+#define	BOL		(ANY+2)	/* Beginning of line, ^ */
+#define	EOL		(ANY+3)	/* End of line, $ */
+#define	CCLASS		(ANY+4)	/* Character class, [] */
+#define	NCCLASS		(ANY+5)	/* Negated character class, [^] */
+#define	END		(ANY+0x77)	/* Terminate: match found */
 
-#define	ISATOR		0x10000
-#define	ISAND		0x20000
+#define	ISATOR		OPERATOR
+#define	ISAND		ANY
+
+#define	QUOTED	0x4000000	/* Bit set for \-ed lex characters */
 
 /*
  * Parser Information
@@ -459,7 +461,7 @@
 			exprp++;
 			return '\n';
 		}
-		return *exprp++|0x10000;
+		return *exprp++|QUOTED;
 	}
 	return *exprp++;
 }
@@ -499,7 +501,7 @@
 			classp[n+2] = c2;
 			n += 3;
 		}else
-			classp[n++] = c1;
+			classp[n++] = c1 & ~QUOTED;
 	}
 	classp[n] = 0;
 	if(nclass == Nclass){