Mercurial > ~dholland > hg > ag > index.cgi
view tests/agcl/ffcalc/ffcx-t.syn @ 6:607e3be6bad8
Adjust to the moving target called the C++ standard.
Apparently nowadays it's not allowed to define an explicit copy
constructor but not an assignment operator. Consequently, defining the
explicit copy constructor in terms of the implicit/automatic
assignment operator for general convenience no longer works.
Add assignment operators.
Caution: not tested with the IBM compiler, but there's no particular
reason it shouldn't work.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:46:22 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
{/* FOUR FUNCTION CALCULATOR: FFCALCX.SYN */} // -- CONFIGURATION SECTION ---------------------------- [ default token type = double disregard white space lexeme { real} traditional engine left { '+', '-'} left { '*', '/'} right {unary minus} ] // -- FOUR FUNCTION CALCULATOR ------------------------- (void) calculator $ -> [calculation?, '\n']..., eof (void) calculation -> expression:x =printf("%g\n",x); -> name:n, '=', expression:x ={ printf("%c = %g\n",n+'A',value[n]=x);} -> error expression -> name:n = value[n]; -> real -> '(', expression:x, ')' = x; -> expression:x, '+', expression:t = x+t; -> expression:x, '-', expression:t = x-t; -> expression:t, '*', expression:f = t*f; -> expression:t, '/', expression:f = t/f; -> unary minus, expression:f = -f; // -- LEXICAL UNITS ------------------------------------ digit = '0-9' eof = -1 unary minus = '-' (void) white space -> ' ' + '\t' + '\r' + '\f' + '\v' -> "/*", ~eof?..., "*/" (int) name -> 'a-z' + 'A-Z':c = c-'A'; real -> integer part:i, '.', fraction part:f = i+f; -> integer part, '.'? -> '.', fraction part:f = f; integer part -> digit:d = d-'0'; -> integer part:x, digit:d = 10*x + d-'0'; fraction part -> digit:d =(d-'0')/10.; -> digit:d, fraction part:f =(d-'0' + f)/10.; { /* -- EMBEDDED C ---------------------------------- */ double value[64]; /* registers */ int main(void) { ffcalcx(); return 0; } } /* -- END OF EMBEDDED C ----------------------------*/