Changeset 5aeb1a9 for doc


Ignore:
Timestamp:
Jul 24, 2024, 7:11:56 PM (4 months ago)
Author:
JiadaL <j82liang@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/jiada_liang_MMath/CFAenum.tex

    ra03ed29 r5aeb1a9  
    395395
    396396
     397\section{Enumeration I/O}
     398
     399As 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.
     400However, very few programming languages provide a mechanism to read in enumerator values.
     401Even 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.
     403When the enumerator labels are packed together in the input stream, the input algorithm scans for the longest matching string.
     404For 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}
     411int 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$
     430BBBABAAAAB
     431BBB AAA AA AB B
     432
     433$\rm output$
     434BBB = 3
     435AB = 6
     436AAA = 4
     437AB = 6
     438BBB = 3
     439AAA = 4
     440AA = 5
     441AB = 6
     442B = 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
    397453\section{Planet Example}
    398454
Note: See TracChangeset for help on using the changeset viewer.