12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

144 TOKEN DEFINITION ANNOYANCE-FILTER §171<br />

171. Initialise a tokenDefinition for parsing ISO-8859 text with our chosen defaults for punctuation<br />

embedded in such tokens. Any pre-existing definitions are cleared.<br />

〈 Class implementations 11 〉 +≡<br />

void tokenDefinition ::setISO 8859defaults (unsigned int lmin , unsigned int lmax )<br />

{<br />

clear ( );<br />

setLengthLimits (lmin , lmax );<br />

for (unsigned int c = 0; c < 256; c++) {<br />

isToken [c] = (isascii (c) ∧ isdigit (c)) ∨ isISOalpha (c) ∨ (c ≡ ’−’) ∨ (c ≡ ’\’’) ∨ (c ≡ ’$’);<br />

notExclusively [c] = (isdigit (c) ∨ (c ≡ ’−’)) ? 1 : 0;<br />

}<br />

#define CI(x)static cast〈int〉 (x)<br />

notAtEnd [CI(’−’)] = notAtEnd [CI(’\’’)] = true ;<br />

#undef CI<br />

}<br />

172. Initialise a tokenDefinition for parsing US-ASCII text with our chosen defaults for punctuation<br />

embedded in such tokens. Any pre-existing definitions are cleared.<br />

〈 Class implementations 11 〉 +≡<br />

void tokenDefinition ::setUS ASCIIdefaults (unsigned int lmin , unsigned int lmax )<br />

{<br />

clear ( );<br />

setLengthLimits (lmin , lmax );<br />

for (unsigned int c = 0; c < 128; c++) {<br />

isToken [c] = isalpha (c) ∨ isdigit (c);<br />

notExclusively [c] = (isdigit (c) ∨ (c ≡ ’−’)) ? 1 : 0;<br />

}<br />

#define CI(x)static cast〈int〉 (x)<br />

isToken [CI(’_’)] = notExclusively [CI(’_’)] = true ;<br />

notAtEnd [CI(’−’)] = notAtEnd [CI(’\’’)] = true ;<br />

#undef CI<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!