Mercurial > ~dholland > hg > ag > index.cgi
view tests/agcl/ffcalc/ffc-wa.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: FFCALC.SYN */ #include "Number.h" int Number::nCreated = 0; char Number::buf[100]; } // -- CONFIGURATION SECTION ---------------------------- [ disregard white space lexeme { real} parser file name = "#.cpp" wrapper {Number} line numbers allow macros = OFF auto resynch error frame ] // -- FOUR FUNCTION CALCULATOR ------------------------- calculator $ -> [calculation?, '\n']..., eof calculation -> expression:x =printf("%s\n", x.asString()),fflush(stdout); -> name:n, '=', expression:x ={ printf("%c = %s\n",n+'A', fflush(stdout), (value[n]=x).asString());} (Number) expression -> term -> expression:x, '+', term:t = { printf("x = %s\n", x.asString()); printf("t = %s\n", t.asString()); fflush(stdout); x+=t; printf("x = %s\n", x.asString()); fflush(stdout); return x; } -> expression:x, '-', term:t = x-=t; (Number) term -> factor -> term:t, '*', factor:f = t*=f; -> term:t, '/', factor:f = t/=f; (Number) factor -> name:n = value[n]; -> real:x =Number(x); -> '(', expression:x, ')' = x; -> '-', factor:f = -f; // -- LEXICAL UNITS ------------------------------------ digit = '0-9' eof = -1 white space -> ' ' + '\t' + '\r' + '\f' + '\v' -> "/*", ~eof?..., "*/" (int) name -> 'a-z' + 'A-Z':c = c-'A'; (double) real -> integer part:i, '.', fraction part:f = i+f; -> integer part, '.'? -> '.', fraction part:f = f; (double) integer part -> digit:d = d-'0'; -> integer part:x, digit:d = 10*x + d-'0'; (double) fraction part -> digit:d =(d-'0')/10.; -> digit:d, fraction part:f =(d-'0' + f)/10.; { /* -- EMBEDDED C ---------------------------------- */ #define SYNTAX_ERROR printf("%s, line %d, column %d\n", \ (PCB).error_message, (PCB).line, (PCB).column), fflush(stdout) Number value[64]; /* registers */ int main(void) { ffcalcr(); return 0; } } /* -- END OF EMBEDDED C ----------------------------*/