📄 femparser.cpp
字号:
res = terme (); break; case op_minus: nextsym (); l2 = terme (); plante (&res, op_minus, 0.F, 0, NULL, pt, NULL, l2, NULL, NULL); break; default: res = terme (); } while ((cursym == op_plus) || (cursym == op_minus)) { Symbol thesym = cursym; nextsym (); l2 = terme (); plante (&res, thesym, 0.F, 0, NULL, pt, res, l2, NULL, NULL); } return res;}noeudPtr femParser::exprcomp (){ noeudPtr l2, res = exprarith (); while ((cursym >= lt) && (cursym <= neq)) { Symbol thesym = cursym; nextsym (); l2 = exprarith (); plante (&res, thesym, 0.F, 0, NULL, pt, res, l2, NULL, NULL); } return res;}noeudPtr femParser::expr (){ noeudPtr l2, res = exprcomp (); while ((cursym == et) || (cursym == ou)) { Symbol thesym = cursym; nextsym (); l2 = exprcomp (); plante (&res, thesym, 0.F, 0, NULL, pt, res, l2, NULL, NULL); } return res;}noeudPtr femParser::fctfileproc (){ char *s = NULL; noeudPtr res = NULL; noeudPtr l1 = NULL; float thecst=0.F; char *thechaine = NULL; nextsym (); match (lpar); thechaine = curchaine; match (chaine); while (cursym == comma) { nextsym (); switch (cursym) { case oldvar: case newvar: case fdecl: break; default: sprintf (errbuf, "line %d: variable declaration expected", numligne); erreur (errbuf); } nextsym (); } match (rpar); s = readprog (thechaine); //thecst = readprog (thechaine, &s); CP/* if (thecst <= 0) { l1 = NULL; if (thecst == -1) sprintf (errbuf, "cant find file"); else if (OPTION) { sprintf (errbuf, "file not found"); erreur (errbuf); } } else {*/ programme *tmpprog = new programme; tmpprog->thestring = thestring; tmpprog->curchar = curchar; tmpprog->sym = cursym; tmpprog->numligne = numligne; tmpprog->pere = curprog; curprog = tmpprog; curchar = thestring = new char[strlen(s)]; numligne = 0; strcpy (thestring, s); nextsym (); l1 = instruction (); delete [] thestring; thestring = NULL; thestring = curprog->thestring; curchar = curprog->curchar; cursym = curprog->sym; numligne = curprog->numligne; tmpprog = curprog->pere; delete [] thestring; thestring = NULL; delete curprog;curprog = NULL; curprog = tmpprog; /*}*/ delete [] s; plante (&res, fctfile, thecst, 0, NULL, pt, l1, NULL, NULL, NULL); return res;}noeudPtr femParser::symb_bdyproc (){ noeudPtr l1 = NULL, l2 = NULL, l3 = NULL, l4 = NULL, res = NULL; float thecst; int refb = 0; char *thechaine = ""; Symbol thesym; if (!flag.bdy) { sprintf (errbuf, "line %d: expecting symbol 'bdy'", numligne); erreur (errbuf); } flag.bdy = 0; flag.build = 0; thesym = cursym; nextsym (); match (lpar); thecst = curcst; if (thecst < 0) { sprintf (errbuf, "line %d: invalid bdy number (ng): <0", numligne); erreur (errbuf); } match (cste); match (comma); if(thesym==polygon) { thechaine = curchaine; match (chaine); if(cursym==comma) { nextsym(); l1 = expr (); } match (rpar); plante (&res, polygon, thecst, refb, NULL, thechaine, l1, NULL, NULL, NULL); } else{ l1 = expr (); match (comma); l2 = expr (); match (comma); l3 = expr (); if (cursym == comma) { nextsym (); refb = int(curcst); if (thecst < 0) { sprintf (errbuf, "line %d: invalid bdy number (ng): <0", numligne); erreur (errbuf); } nextsym(); } match (rpar); l4 = instruction (); plante (&res, symb_bdy, thecst, refb, NULL, pt, l1, l2, l3, l4); } flag.bdy = 1; flag.build = 1; return res;}noeudPtr femParser::preparesolve (){ noeudPtr l3 = NULL, res = NULL; Symbol whatsym = cursym; char *thechaine = NULL; l3 = NULL; nextsym (); match (lpar); N = 0; if (cursym == chaine) { if (whatsym == sauvetout) { thechaine = curchaine; match (chaine); match (comma); } } if (!((cursym == newvar) || (cursym == fdecl))) { sprintf (errbuf, "line %d: Expecting a function\n", numligne); erreur (errbuf); } while ((cursym == newvar) || (cursym == fdecl)) { curident->value = N++; curident->symb = fdecl; plante (&res, symb_system, 0.F, -N, curident, NULL, res, NULL, NULL, NULL); if (N > MAXSYS) { sprintf (errbuf, "line %d: Systems bigger than 2 not yet implemented\n", numligne); erreur (errbuf); } nextsym (); if (cursym == comma) nextsym (); } if (cursym != rpar) l3 = expr (); plante (&res, symb_system, 0.F, N, curident, thechaine, res, NULL, l3, NULL); match (rpar); return res;}noeudPtrfemParser::prepvarsolve (){ noeudPtr l3 = NULL, res = NULL; Symbol whatsym = cursym; char *thechaine = NULL; int varswitch=0; l3 = NULL; nextsym (); match (lpar); N = 0; if (cursym == chaine) { if (whatsym == sauvetout) { thechaine = curchaine; match (chaine); match (comma); } } if (!((cursym == newvar) || (cursym == fdecl))) { sprintf (errbuf, "line %d: Expecting a function\n", numligne); erreur (errbuf); } while ((cursym == newvar) || (cursym == fdecl)) { curident->value = N++; curident->symb = fdecl; plante (&res, varsolve, (creal)varswitch, -N, curident, NULL, res, NULL, NULL, NULL); nextsym (); if (cursym == comma) nextsym (); else if (cursym==semicolon){ varswitch = N; nextsym();} } if (cursym != rpar) l3 = expr (); //linear system indicator if(N != 2*varswitch) { sprintf (errbuf, "line %d: nb of test & unknown functions dont match\n", numligne); erreur (errbuf); } N = varswitch; plante (&res, varsolve, 0.F, N, curident, thechaine, res, NULL, l3, NULL); match (rpar); return res;}noeudPtr femParser::symb_dchproc (){ noeudPtr l1 = NULL, l2 = NULL, res = NULL; float thecst = 0.F; int im = -1, jm, thesgn, firstsgn = 1; Symbol thesym; char *pt = NULL; if (!flag.onbdy) { sprintf (errbuf, "line %d: expecting symbol 'onbdy'\n", numligne); erreur (errbuf); } nextsym (); match (lpar); do { if (cursym == comma) nextsym (); thecst = thecst * 100 + curcst; //code all boundaries: ib<100 else trouble match (cste); } while (cursym == comma); match (rpar); if ((cursym == newvar) || (cursym == fdecl)) // Dirichlet { nextsym (); im = (int) realpart (curident->value); match (fctdef); l1 = expr (); plante (&res, symb_dch, thecst, im, NULL, pt, l1, NULL, NULL, NULL); flag.onbdy = 1; return res; } do { // Robin - Fourier thesgn = 1; pt = NULL; l2 = NULL; switch (cursym) { case op_minus: thesgn = -1; case op_plus: nextsym (); default: break; } if ((thesgn == -1) && (cursym == symb_frr)) firstsgn = -1;// { sprintf(errbuf, "line %d: Cannot have '-' in front of dnu()", numligne); erreur(errbuf);} if (!((cursym == symb_id) || (cursym == symb_frr))) { sprintf (errbuf, "line %d: Expecting id() or dnu(). Found : %s", numligne, mesg[cursym]); erreur (errbuf); } if ((cursym == symb_frr) && (flag.onbdy == 2)) { sprintf (errbuf, "line %d: Only one dnu() allowed per statement", numligne); erreur (errbuf); } if (cursym == symb_id) thesym = id_bdy; else { flag.onbdy = 2; thesym = cursym; } nextsym (); match (lpar); jm = (int) realpart (curident->value); if (cursym != newvar) match (fdecl); match (rpar); if (thesym == id_bdy) { if ((cursym == slash) || (cursym == star) || (cursym == modulo)) { if (cursym == slash) pt = "a"; nextsym (); l2 = terme (); } else plante (&l2, cste, 1.F, 0, NULL, NULL, NULL, NULL, NULL, NULL); plante (&res, id_bdy, thesgn * thecst, jm, NULL, pt, res, l2, NULL, NULL); } else im = jm; } while (cursym == op_minus || cursym == op_plus); flag.onbdy = 1; match (fctdef); l2 = expr (); plante (&res, symb_frr, firstsgn * thecst, im, NULL, NULL, res, l2, NULL, NULL); return res;}noeudPtr femParser::symb_pdeproc (){ noeudPtr l1 = NULL, l2 = NULL, l3 = NULL, res = NULL; ident *theid = NULL; Symbol thesym; char *thechaine = ""; char *pt = NULL; int im, jm; float thesgn = 1.F; nextsym (); match (lpar); theid = curident; im = (int) realpart (curident->value); if (cursym == newvar) { theid->symb = fdecl; nextsym (); } else match (fdecl); match (rpar); do { thesgn = 1.F; pt = NULL; l1 = NULL; switch (cursym) { case op_minus: thesgn = -1.F; case op_plus: nextsym (); default: break; } switch (cursym) { case symb_id: case symb_lapl: case d_xx: case d_xy: case d_yx: case d_yy: case partial_x: case partial_y: thesym = cursym; if (thesym == partial_x) thesym = div_x; if (thesym == partial_y) thesym = div_y; nextsym (); match (lpar); jm = (int) realpart (curident->value); match (fdecl); match (rpar); if ((cursym == slash) || (cursym == star)) { if (cursym == slash) pt = "a"; nextsym (); l1 = terme (); } else plante (&l1, cste, 1.F, 0, NULL, NULL, NULL, NULL, NULL, NULL); plante (&res, thesym, thesgn, im * 100 + jm, NULL, pt, res, l1, NULL, NULL); break; default: sprintf (errbuf, "line %d: Unexpected symbol : %s", numligne, mesg[cursym]); erreur (errbuf); } } while (cursym == op_minus || cursym == op_plus); match (fctdef); l2 = expr (); plante (&res, symb_pde, 0.F, im, theid, thechaine, res, l2, l3, NULL); return res;}noeudPtr femParser::diskmshproc (){ noeudPtr res = NULL, l1 = NULL; Symbol thesym = cursym; char *thechaine = NULL; if (cursym != chargmsh) { if (!flag.fct) { sprintf (errbuf, "line %d: illegal use of symbol %s", numligne, mesg[cursym]); erreur (errbuf); } } nextsym (); match (lpar); thechaine = curchaine; match (chaine); if (cursym == comma) { nextsym(); l1 = expr(); } match (rpar); plante (&res, thesym, 0.F, 0, NULL, thechaine, l1, NULL, NULL, NULL); if (thesym == chargmsh) { if (OPTION) { flag.build = 0; flag.bdy = 0; } flag.fct = 1; flag.onbdy = 1; flag.solv = 1; } return res;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -