- Timestamp:
- Jul 24, 2024, 7:11:56 PM (4 months ago)
- Branches:
- master
- Children:
- 38e20a80
- Parents:
- a03ed29 (diff), 878b1385 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/CFAenum.tex
ra03ed29 r5aeb1a9 395 395 396 396 397 \section{Enumeration I/O} 398 399 As seen in multiple examples, enumerations can be printed and the default property printed is the enumerator's label, which is similar in other programming languages. 400 However, very few programming languages provide a mechanism to read in enumerator values. 401 Even the @boolean@ type in many languages does not have a mechanism for input using the enumerators @true@ or @false@. 402 \VRef[Figure]{f:EnumerationI/O} show \CFA enumeration input based on the enumerator labels. 403 When the enumerator labels are packed together in the input stream, the input algorithm scans for the longest matching string. 404 For basic types in \CFA, the constants use to initialize a variable in a program are available to initialize a variable using input, where strings constants can be quoted or unquoted. 405 406 \begin{figure} 407 \begin{cquote} 408 \setlength{\tabcolsep}{15pt} 409 \begin{tabular}{@{}ll@{}} 410 \begin{cfa} 411 int main() { 412 enum(int ) E { BBB = 3, AAA, AA, AB, B }; 413 E e; 414 415 for () { 416 try { 417 @sin | e@; 418 } catch( missing_data * ) { 419 sout | "missing data"; 420 continue; // try again 421 } 422 if ( eof( sin ) ) break; 423 sout | e | "= " | value( e ); 424 } 425 } 426 \end{cfa} 427 & 428 \begin{cfa} 429 $\rm input$ 430 BBBABAAAAB 431 BBB AAA AA AB B 432 433 $\rm output$ 434 BBB = 3 435 AB = 6 436 AAA = 4 437 AB = 6 438 BBB = 3 439 AAA = 4 440 AA = 5 441 AB = 6 442 B = 7 443 444 \end{cfa} 445 \end{tabular} 446 \end{cquote} 447 \caption{Enumeration I/O} 448 \label{f:EnumerationI/O} 449 \end{figure} 450 451 452 397 453 \section{Planet Example} 398 454
Note: See TracChangeset
for help on using the changeset viewer.