diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb05d8f9..687f5bd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,8 +96,6 @@ foreach(type ${ParserTypes}) ${BISON_EXECUTABLE} --defines=parse_${type}.hpp --output=parse_${type}.cpp - -v - -Wprecedence ${bisonIn} DEPENDS ${bisonIn}) # Create custom Flex diff --git a/src/check_citi.cpp b/src/check_citi.cpp index ad26a32d..06f72ed8 100644 --- a/src/check_citi.cpp +++ b/src/check_citi.cpp @@ -89,7 +89,8 @@ static char * citi_get_package (struct citi_package_t * p) { } /* Create a valid vector for the dataset. */ -static qucs::vector * citi_create_vector (struct citi_package_t * p, int i, char * n, char * type) { +static qucs::vector * citi_create_vector (struct citi_package_t * p, int i, + char * n, char * type) { qucs::vector * vec; vec = citi_get_vector (p, i); // fetch vector vec = new qucs::vector (*vec); // copy vector @@ -194,8 +195,8 @@ int citi_check (void) { int cvar = citi_count_variables (p); if (cvec != cvar) { logprint (LOG_ERROR, "checker error, no. of vectors (%d) does not equal " - "no. of variables (%d) in package `%s'\n", cvec, cvar, - package); + "no. of variables (%d) in package `%s'\n", cvec, cvar, + package); errors++; break; } @@ -212,50 +213,50 @@ int citi_check (void) { for (h = p->head; h != NULL; h = h->next) { qucs::vector * v; if (h->var != NULL) { - char txt[sizeof(opack) + 16]; - if (h->i1 >= 0) { - /* dependent variables */ - if (h->i2 >= 0) { - sprintf (txt, "%s%s[%d,%d]", opack, h->var, h->i1, h->i2); - v = citi_create_vector (p, n, txt, h->type); - v->setDependencies (new strlist (deps)); - errors += citi_check_dep_length (v, deps, package); - citi_result->addVariable (v); - n++; - } else { - sprintf (txt, "%s%s[%d]", opack, h->var, h->i1); - v = citi_create_vector (p, n, txt, h->type); - v->setDependencies (new strlist (deps)); - errors += citi_check_dep_length (v, deps, package); - citi_result->addVariable (v); - n++; - } - } else if (h->n >= 0) { - /* independent variable */ - sprintf (txt, "%s%s", opack, h->var); - v = citi_create_vector (p, n, txt, h->type); - deps.add (txt); - if (!citi_result->findDependency (txt)) { - /* add independent vectors only once */ - citi_result->addDependency (v); - } - n++; - // check length of independent vector - if (v->getSize () != h->n) { - logprint (LOG_ERROR, "checker error, vector `%s' length (%d) " - "does not equal defined length (%d) in package `%s'\n", - h->var, v->getSize (), h->n, package); - errors++; - } - } else { - /* dependent variables, no indices */ - sprintf (txt, "%s%s", opack, h->var); - v = citi_create_vector (p, n, txt, h->type); - v->setDependencies (new strlist (deps)); - errors += citi_check_dep_length (v, deps, package); - citi_result->addVariable (v); - n++; - } + char txt[256]; + if (h->i1 >= 0) { + /* dependent variables */ + if (h->i2 >= 0) { + sprintf (txt, "%s%s[%d,%d]", opack, h->var, h->i1, h->i2); + v = citi_create_vector (p, n, txt, h->type); + v->setDependencies (new strlist (deps)); + errors += citi_check_dep_length (v, deps, package); + citi_result->addVariable (v); + n++; + } else { + sprintf (txt, "%s%s[%d]", opack, h->var, h->i1); + v = citi_create_vector (p, n, txt, h->type); + v->setDependencies (new strlist (deps)); + errors += citi_check_dep_length (v, deps, package); + citi_result->addVariable (v); + n++; + } + } else if (h->n >= 0) { + /* independent variable */ + sprintf (txt, "%s%s", opack, h->var); + v = citi_create_vector (p, n, txt, h->type); + deps.add (txt); + if (!citi_result->findDependency (txt)) { + /* add independent vectors only once */ + citi_result->addDependency (v); + } + n++; + // check length of independent vector + if (v->getSize () != h->n) { + logprint (LOG_ERROR, "checker error, vector `%s' length (%d) " + "does not equal defined length (%d) in package `%s'\n", + h->var, v->getSize (), h->n, package); + errors++; + } + } else { + /* dependent variables, no indices */ + sprintf (txt, "%s%s", opack, h->var); + v = citi_create_vector (p, n, txt, h->type); + v->setDependencies (new strlist (deps)); + errors += citi_check_dep_length (v, deps, package); + citi_result->addVariable (v); + n++; + } } } } diff --git a/src/check_mdl.cpp b/src/check_mdl.cpp index 14776ccf..4186b06b 100644 --- a/src/check_mdl.cpp +++ b/src/check_mdl.cpp @@ -346,7 +346,7 @@ valuelist * mdl_find_depdataset (struct mdl_link_t * link, else if (!strcmp (hyptab->name, "List Table")) { lstsweep * sw = new lstsweep (); sw->create (nof); - char txt[32]; + char txt[16]; for (int i = 0; i < nof; i++) { sprintf (txt, "Value %d", i + 1); val = mdl_helement_dvalue (link, hyptab->data, txt); @@ -418,7 +418,7 @@ static void mdl_find_varlink (struct mdl_link_t * link, char * name, // Sorts a dependency list according to their sweep order. static strlist * mdl_sort_deps (valuelist * d) { strlist * deps = new strlist (); - for (int i = 0; i < static_cast(d->size()); i++) { + for (int i = 0; i < d->size(); i++) { for (auto &val: *d) { if (val.second == i + 1) { deps->append (val.first.c_str()); diff --git a/src/circuit.cpp b/src/circuit.cpp index 2c79e78e..752e50a9 100644 --- a/src/circuit.cpp +++ b/src/circuit.cpp @@ -229,22 +229,22 @@ void circuit::freeMatrixHB (void) { /* Allocates the HB-matrix memory. */ void circuit::allocMatrixHB (void) { if (VectorQ) { - memset (static_cast(VectorQ), 0, size * sizeof (nr_complex_t)); + memset (VectorQ, 0, size * sizeof (nr_complex_t)); } else { VectorQ = new nr_complex_t[size]; } if (MatrixQV) { - memset (static_cast(MatrixQV), 0, size * size * sizeof (nr_complex_t)); + memset (MatrixQV, 0, size * size * sizeof (nr_complex_t)); } else { MatrixQV = new nr_complex_t[size * size]; } if (VectorCV) { - memset (static_cast(VectorCV), 0, size * sizeof (nr_complex_t)); + memset (VectorCV, 0, size * sizeof (nr_complex_t)); } else { VectorCV = new nr_complex_t[size]; } if (VectorGV) { - memset (static_cast(VectorGV), 0, size * sizeof (nr_complex_t)); + memset (VectorGV, 0, size * sizeof (nr_complex_t)); } else { VectorGV = new nr_complex_t[size]; } @@ -253,7 +253,7 @@ void circuit::allocMatrixHB (void) { /* Allocates the S-parameter matrix memory. */ void circuit::allocMatrixS (void) { if (MatrixS) { - memset (static_cast(MatrixS), 0, size * size * sizeof (nr_complex_t)); + memset (MatrixS, 0, size * size * sizeof (nr_complex_t)); } else { MatrixS = new nr_complex_t[size * size]; } @@ -654,8 +654,8 @@ void circuit::setMatrixS (matrix s) { circuit. */ matrix circuit::getMatrixS (void) { matrix res (size); - for(int i=0; i < size; ++i) - for(int j=0; j < size; ++j) + for(unsigned int i=0; i < size; ++i) + for(unsigned int j=0; j < size; ++j) res(i,j) = MatrixS[i*size + j]; return res; } @@ -675,8 +675,8 @@ void circuit::setMatrixN (matrix n) { matrix of the circuit. */ matrix circuit::getMatrixN (void) { matrix res (size); - for(int i=0; i < size; ++i) - for(int j=0; j < size; ++j) + for(unsigned int i=0; i < size; ++i) + for(unsigned int j=0; j < size; ++j) res(i,j) = MatrixN[i*size + j]; return res; } @@ -696,50 +696,50 @@ void circuit::setMatrixY (matrix y) { circuit. */ matrix circuit::getMatrixY (void) { matrix res (size); - for(int i=0; i < size; ++i) - for(int j=0; j < size; ++j) + for(unsigned int i=0; i < size; ++i) + for(unsigned int j=0; j < size; ++j) res(i,j) = MatrixY[i*size + j]; return res; } // The function cleans up the B-MNA matrix entries. void circuit::clearB (void) { - memset (static_cast(MatrixB), 0, sizeof (nr_complex_t) * size * vsources); + memset (MatrixB, 0, sizeof (nr_complex_t) * size * vsources); } // The function cleans up the C-MNA matrix entries. void circuit::clearC (void) { - memset (static_cast(MatrixC), 0, sizeof (nr_complex_t) * size * vsources); + memset (MatrixC, 0, sizeof (nr_complex_t) * size * vsources); } // The function cleans up the D-MNA matrix entries. void circuit::clearD (void) { - memset (static_cast(MatrixD), 0, sizeof (nr_complex_t) * vsources * vsources); + memset (MatrixD, 0, sizeof (nr_complex_t) * vsources * vsources); } // The function cleans up the E-MNA matrix entries. void circuit::clearE (void) { - memset (static_cast(VectorE), 0, sizeof (nr_complex_t) * vsources); + memset (VectorE, 0, sizeof (nr_complex_t) * vsources); } // The function cleans up the J-MNA matrix entries. void circuit::clearJ (void) { - memset (static_cast(VectorJ), 0, sizeof (nr_complex_t) * vsources); + memset (VectorJ, 0, sizeof (nr_complex_t) * vsources); } // The function cleans up the I-MNA matrix entries. void circuit::clearI (void) { - memset (static_cast(VectorI), 0, sizeof (nr_complex_t) * size); + memset (VectorI, 0, sizeof (nr_complex_t) * size); } // The function cleans up the V-MNA matrix entries. void circuit::clearV (void) { - memset (static_cast(VectorV), 0, sizeof (nr_complex_t) * size); + memset (VectorV, 0, sizeof (nr_complex_t) * size); } // The function cleans up the G-MNA matrix entries. void circuit::clearY (void) { - memset (static_cast(MatrixY), 0, sizeof (nr_complex_t) * size * size); + memset (MatrixY, 0, sizeof (nr_complex_t) * size * size); } /* This function can be used by several components in order to place diff --git a/src/components/devices/thyristor.cpp b/src/components/devices/thyristor.cpp index 5b2e7cba..f20cf5a8 100644 --- a/src/components/devices/thyristor.cpp +++ b/src/components/devices/thyristor.cpp @@ -85,7 +85,7 @@ void thyristor::calcTheModel (bool last) { isOn = Ud > Ud_bo; nr_double_t Vak = real (getV (NODE_A1) - getV (NODE_A2)); - isOn &= (Vak > 0.0); + isOn *= (Vak > 0.0); if (Ud >= 80.0) { Id *= std::exp (80.0) * (1.0 + Ud - 80.0) - 1.0; diff --git a/src/components/microstrip/bondwire.cpp b/src/components/microstrip/bondwire.cpp index c3be904f..4140d0c5 100644 --- a/src/components/microstrip/bondwire.cpp +++ b/src/components/microstrip/bondwire.cpp @@ -414,7 +414,7 @@ void bondwire::calcDC(void) } } -void bondwire::calcTR() +void bondwire::calcTR(nr_double_t t) { calcDC(); } diff --git a/src/components/microstrip/bondwire.h b/src/components/microstrip/bondwire.h index 154ecfc4..944ba7e0 100644 --- a/src/components/microstrip/bondwire.h +++ b/src/components/microstrip/bondwire.h @@ -39,7 +39,7 @@ class bondwire : public qucs::circuit void initTR (void); void calcDC (void); void calcAC (nr_double_t); - void calcTR (); + void calcTR (nr_double_t); void calcNoiseAC (nr_double_t); qucs::matrix calcMatrixY (nr_double_t); void saveCharacteristics (nr_double_t); diff --git a/src/converter/CMakeLists.txt b/src/converter/CMakeLists.txt index 65ceecab..61e15fc0 100644 --- a/src/converter/CMakeLists.txt +++ b/src/converter/CMakeLists.txt @@ -26,10 +26,6 @@ foreach(type ${ParserTypes}) ${BISON_EXECUTABLE} --defines=parse_${type}.hpp --output=parse_${type}.cpp - -v - -Wce - -Wprecedence - -Wmidrule-value ${bisonIn} DEPENDS ${bisonIn}) # Create custom Flex @@ -64,4 +60,4 @@ target_link_libraries(qucsconv_rf libqucsator ${CMAKE_DL_LIBS}) # # Handle installation # -install(TARGETS qucsconv_rf DESTINATION bin) +install(TARGETS qucsconv_rf DESTINATION bin) \ No newline at end of file diff --git a/src/converter/check_spice.cpp b/src/converter/check_spice.cpp index e2c55a92..2a8dce0c 100644 --- a/src/converter/check_spice.cpp +++ b/src/converter/check_spice.cpp @@ -858,7 +858,7 @@ static void spice_translate_nodes (struct definition_t * def, int pass) { node->node = strdup (t->node); else { // no node given, occurs in device descriptions - char txt[17]; + char txt[16]; sprintf (txt, "%s%d", "_node", n); node->node = strdup (txt); } diff --git a/src/converter/parse_spice.ypp b/src/converter/parse_spice.ypp index 8056f9ce..b9948dc9 100644 --- a/src/converter/parse_spice.ypp +++ b/src/converter/parse_spice.ypp @@ -44,14 +44,6 @@ #include "check_spice.h" -#define YY_HEADER_EXPORT_START_CONDITIONS -#include "scan_spice.hpp" - -extern char* spice_text; - -extern void push_state(int state); -extern void pop_state(); - // Converts the given string into upper case. static char * spice_toupper (char * str) { for (unsigned int i = 0; i < strlen (str); i++) { @@ -136,11 +128,10 @@ static struct value_t * spice_append_val_values (struct value_t * values, %} -%define api.prefix {spice_} +%name-prefix "spice_" %token TitleLine InvalidCharacter End Eol -%token Identifier Digits Floats Nodes Options Function Lookahead_Double_Value -%token Lookahead_Three_Node Lookahead_Four_Node Lookahead_Five_Node +%token Identifier Digits Floats Nodes Options Function %token SUBCKT_Action ENDS_Action AC_Action OP_Action I_Source SAVE_Action %token RLC_Device L_Device K_Device IV_Source GE_Source FH_Source V_Source %token Diode_Device Bipolar_Device JFET_Device MOSFET_Device MESFET_Device @@ -152,9 +143,6 @@ static struct value_t * spice_append_val_values (struct value_t * values, %token U_Device S_Device W_Device ON_Special TF_Action SENS_Action FOUR_Action %token OpFunc Behave TC_Special TEMP_Action -%precedence Identifier Digits Nodes -%precedence _NODE_ - %union { char * ident; char * str; @@ -174,7 +162,7 @@ static struct value_t * spice_append_val_values (struct value_t * values, %type IC_Condition_4 SWITCH_State NodeValueList TC_Value_1 TC_Value_2 %type VSourceList -%type Identifier Nodes Function Value Lookahead_Double_Value Floats Digits Node FH_Node +%type Identifier Nodes Function Value Floats Digits Node FH_Node %type RLC_Device K_Device L_Device IV_Source GE_Source FH_Source %type V_Source MODEL_Spec Diode_Device Bipolar_Device JFET_Device %type MOSFET_Device MESFET_Device TRAN_Action PLOT_Action MODEL_Action @@ -186,7 +174,7 @@ static struct value_t * spice_append_val_values (struct value_t * values, %type IC_Special OFF_Special SIM_Type TEMP_Special MOS_Special %type BranchFunc NODESET_Action T_Device U_Device S_Device W_Device %type TF_Action SENS_Action FOUR_Action OpFunc TC_Special TEMP_Action -%type Behave Lookahead_Three_Node Lookahead_Four_Node Lookahead_Five_Node +%type Behave %% @@ -386,7 +374,7 @@ DefinitionLine: spice_append_str_value ($$, $5, HINT_NAME); $$->values = netlist_append_values ($$->values, $6); } - | Bipolar_Device Lookahead_Three_Node Node Node MODEL_Ident DEVICE_List_2 { + | Bipolar_Device Node Node Node MODEL_Ident DEVICE_List_2 { /* 3 node BJT */ $$ = spice_create_device ($1); spice_append_str_value ($$, $2, HINT_NODE); @@ -395,7 +383,7 @@ DefinitionLine: spice_append_str_value ($$, $5, HINT_NAME); $$->values = netlist_append_values ($$->values, $6); } - | Bipolar_Device Lookahead_Four_Node Node Node Node MODEL_Ident DEVICE_List_2 { + | Bipolar_Device Node Node Node Node MODEL_Ident DEVICE_List_2 { /* 4 node BJT */ $$ = spice_create_device ($1); spice_append_str_value ($$, $2, HINT_NODE); @@ -405,7 +393,7 @@ DefinitionLine: spice_append_str_value ($$, $6, HINT_NAME); $$->values = netlist_append_values ($$->values, $7); } - | Bipolar_Device Lookahead_Five_Node Node Node Node Node MODEL_Ident DEVICE_List_2 { + | Bipolar_Device Node Node Node Node Node MODEL_Ident DEVICE_List_2 { /* 5 node BJT */ $$ = spice_create_device ($1); spice_append_str_value ($$, $2, HINT_NODE); @@ -673,7 +661,7 @@ IC_Condition_4: ; Output_Range: - Lookahead_Double_Value Value { /* range specification during plotting */ + Value Value { /* range specification during plotting */ $$ = NULL; $$ = spice_append_val_values ($$, $1, HINT_NUMBER); $$ = spice_append_val_values ($$, $2, HINT_NUMBER); @@ -681,14 +669,13 @@ Output_Range: ; VOLTAGE_Output: - Node { + Node { // TODO: 2 reduce/reduce, 2 shift/reduce /* print/plot specification of node voltage */ - push_state(DOUBLEVALUE); $$ = NULL; $$ = spice_append_str_values ($$, strdup ("V"), HINT_NAME | HINT_MSTART); $$ = spice_append_str_values ($$, $1, HINT_NODE | HINT_MSTOP); } - | VoltFunc Node %prec _NODE_ { + | VoltFunc Node { // TODO: 2 reduce/reduce /* print/plot specification of node voltage */ $$ = NULL; $$ = spice_append_str_values ($$, $1, HINT_NAME | HINT_MSTART); @@ -856,7 +843,7 @@ DEVICE_List_3: /* nothing */ { $$ = NULL; } $$ = netlist_append_values ($$, $2); } | IC_Condition_3 DEVICE_List_3 { - $$ = netlist_append_values ($1, $2); + $$ = netlist_append_values ($1, $2); } ; @@ -982,6 +969,6 @@ SubBodyLine: %% int spice_error (const char * error) { - fprintf (stderr, "line %d: %s at id %d, token '%s'\n", spice_lineno, error, spice_char, spice_text); + fprintf (stderr, "line %d: %s\n", spice_lineno, error); return 0; } diff --git a/src/converter/parse_vcd.ypp b/src/converter/parse_vcd.ypp index 9f0e0e58..29dc63dd 100644 --- a/src/converter/parse_vcd.ypp +++ b/src/converter/parse_vcd.ypp @@ -43,7 +43,7 @@ %} -%define api.prefix {vcd_} +%name-prefix "vcd_" %token t_END %token t_COMMENT @@ -91,7 +91,7 @@ } %type Identifier IdentifierCode Reference -%type Value ZERO ONE Z Binary Real U +%type Value ZERO ONE Z X Binary Real %type Size PositiveInteger TimeScale %type TimeUnit SimulationTime PositiveHugeInteger %type ScalarValueChange VectorValueChange ValueChangeList ValueChange diff --git a/src/converter/scan_spice.lpp b/src/converter/scan_spice.lpp index f2129211..af6566ae 100644 --- a/src/converter/scan_spice.lpp +++ b/src/converter/scan_spice.lpp @@ -50,6 +50,7 @@ #include "check_spice.h" #include "parse_spice.hpp" + /* fixing invalid identifiers */ static void spice_fix_identifier (char * ident) { char * p; @@ -61,22 +62,6 @@ static void spice_fix_identifier (char * ident) { } } -static void yy_push_state(int); -static void yy_pop_state(); -static int yy_top_state(); - -void push_state(int state) { - yy_push_state(state); -} - -void pop_state() { - yy_pop_state(); -} - -int top_state() { - return yy_top_state(); -} - %} WS [ \t\n\r] @@ -149,8 +134,8 @@ POLY [pP][oO][lL][yY] %x COMMENT IVREF DEVPROP LREF MODREF1 MODREF2 IGNORE FUNREF FILEREF VREF %x STARTUP VSINGLE ISWITCH VSWITCH CONTROL GEVALS INLINE SUBCKT TLPROP RLCPROP -%x FHVALS DOUBLEVALUE LANODE -%option yylineno stack noyywrap nounput noinput prefix="spice_" header-file="scan_spice.hpp" +%x FHVALS +%option yylineno noyywrap nounput noinput prefix="spice_" %% ^{TITLE} { /* detect initial title lines */ @@ -514,7 +499,6 @@ POLY [pP][oO][lL][yY] ^[qQ]{CSFX} { /* BJT instances */ spice_lval.ident = strdup (spice_text); BEGIN(DEVPROP); - push_state(LANODE); return Bipolar_Device; } @@ -540,51 +524,17 @@ POLY [pP][oO][lL][yY] return End; } -{NUMBER}|{DIGIT}+/{WS}({DIGIT}+|NUMBER) { - /* identify value followed by value */ - spice_lval.ident = strdup (spice_text); - pop_state(); - return Lookahead_Double_Value; -} - -{NODE}|{IDENT}|{DIGIT}+/{WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({MODEL}|{IDENT}) { - /* identify node followed by 2 node */ - spice_lval.ident = strdup (spice_text); - pop_state(); - return Lookahead_Three_Node; -} - -{NODE}|{IDENT}|{DIGIT}+/{WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({MODEL}|{IDENT}) { - /* identify node followed by 3 node */ - spice_lval.ident = strdup (spice_text); - pop_state(); - return Lookahead_Four_Node; -} - -{NODE}|{IDENT}|{DIGIT}+/{WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({DIGIT}+|{NODE}|{IDENT}){WS}+({MODEL}|{IDENT}) { - /* identify node followed by 4 node */ - spice_lval.ident = strdup (spice_text); - pop_state(); - return Lookahead_Five_Node; -} - {DIGIT}+ { + GEVALS,TLPROP,RLCPROP,FHVALS>{DIGIT}+ { /* identify node (containing digits) */ spice_lval.ident = strdup (spice_text); - if (yy_start_stack_ptr > 0 && top_state() == DOUBLEVALUE) { - pop_state(); - } return Digits; } {NUMBER} { + RLCPROP,FHVALS>{NUMBER} { /* identify float (any kind) */ spice_lval.ident = strdup (spice_text); - if (yy_start_stack_ptr > 0 && top_state() == DOUBLEVALUE) { - pop_state(); - } return Floats; } @@ -613,12 +563,9 @@ POLY [pP][oO][lL][yY] } {IDENT} { /* arbitrary identifier */ + TLPROP,RLCPROP>{IDENT} { /* arbitrary identifier */ spice_lval.ident = strdup (spice_text); spice_fix_identifier (spice_lval.ident); - if (yy_start_stack_ptr > 0 && top_state() == DOUBLEVALUE) { - pop_state(); - } return Identifier; } @@ -649,21 +596,15 @@ POLY [pP][oO][lL][yY] } {NODE} { + TLPROP,RLCPROP,FHVALS>{NODE} { /* identify node */ spice_lval.ident = strdup (spice_text); - if (yy_start_stack_ptr > 0 && top_state() == DOUBLEVALUE) { - pop_state(); - } return Nodes; } {EOL} { + ISWITCH,VSWITCH,GEVALS,SUBCKT,TLPROP,RLCPROP,FHVALS>{EOL} { /* detect end of line */ - if (yy_start_stack_ptr > 0 && top_state() == DOUBLEVALUE) { - pop_state(); - } BEGIN(STARTUP); return Eol; } diff --git a/src/environment.cpp b/src/environment.cpp index 0b175f25..4fee717b 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -294,7 +294,7 @@ void environment::setValue (char * n, constant * value) { // Local macro definition to go through the list of equations. #define foreach_equation(eqn) \ - for (assignment * eqn = A (equations); \ + for (assignment * (eqn) = A (equations); \ (eqn) != NULL; (eqn) = A ((eqn)->getNext ())) // Short helper macro. diff --git a/src/equation.cpp b/src/equation.cpp index 554f0201..e6cb5979 100644 --- a/src/equation.cpp +++ b/src/equation.cpp @@ -1401,7 +1401,7 @@ checker::~checker () // Local macro definition to go through the list of equations. #define foreach_equation(eqn) \ - for (assignment * eqn = A (equations); \ + for (assignment * (eqn) = A (equations); \ (eqn) != NULL; (eqn) = A ((eqn)->getNext ())) /* The function goes through the list of equations assigned to the @@ -2187,7 +2187,6 @@ int solver::dataSize (constant * eqn) break; case TAG_MATVEC: // matrix vector size = eqn->getResult()->mv->getSize (); - break; default: size = 1; } diff --git a/src/evaluate.cpp b/src/evaluate.cpp index f0979f78..c405fd33 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -76,14 +76,14 @@ using namespace fspecial; #define _ARES(idx) args->getResult(idx) #define _ARG(idx) args->get(idx) -#define _D(var,idx) nr_double_t var = D (_ARES (idx)); -#define _BO(var,idx) bool var = B (_ARES (idx)); -#define _CX(var,idx) nr_complex_t * var = C (_ARES (idx)); -#define _V(var,idx) qucs::vector * var = V (_ARES (idx)); -#define _M(var,idx) matrix * var = M (_ARES (idx)); -#define _MV(var,idx) matvec * var = MV (_ARES (idx)); -#define _I(var,idx) int var = INT (_ARES (idx)); -#define _R(var,idx) range * var = RNG (_ARES (idx)); +#define _D(var,idx) nr_double_t (var) = D (_ARES (idx)); +#define _BO(var,idx) bool (var) = B (_ARES (idx)); +#define _CX(var,idx) nr_complex_t * (var) = C (_ARES (idx)); +#define _V(var,idx) qucs::vector * (var) = V (_ARES (idx)); +#define _M(var,idx) matrix * (var) = M (_ARES (idx)); +#define _MV(var,idx) matvec * (var) = MV (_ARES (idx)); +#define _I(var,idx) int (var) = INT (_ARES (idx)); +#define _R(var,idx) range * (var) = RNG (_ARES (idx)); #define _ARR0(var) _R (var,0) #define _ARR1(var) _R (var,1) diff --git a/src/hbsolver.cpp b/src/hbsolver.cpp index b8141c8b..f5083744 100644 --- a/src/hbsolver.cpp +++ b/src/hbsolver.cpp @@ -415,7 +415,7 @@ void hbsolver::collectFrequencies (void) { // build frequency dimension lengths ndfreqs = new int[dfreqs.size ()]; - for (i = 0; i < static_cast(dfreqs.size ()); i++) { + for (i = 0; i < dfreqs.size (); i++) { ndfreqs[i] = (n + 1) * 2; } @@ -428,7 +428,7 @@ void hbsolver::collectFrequencies (void) { #endif /* HB_DEBUG */ // build list of positive frequencies including DC - for (n = 0; n < static_cast(negfreqs.size ()); n++) { + for (n = 0; n < negfreqs.size (); n++) { if ((f = negfreqs[n]) < 0.0) continue; rfreqs.push_back (f); } @@ -576,7 +576,7 @@ void hbsolver::createMatrixLinearA (void) { A = new tmatrix ((N + M) * lnfreqs); // through each frequency - for (int i = 0; i < static_cast(rfreqs.size ()); i++) { + for (int i = 0; i < rfreqs.size (); i++) { freq = rfreqs[i]; // calculate components' MNA matrix for the given frequency for (auto *lc : lincircuits) @@ -882,7 +882,7 @@ void hbsolver::calcConstantCurrent (void) { circuit * vs = *it; vs->initHB (); vs->setVoltageSource (0); - for (int f = 0; f < static_cast(rfreqs.size ()); f++) { // for each frequency + for (int f = 0; f < rfreqs.size (); f++) { // for each frequency nr_double_t freq = rfreqs[f]; vs->calcHB (freq); VC (vsrc * lnfreqs + f) = vs->getE (VSRC_1); diff --git a/src/interface/e_trsolver.cpp b/src/interface/e_trsolver.cpp index 5d9befc4..160322b7 100644 --- a/src/interface/e_trsolver.cpp +++ b/src/interface/e_trsolver.cpp @@ -371,7 +371,7 @@ void e_trsolver::printx() { char buf [1024]; - for (int r = 0; r < static_cast(x->size()); r++) { + for (int r = 0; r < x->size(); r++) { buf[0] = '\0'; //sprintf (buf, "%+.2e%+.2ei", (double) real (x->get (r)), (double) imag (x->get (r))); @@ -552,7 +552,7 @@ void e_trsolver::acceptstep_sync() /* This function tries to adapt the current time-step according to the global truncation error. */ -void e_trsolver::adjustDelta_sync (nr_double_t /* t */) +void e_trsolver::adjustDelta_sync (nr_double_t t) { deltaOld = delta; @@ -830,7 +830,7 @@ void e_trsolver::copySolution (tvector * src[8], tvectorsize () == dest[i]->size ()); // copy over the data values - for (int j = 0; j < static_cast(src[i]->size ()); j++) + for (int j = 0; j < src[i]->size (); j++) { dest[i]->set (j, src[i]->get (j)); } diff --git a/src/module.cpp b/src/module.cpp index 3a8e0605..e09465d7 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -454,7 +454,7 @@ void module::registerDynamicModules (char *proj, std::list modlist) */ fprintf(stdout,"project location: %s\n", proj); - fprintf(stdout,"modules to load: %u\n", modlist.size()); + fprintf(stdout,"modules to load: %lu\n", modlist.size()); std::list::iterator it; for (it=modlist.begin(); it!=modlist.end(); ++it) { diff --git a/src/nasolver.cpp b/src/nasolver.cpp index 08a32f0b..c343f618 100644 --- a/src/nasolver.cpp +++ b/src/nasolver.cpp @@ -250,7 +250,7 @@ void nasolver::applyNodeset (bool nokeep) if (x == NULL || nlist == NULL) return; // set each solution to zero - if (nokeep) for (int i = 0; i < static_cast(x->size ()); i++) x->set (i, 0); + if (nokeep) for (int i = 0; i < x->size (); i++) x->set (i, 0); // then apply the nodeset itself for (nodeset * n = subnet->getNodeset (); n; n = n->getNext ()) diff --git a/src/parse_citi.ypp b/src/parse_citi.ypp index f25d05fc..1fe08094 100644 --- a/src/parse_citi.ypp +++ b/src/parse_citi.ypp @@ -49,7 +49,7 @@ using namespace qucs; %} -%define api.prefix {citi_} +%name-prefix "citi_" %token InvalidCharacter %token Float diff --git a/src/parse_csv.ypp b/src/parse_csv.ypp index b5b57402..08584578 100644 --- a/src/parse_csv.ypp +++ b/src/parse_csv.ypp @@ -49,8 +49,9 @@ using namespace qucs; %} -%define api.prefix {csv_} +%name-prefix "csv_" +%token InvalidCharacter %token Float %token Identifier %token Eol @@ -65,7 +66,7 @@ using namespace qucs; %type HeaderList HeaderLine %type Identifier Header %type Float -%type DataSet DataList +%type DataLine DataSet DataList %% @@ -88,12 +89,7 @@ Header: } ; -HeaderList: - Header { - if ($$ == NULL) $$ = new strlist (); - $$->add ($1); - free ($1); - } +HeaderList: /* nothing */ { $$ = NULL; } | Header HeaderList { if ($2 == NULL) $2 = new strlist (); $2->add ($1); @@ -112,11 +108,11 @@ HeaderLine: /* header line */ ; DataSet: /* nothing */ { $$ = NULL; } - | DataList Eol DataSet { /* append vector lines */ + | DataLine Eol DataSet { /* append vector lines */ $1->setNext ($3); $$ = $1; } - | DataList { /* last line, no trailing end-of-line */ + | DataLine { /* last line, no trailing end-of-line */ $$ = $1; } | Eol DataSet { /* skip this line */ @@ -124,12 +120,10 @@ DataSet: /* nothing */ { $$ = NULL; } } ; -DataList: - Float { - if ($$ == NULL) $$ = new vector (); - $$ = new vector (); - $$->add ($1); - } +DataLine: DataList +; + +DataList: /* nothing */ { $$ = NULL; } | Float DataList { if ($2 == NULL) $2 = new vector (); $2->add ($1); diff --git a/src/parse_dataset.ypp b/src/parse_dataset.ypp index c4c57d60..5b46defa 100644 --- a/src/parse_dataset.ypp +++ b/src/parse_dataset.ypp @@ -49,7 +49,7 @@ using namespace qucs; %} -%define api.prefix {dataset_} +%name-prefix "dataset_" %token InvalidCharacter %token Identifier diff --git a/src/parse_mdl.ypp b/src/parse_mdl.ypp index ea3115ef..e5005f4b 100644 --- a/src/parse_mdl.ypp +++ b/src/parse_mdl.ypp @@ -49,7 +49,7 @@ using namespace qucs; %} -%define api.prefix {mdl_} +%name-prefix "mdl_" %token LINK %token Identifier diff --git a/src/parse_netlist.ypp b/src/parse_netlist.ypp index a560108b..e8a3bdd9 100644 --- a/src/parse_netlist.ypp +++ b/src/parse_netlist.ypp @@ -46,7 +46,7 @@ using namespace qucs; %} -%define api.prefix {netlist_} +%name-prefix "netlist_" %token InvalidCharacter %token Identifier @@ -62,6 +62,7 @@ using namespace qucs; %token Character %token STRING +%right '=' %right '?' ':' %left Or %left And @@ -69,9 +70,9 @@ using namespace qucs; %left Less Greater LessOrEqual GreaterOrEqual %left '-' '+' %left '*' '/' '%' -%precedence Not -%precedence NEG /* unary negation */ -%precedence POS /* unary non-negation */ +%right Not +%left NEG /* unary negation */ +%left POS /* unary non-negation */ %right '^' %union { diff --git a/src/parse_touchstone.ypp b/src/parse_touchstone.ypp index 69390e07..48edc534 100644 --- a/src/parse_touchstone.ypp +++ b/src/parse_touchstone.ypp @@ -49,7 +49,7 @@ using namespace qucs; %} -%define api.prefix {touchstone_} +%name-prefix "touchstone_" %token InvalidCharacter %token Float @@ -102,6 +102,15 @@ Dataset: /* nothing */ { } touchstone_line->setNext($2); touchstone_line = $2; } + | Dataset DataLine { /* last line, no trailing end-of-line */ + if (!touchstone_vector) + touchstone_vector = $2; /* save first vector location */ + if (touchstone_line) + touchstone_line->setNext($2); + touchstone_line = $2; + logprint (LOG_ERROR, "line %d: no trailing end-of-line found, " + "continuing...\n", touchstone_lineno); + } | Dataset Eol { /* skip this line */ } ; diff --git a/src/parse_zvr.ypp b/src/parse_zvr.ypp index 441c2285..12901c16 100644 --- a/src/parse_zvr.ypp +++ b/src/parse_zvr.ypp @@ -49,7 +49,7 @@ using namespace qucs; %} -%define api.prefix {zvr_} +%name-prefix "zvr_" %token ZVR %token Version diff --git a/src/scan_csv.lpp b/src/scan_csv.lpp index e124488b..cc6d8145 100644 --- a/src/scan_csv.lpp +++ b/src/scan_csv.lpp @@ -103,7 +103,7 @@ SPACE [ \t] logprint (LOG_ERROR, "line %d: syntax error, unrecognized character: `%s'\n", csv_lineno, csv_text); - REJECT; + return InvalidCharacter; } . { /* skip any character in here */ } diff --git a/src/spline.cpp b/src/spline.cpp index c45ed738..a96e29f3 100644 --- a/src/spline.cpp +++ b/src/spline.cpp @@ -119,7 +119,7 @@ void spline::vectors (std::vector y, std::vector t) { // Pass interpolation datapoints as tvectors. void spline::vectors (tvector y, tvector t) { int i = t.size (); - assert (static_cast(y.size ()) == i && i >= 3); + assert (y.size () == i && i >= 3); // create local copy of f(x) realloc (i); diff --git a/src/strlist.cpp b/src/strlist.cpp index 38789fee..920c5473 100644 --- a/src/strlist.cpp +++ b/src/strlist.cpp @@ -192,15 +192,6 @@ char * strlist::toString (const char * concat) { return txt ? txt : (char *) ""; } -strlist& strlist::operator=(strlist rhs) -{ - struct strlist_t * s; - root = NULL; - txt = NULL; - for (s = rhs.root; s != NULL; s = s->next) append (s->str); - return *this; -} - // Constructor for string list iterator. strlistiterator::strlistiterator (strlist & s) { _strlist = &s; diff --git a/src/strlist.h b/src/strlist.h index 3af66b4f..9ba39d88 100644 --- a/src/strlist.h +++ b/src/strlist.h @@ -55,7 +55,6 @@ class strlist static strlist * join (strlist *, strlist *); void del (strlist *); char * toString (const char * concat = " "); - strlist& operator=(strlist rhs); private: struct strlist_t * root; diff --git a/src/tmatrix.cpp b/src/tmatrix.cpp index 58b02c7a..9e6aafe4 100644 --- a/src/tmatrix.cpp +++ b/src/tmatrix.cpp @@ -57,7 +57,7 @@ tmatrix::tmatrix (int s) { rows = cols = s; if (s > 0) { data = new nr_type_t[s * s]; - memset (static_cast(data), 0, sizeof (nr_type_t) * s * s); + memset (data, 0, sizeof (nr_type_t) * s * s); } else data = NULL; } @@ -70,7 +70,7 @@ tmatrix::tmatrix (int r, int c) { cols = c; if (r > 0 && c > 0) { data = new nr_type_t[r * c]; - memset (static_cast(data), 0, sizeof (nr_type_t) * r * c); + memset (data, 0, sizeof (nr_type_t) * r * c); } else data = NULL; } @@ -294,7 +294,7 @@ tmatrix operator * (tmatrix a, tmatrix b) { // Multiplication of matrix and vector. template tvector operator * (tmatrix a, tvector b) { - assert (a.getCols () == static_cast(b.size ())); + assert (a.getCols () == b.size ()); int r, c, n = a.getCols (); nr_type_t z; tvector res (n); @@ -309,7 +309,7 @@ tvector operator * (tmatrix a, tvector b) { // Multiplication of vector (transposed) and matrix. template tvector operator * (tvector a, tmatrix b) { - assert (static_cast(a.size ()) == b.getRows ()); + assert (a.size () == b.getRows ()); int r, c, n = b.getRows (); nr_type_t z; tvector res (n); diff --git a/src/tvector.cpp b/src/tvector.cpp index f6d1734e..a21a317e 100644 --- a/src/tvector.cpp +++ b/src/tvector.cpp @@ -180,7 +180,7 @@ template nr_type_t scalar (tvector a, tvector b) { assert (a.size () == b.size ()); nr_type_t n = 0; - for (int i = 0; i < static_cast(a.size ()); i++) n += a.get (i) * b.get (i); + for (int i = 0; i < a.size (); i++) n += a.get (i) * b.get (i); return n; } @@ -195,7 +195,7 @@ tvector tvector::operator = (const nr_type_t val) { template nr_type_t sum (tvector a) { nr_type_t res = 0; - for (int i = 0; i < static_cast(a.size ()); i++) res += a.get (i); + for (int i = 0; i < a.size (); i++) res += a.get (i); return res; } @@ -249,7 +249,7 @@ nr_double_t norm (tvector a) { return n; #else nr_double_t scale = 0, n = 1, x, ax; - for (int i = 0; i < static_cast(a.size ()); i++) { + for (int i = 0; i < a.size (); i++) { if ((x = real (a (i))) != 0) { ax = fabs (x); if (scale < ax) { @@ -283,7 +283,7 @@ nr_double_t norm (tvector a) { template nr_double_t maxnorm (tvector a) { nr_double_t nMax = 0, n; - for (int i = 0; i < static_cast(a.size ()); i++) { + for (int i = 0; i < a.size (); i++) { n = norm (a.get (i)); if (n > nMax) nMax = n; } diff --git a/src/vector.cpp b/src/vector.cpp index 1cee20a5..1cc0c306 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -323,12 +323,7 @@ vector xhypot (vector v1, vector v2) { vector res (len); for (j = i = n = 0; n < len; n++) { res (n) = xhypot (v1 (i), v2 (j)); - if (++i >= len1) { - i = 0; - } - if (++j >= len2) { - j = 0; - } + if (++i >= len1) i = 0; if (++j >= len2) j = 0; } return res; } @@ -454,12 +449,7 @@ vector pow (vector v1, vector v2) { vector res (len); for (j = i = n = 0; n < len; n++) { res (n) = pow (v1 (i), v2 (j)); - if (++i >= len1) { - i = 0; - } - if (++j >= len2) { - j = 0; - } + if (++i >= len1) i = 0; if (++j >= len2) j = 0; } return res; } @@ -913,8 +903,7 @@ vector operator%(vector v1, vector v2) { vector res (len); for (j = i = n = 0; n < len; n++) { res (n) = v1 (i) % v2 (j); - if (++i >= len1) i = 0; - if (++j >= len2) j = 0; + if (++i >= len1) i = 0; if (++j >= len2) j = 0; } return res; } @@ -1179,12 +1168,7 @@ vector polar (vector a, vector p) { vector res (len); for (j = i = n = 0; n < len; n++) { res (n) = qucs::polar (a (i), p (j)); - if (++i >= len1) { - i = 0; - } - if (++j >= len2) { - j = 0; - } + if (++i >= len1) i = 0; if (++j >= len2) j = 0; } return res; } @@ -1215,12 +1199,7 @@ vector atan2 (vector y, vector x) { vector res (len); for (j = i = n = 0; n < len; n++) { res (n) = atan2 (y (i), x (j)); - if (++i >= len1) { - i = 0; - } - if (++j >= len2) { - j = 0; - } + if (++i >= len1) i = 0; if (++j >= len2) j = 0; } return res; } diff --git a/tests/basic/components/csv/qucs_csv.csv b/tests/basic/components/csv/qucs_csv.csv deleted file mode 100755 index 2a7c4755..00000000 --- a/tests/basic/components/csv/qucs_csv.csv +++ /dev/null @@ -1,3 +0,0 @@ -col1 col2 col3 -1,2,3 -4,5,6 diff --git a/tests/basic/components/spfile/bjt.cir b/tests/basic/components/spfile/bjt.cir deleted file mode 100644 index 60bc8e54..00000000 --- a/tests/basic/components/spfile/bjt.cir +++ /dev/null @@ -1,23 +0,0 @@ -.title dual rc ladder -* file name rcrcac.cir -*R1 int in 10k -*V1 in 0 dc 0 ac 1 PULSE (0 5 1u 1u 1u 1 1) -*R2 out int 1k -*C1 int 0 1u -*C2 out 0 100n - -Q3 A B C BJTNAME 1.0 -Q4 A B C D BJTNAME 2.0 -Q5 A B C D E BJTNAME 3.0 - -.MODEL BJTNAME NPN(BF=200 CJC=20pf CJE=20pf IS=1E-16) - -.plot dc 1 2 3 4 5 6 7 8 - -*.control -*ac dec 10 1 100k -*plot vdb(out) -*plot ph(out) -*.endc - -