1.1 --- a/tools/incparser/IncParser.cs Sat Apr 19 10:35:24 2008 +0000
1.2 +++ b/tools/incparser/IncParser.cs Mon Apr 21 21:41:38 2008 +0000
1.3 @@ -133,7 +133,7 @@
1.4 Initialize();
1.5 }
1.6
1.7 - public void Parse(ParseWriter w)
1.8 + public void Parse(ParseWriter w)
1.9 {
1.10 w.BeginSection(System.IO.Path.GetFileName(FileName));
1.11 LexToken tok = LexToken.TOKEN_NONE;
1.12 @@ -198,7 +198,12 @@
1.13 }
1.14 default:
1.15 {
1.16 - throw new ParseException("Unrecognized token: " + tok);
1.17 + if (_LexString == "static" || _LexString == "new")
1.18 + {
1.19 + PARSE_Public(w);
1.20 + break;
1.21 + }
1.22 + throw new ParseException("Unrecognized token: " + tok + " " + _LexString);
1.23 }
1.24 }
1.25 }
1.26 @@ -207,16 +212,29 @@
1.27
1.28 private void PARSE_Public(ParseWriter w)
1.29 {
1.30 + MatchToken(LexToken.TOKEN_CONST);
1.31 +
1.32 /* Eat up an optional tag */
1.33 MatchToken(LexToken.TOKEN_LABEL);
1.34 -
1.35 +
1.36 /* Eat up a name */
1.37 NeedToken(LexToken.TOKEN_SYMBOL);
1.38
1.39 + while (MatchChar('['))
1.40 + {
1.41 + DiscardUntilChar(']');
1.42 + NeedChar(']');
1.43 + }
1.44 +
1.45 if (MatchChar('='))
1.46 {
1.47 ignore_block();
1.48 }
1.49 + else if (MatchChar('(') && MatchChar(')'))
1.50 + {
1.51 + ignore_block();
1.52 + return;
1.53 + }
1.54
1.55 NeedChar(';');
1.56 }
1.57 @@ -225,6 +243,7 @@
1.58 {
1.59 /* For now, we completely ignore these (they're not written to the output) */
1.60 NeedToken(LexToken.TOKEN_SYMBOL);
1.61 + w.structList.Add(LexString);
1.62 NeedChar('{');
1.63
1.64 bool need_closebrace = true;
1.65 @@ -294,6 +313,7 @@
1.66 /* Get the functag name */
1.67 NeedToken(LexToken.TOKEN_SYMBOL);
1.68 w.WritePair("name", LexString);
1.69 + w.funcenumList.Add(LexString);
1.70
1.71 NeedChar('{');
1.72
1.73 @@ -359,6 +379,7 @@
1.74 /* Get the functag name */
1.75 NeedToken(LexToken.TOKEN_SYMBOL);
1.76 w.WritePair("name", LexString);
1.77 + w.functagList.Add(LexString);
1.78
1.79 if (MatchToken(LexToken.TOKEN_LABEL))
1.80 {
1.81 @@ -422,14 +443,17 @@
1.82 if (tok == LexToken.TOKEN_FORWARD)
1.83 {
1.84 w.BeginSection("forward");
1.85 + w.forwardList.Add(name);
1.86 }
1.87 else if (tok == LexToken.TOKEN_NATIVE)
1.88 {
1.89 w.BeginSection("native");
1.90 + w.nativeList.Add(name);
1.91 }
1.92 else if (tok == LexToken.TOKEN_STOCK)
1.93 {
1.94 w.BeginSection("stock");
1.95 + w.stockList.Add(name);
1.96 }
1.97
1.98 w.WritePair("name", name);
1.99 @@ -571,9 +595,17 @@
1.100 w.WritePair("name", name);
1.101 w.BeginSection("properties");
1.102
1.103 + w.enumList.Add(name);
1.104 +
1.105 NeedChar('{');
1.106 bool more_entries = true;
1.107 bool need_closebrace = true;
1.108 +
1.109 + if (MatchToken(LexToken.TOKEN_DOCBLOCK))
1.110 + {
1.111 + w.WritePair("doc", LexString);
1.112 + }
1.113 +
1.114 do
1.115 {
1.116 if (MatchChar('}'))
1.117 @@ -583,12 +615,14 @@
1.118 }
1.119 NeedToken(LexToken.TOKEN_SYMBOL);
1.120 name = LexString;
1.121 +
1.122 if (MatchChar('='))
1.123 {
1.124 - DiscardUntilCharOrComment(',', true);
1.125 + DiscardUntilCharOrComment(",\n}", true);
1.126 }
1.127 more_entries = MatchChar(',');
1.128 w.WritePair("name", name);
1.129 + w.enumTypeList.Add(name);
1.130 if (MatchToken(LexToken.TOKEN_DOCBLOCK))
1.131 {
1.132 w.WritePair("doc", LexString);
1.133 @@ -637,6 +671,8 @@
1.134 }
1.135
1.136 /* Write */
1.137 + w.defineList.Add(name);
1.138 +
1.139 w.BeginSection("define");
1.140 w.WritePair("name", name);
1.141 w.WritePair("linetext", value);
1.142 @@ -721,6 +757,37 @@
1.143 }
1.144 }
1.145
1.146 + /**
1.147 + * Discards all data up to a certain character, ignoring
1.148 + * the contents, unless specified to stop at a doc block comment.
1.149 + */
1.150 + private void DiscardUntilCharOrComment(string s, bool stop_at_comment)
1.151 + {
1.152 + for (int i = 0; i < Contents.Length; i++)
1.153 + {
1.154 + if (Contents[i] == '\n')
1.155 + {
1.156 + LineNo++;
1.157 + }
1.158 + else if (s.Contains(Contents[i].ToString()))
1.159 + {
1.160 + if (i > 0)
1.161 + {
1.162 + Contents.Remove(0, i);
1.163 + }
1.164 + return;
1.165 + }
1.166 + else if (stop_at_comment && CheckString(i, "/**"))
1.167 + {
1.168 + if (i > 0)
1.169 + {
1.170 + Contents.Remove(0, i);
1.171 + }
1.172 + return;
1.173 + }
1.174 + }
1.175 + }
1.176 +
1.177 /**
1.178 * Finds the end of an expression
1.179 */
1.180 @@ -938,7 +1005,7 @@
1.181 bool is_doc = false;
1.182 bool is_newline = true;
1.183
1.184 - for (int i=0; i<Contents.Length-1; i++)
1.185 + for (int i=0; i<Contents.Length; i++)
1.186 {
1.187 if (Contents[i] == '\n')
1.188 {
1.189 @@ -953,6 +1020,7 @@
1.190 in_comment = true;
1.191 is_ml = false;
1.192 is_doc = false;
1.193 + is_newline = false;
1.194 } else if (Contents[i+1] == '*') {
1.195 /* Detect whether this is a doc comment or not */
1.196 if (Contents.Length - i >= 3