Mercurial > projects > dil
comparison trunk/src/dil/doc/Parser.d @ 769:5e3ef1b2011c
Added and improved documentation.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 17 Feb 2008 02:21:55 +0100 |
parents | d84349a60f5c |
children | 3b34f6a95a27 |
comparison
equal
deleted
inserted
replaced
768:d84349a60f5c | 769:5e3ef1b2011c |
---|---|
6 | 6 |
7 import dil.lexer.Funcs; | 7 import dil.lexer.Funcs; |
8 import dil.Unicode; | 8 import dil.Unicode; |
9 import common; | 9 import common; |
10 | 10 |
11 /// A pair of strings. | |
11 class IdentValue | 12 class IdentValue |
12 { | 13 { |
13 string ident; | 14 string ident; |
14 string value; | 15 string value; |
15 this (string ident, string value) | 16 this (string ident, string value) |
21 | 22 |
22 /// Parses text of the form: | 23 /// Parses text of the form: |
23 /// <pre> | 24 /// <pre> |
24 /// ident = value | 25 /// ident = value |
25 /// ident2 = value2 | 26 /// ident2 = value2 |
26 //// more text | 27 /// more text |
27 /// </pre> | 28 /// </pre> |
28 struct IdentValueParser | 29 struct IdentValueParser |
29 { | 30 { |
30 char* p; | 31 char* p; /// Current pointer. |
31 char* textEnd; | 32 char* textEnd; |
32 | 33 |
33 IdentValue[] parse(string text) | 34 IdentValue[] parse(string text) |
34 { | 35 { |
35 if (!text.length) | 36 if (!text.length) |
71 {} | 72 {} |
72 end++; | 73 end++; |
73 return makeString(begin, end); | 74 return makeString(begin, end); |
74 } | 75 } |
75 | 76 |
77 /// Finds the next "Identifier =". | |
78 /// Params: | |
79 /// ident = set to Identifier. | |
80 /// bodyBegin = set to the beginning of the text body (whitespace skipped.) | |
81 /// Returns: true if found. | |
76 bool findNextIdent(ref string ident, ref char* bodyBegin) | 82 bool findNextIdent(ref string ident, ref char* bodyBegin) |
77 { | 83 { |
78 while (p < textEnd) | 84 while (p < textEnd) |
79 { | 85 { |
80 skipWhitespace(); | 86 skipWhitespace(); |
117 } | 123 } |
118 } | 124 } |
119 | 125 |
120 char[] makeString(char* begin, char* end) | 126 char[] makeString(char* begin, char* end) |
121 { | 127 { |
122 assert(begin <= end); | 128 assert(begin && end && begin <= end); |
123 return begin[0 .. end - begin]; | 129 return begin[0 .. end - begin]; |
124 } | 130 } |