48 char *s = (
char*) NULL;
49 char *t = (
char*) NULL;
58 (void) fprintf(
STDERR,
" the sampling frequency <fs> defined in NAPA netlist\n");
60 (void) fprintf(
STDERR,
" will be superseded by user input at execution\n\n");
68 (void) fprintf(
STDERR,
" the sampling period <ts> defined in NAPA netlist\n");
70 (void) fprintf(
STDERR,
" will be superseded by user input at execution\n\n");
80 (void) strcpy(tok2,
Var_List[nv].value);
85#if (IS_WIN64 == PLATFORM)
89 if (0 == strcmp(s, t)) {
91 (void) fprintf(
STDERR,
" String parameter <%s> was used during the compilation of a NAPA cell.\n",
Cmdline_List[i].parms);
92 (void) fprintf(
STDERR,
" Its value is currently set to <%s>.\n",
Var_List[nv].value);
93 (void) fprintf(
STDERR,
" It cannot be redefined at execution and therefore cannot be a command line parameter.\n");
101 (void) fprintf(
STDERR,
" <%s>, being a variable of the command line, cannot be an event\n",
Cmdline_List[i].parms);
104 (void) fprintf(
STDERR,
" <%s>, being a variable of the command line, cannot be updated\n",
Cmdline_List[i].parms);
115 char *s = (
char*) NULL;
126 (void) fprintf(
STDERR,
" <%s>, a node cannot be used in a directive\n", tok );
130 (void) fprintf(
STDERR,
" <%s>, a variable cannot be used in a directive\n", tok);
149 (void) fprintf(
STDERR,
"\n No sampling frequency definition in netlist...\n");
163 char *s = (
char*) NULL;
164 char *str1 = (
char*) NULL;
165 char *str2 = (
char*) NULL;
169 char sgn[2] = {
'\0'};
170 char brck[3] = {
'\0'};
171 char *tg = (
char*) NULL;
172 unsigned long *ml = (
unsigned long*) NULL;
173 unsigned long *mf = (
unsigned long*) NULL;
344 if (0 == strcmp(tok1,
"\"\"")) {
346 (void) fprintf(
STDERR,
" pattern descriptor is empty\n");
440 (void) fprintf(
STDERR,
" this platform (%s) does not support sign extension on right shifts!\n",
MACHINE);
512 if (((
char*) NULL == strstr(
Node_List[out].option,
"none")) && ((
char*) NULL == strstr(
Node_List[out].option,
"nocheck"))) {
515 (void) fprintf(
STDERR,
" (%s) is not a valid trigger qualifier\n\n",
Node_List[out].option);
516 (void) fprintf(
STDERR,
" optional valid qualifier is (nocheck)\n");
567 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
575 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
588 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
596 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
599 if (((
char*) NULL == strstr(
Node_List[out].option,
"arithmetic"))
600 && ((
char*) NULL == strstr(
Node_List[out].option,
"geometric" ))
601 && ((
char*) NULL == strstr(
Node_List[out].option,
"harmonic" ))
602 && ((
char*) NULL == strstr(
Node_List[out].option,
"rms" ))) {
604 (void) fprintf(
STDERR,
" (%s) is not a valid qualifier for node 'average'\n\n",
Node_List[out].option);
605 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
606 (void) fprintf(
STDERR,
" (arithmetic)\n");
607 (void) fprintf(
STDERR,
" (geometric)\n");
608 (void) fprintf(
STDERR,
" (harmonic)\n");
609 (void) fprintf(
STDERR,
" (rms)\n");
623 (void) snprintf(msg, (
size_t) 31,
"parameter #%ld", i+1L);
631 (void) fprintf(
STDERR,
" input node is missing\n");
636 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
644 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
665 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
673 (void) fprintf(
STDERR,
" at least one input node is required\n");
733 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
741 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
756 (void) fprintf(
STDERR,
" input node or mask is missing\n");
769 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
777 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
805 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
813 (void) fprintf(
STDERR,
" at least two input nodes are required\n");
827 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
835 (void) fprintf(
STDERR,
" two input nodes are required\n");
910 (void) fprintf(
STDERR,
" at least one of the inputs #1 or #2 must be a node\n");
932 (void) fprintf(
STDERR,
" at least one of the inputs #1 or #2 must be a node\n");
935 if (0 == strcmp(str1,
"")) {
1001 if (0 == strcmp(tok1,
"void")) {
1007 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
1015 (void) fprintf(
STDERR,
" at least two input nodes are requested\n");
1029 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
1037 (void) fprintf(
STDERR,
" at least two input nodes are requested\n");
1053 if (((
char*) NULL == strstr(
Node_List[out].option,
"dual"))
1054 && ((
char*) NULL == strstr(
Node_List[out].option,
"positive"))
1055 && ((
char*) NULL == strstr(
Node_List[out].option,
"negative"))) {
1058 (void) fprintf(
STDERR,
" (%s) is not a valid trigger qualifier\n\n",
Node_List[out].option);
1059 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
1060 (void) fprintf(
STDERR,
" (negative)\n");
1061 (void) fprintf(
STDERR,
" (positive)\n");
1062 (void) fprintf(
STDERR,
" (dual)\n");
1092 if (((
char*) NULL == strstr(
Node_List[out].option,
"dual" ))
1093 && ((
char*) NULL == strstr(
Node_List[out].option,
"both" ))
1094 && ((
char*) NULL == strstr(
Node_List[out].option,
"positive"))
1095 && ((
char*) NULL == strstr(
Node_List[out].option,
"negative"))) {
1097 (void) fprintf(
STDERR,
" (%s) is not a valid qualifier for node 'change'\n\n",
Node_List[out].option);
1098 (void) fprintf(
STDERR,
" valid qualifiers are:\n");
1099 (void) fprintf(
STDERR,
" (dual)\n");
1100 (void) fprintf(
STDERR,
" (both)\n");
1101 (void) fprintf(
STDERR,
" (positive)\n");
1102 (void) fprintf(
STDERR,
" (negative)\n");
1128 (void) snprintf(msg, (
size_t) 31,
"input #%ld", i+1L);
1136 (void) fprintf(
STDERR,
" at least two inputs are required\n");
1154 (void) fprintf(
STDERR,
" at least two inputs are required\n");
1159 for (i = 0L; i < n-1L; i++) {
1161 (void) snprintf(msg, (
size_t) 31,
"coefficient of x^%ld", i);
1182 (void) fprintf(
STDERR,
" the array <%s[]> is not a ROM but an array of pointers\n", tok1);
1189 (void) fprintf(
STDERR,
" ROM array <%s[]> is not declared\n", tok1);
1196 (void) fprintf(
STDERR,
" the array <%s[]> is already used as a RAM\n", tok1);
1202 (void) fprintf(
STDERR,
" ROM <%s[]> port definitions are not consistent (single or dual port?)\n", tok1);
1210 (void) fprintf(
STDERR,
" <%s[]>: single-port ROM cannot be used as a dual port ROM\n", tok1);
1218 (void) fprintf(
STDERR,
" address of ROM <%s[]> is not correct\n", tok1);
1244 (void) fprintf(
STDERR,
" the array <%s[]> is not a RAM but an array of pointers\n", tok1);
1251 (void) fprintf(
STDERR,
" RAM array <%s[]> is not declared\n", tok1);
1258 (void) fprintf(
STDERR,
" the array <%s[]> is already used as a ROM\n", tok1);
1264 (void) fprintf(
STDERR,
" RAM <%s[]> port definitions are not consistent (single or dual port?)\n", tok1);
1272 (void) fprintf(
STDERR,
" <%s[]>: single-port RAM cannot be used as a dual port RAM\n", tok1);
1279 (void) fprintf(
STDERR,
" address node of RAM <%s[]> is not correct\n", tok1);
1318 (void) fprintf(
STDERR,
" <%s[]> is declared as a memory array, arrays of \n", tok1);
1319 (void) fprintf(
STDERR,
" pointers are the only arrays allowed as parameters\n" );
1340 (void) fprintf(
STDERR,
" <%s[]> is declared as a memory array, arrays of\n", tok1);
1341 (void) fprintf(
STDERR,
" pointers are the only arrays allowed as parameters\n");
1350 (void) fprintf(
STDERR,
" node kind is not recognized\n");
1364 char *s = (
char*) NULL;
1365 char *t = (
char*) NULL;
1366 char sgn[2] = {
'\0'};
1373 if ((0 == strcmp(sgn,
"-")) || (0 == strcmp(sgn,
"+"))) {
1376 (void) fprintf(
STDERR,
" no sign is allowed in the list of parameters of a record\n");
1382 t = strstr(tok,
"::");
1383 if ((
char*) NULL != t) {
1384 (void) strcpy(tok, t+2);
1392 (void) fprintf(
STDERR,
" <%s> is not an array of pointers, a variable, a node identifier, a number nor a string\n", tok);
1406 (void) fprintf(
STDERR,
" the actual number #%ld of parameters is not compatible with declaration\n", j);
1416 char *str = (
char*) NULL;
1426 if (0 == strcmp(tok,
"when")) {
1428 (void) fprintf(
STDERR,
" keyword 'when' is not allowed in a drop statement\n");
1442 char *str = (
char*) NULL;
1448 if (0 == strcmp(tok,
"when")) {
1450 (void) fprintf(
STDERR,
" keyword 'when' is not allowed in a terminate statement\n");
1465 char *str = (
char*) NULL;
1467 unsigned long *ml = (
unsigned long*) NULL;
1468 unsigned long *mf = (
unsigned long*) NULL;
1476 if (0 == strcmp(
Var_List[v].value,
"void")) {
1478 (void) fprintf(
STDERR,
" the variable <%s> has been defined as (void) and cannot be updated\n",
Update_List[out].name);
1491 (void) fprintf(
STDERR,
" array of pointers, here <%s>, cannot be used",
Record_List[m].name);
1492 (void) fprintf(
STDERR,
" in the update of variable <%s>\n",
Update_List[out].name);
1497 (void) fprintf(
STDERR,
" arrays, here <%s>, cannot be used",
Array_List[m].name);
1498 (void) fprintf(
STDERR,
" in the update of variable <%s>\n",
Update_List[out].name);
1510 char *str = (
char*) NULL;
1512 unsigned long *ml = (
unsigned long*) NULL;
1513 unsigned long *mf = (
unsigned long*) NULL;
1514 for (out = 0L; out <
Num_Vars; out++) {
1530 (void) fprintf(
STDERR,
" definition of the variable cannot be a string <%s>\n", str);
1543 (void) fprintf(
STDERR,
" array of pointers <%s> cannot be used",
Record_List[m].name);
1544 (void) fprintf(
STDERR,
" in the definition of variable <%s>\n",
Var_List[out].name1);
1561long check_syntax(
long to_be,
long no_sign,
const char *sgn,
char *tok,
long id,
const char *txt) {
1564 unsigned long *ml = (
unsigned long*) NULL;
1565 unsigned long *mf = (
unsigned long*) NULL;
1566 char *tg = (
char*) NULL;
1575 not_to_be = (int) (((0L == to_be)) & 15L) ? 1L : 0L;
1578 (void) fprintf(
STDERR,
" %s is missing\n", txt);
1584 (void) fprintf(
STDERR,
" %s <%s> cannot be a node\n", txt, tok);
1590 (void) fprintf(
STDERR,
" %s <%s> cannot be a variable\n", txt, tok);
1597 (void) fprintf(
STDERR,
" %s <%s> cannot be a constant number\n", txt, tok);
1601 if (((0 == strcmp(sgn,
"-")) || (0 == strcmp(sgn,
"+"))) && (
NOSIGN == no_sign) && (0 ==
is_node_flagged(
id))) {
1603 (void) fprintf(
STDERR,
" %s <%s> cannot be signed\n", txt, tok);
1609 (void) fprintf(
STDERR,
" %s <%s> is invalid as it is declared as array\n", txt, tok);
1615 (void) fprintf(
STDERR,
" %s <%s> is invalid as it is declared as opcode\n", txt, tok);
1636 (void) fprintf(
STDERR,
" %s <%s> must be", txt, tok);
1637 if (0 != (to_be &
NODE)) {
1638 (void) fprintf(
STDERR,
" a node");
1642 if (0 != (to_be &
NODE)) {
1643 (void) fprintf(
STDERR,
" or");
1645 (void) fprintf(
STDERR,
" a variable");
1648 if (0 != (to_be &
NUMBER)) {
1649 if ((0 != (to_be &
NODE)) || (0 != (to_be &
VARIABLE))) {
1650 (void) fprintf(
STDERR,
" or");
1652 (void) fprintf(
STDERR,
" a constant number");
1654 if (0 != (to_be &
STRING)) {
1656 (void) fprintf(
STDERR,
" or");
1658 (void) fprintf(
STDERR,
" a string");
1660 (void) fprintf(
STDERR,
"\n");
1676 char *tg = (
char*) NULL;
1677 char *str = (
char*) NULL;
1679 char sgn[3] = {
'\0'};
1680 unsigned long *ml = (
unsigned long*) NULL;
1681 unsigned long *mf = (
unsigned long*) NULL;
1699 (void) fprintf(
STDERR,
" no qualifier is expected for this node,\n");
1700 (void) fprintf(
STDERR,
" current qualifier list is ");
1707 (void) fprintf(
STDERR,
"(%s) ", tok);
1709 (void) fprintf(
STDERR,
"\n");
1715 (void) fprintf(
STDERR,
" up to %ld qualifier is expected for this node,\n", num);
1717 (void) fprintf(
STDERR,
" up to %ld qualifiers are expected for this node,\n", num);
1719 (void) fprintf(
STDERR,
" current qualifier list is ");
1726 (void) fprintf(
STDERR,
"(%s) ", tok);
1728 (void) fprintf(
STDERR,
"\n");
1738 char *tg = (
char*) NULL;
1739 unsigned long *ml = (
unsigned long*) NULL;
1740 unsigned long *mf = (
unsigned long*) NULL;
1746 (void) fprintf(
STDERR,
" unexpected text appears at the end of node definition: <%s>\n", tok);
1758void sanity_check(
char *s,
const unsigned long *mlin,
const unsigned long *mfil) {
1759 char *t = (
char*) NULL;
1767 while ((isspace((
int) *t)) && (
'\0' != *t)) {
1775 while (
'\0' != *t) {
1777 dq = (1L == dq) ? 0L : 1L;
1779 if ((t > s) && (
'/' == *t) && (
'/' == *(t-1)) && (0L == dq)) {
1782 if (((t > s) && (
'+' == *(t-1)) && (
'+' == *t)) || ((t > s) && (
'-' == *(t-1)) && (
'-' == *t))) {
1785 (void) fprintf(
STDERR,
" Sorry!To avoid side effects, ANSI-C operator %c%c\n", *(t-1), *t);
1786 (void) fprintf(
STDERR,
" cannot be used explicitely in the NAPA netlist description\n");
1790 if (((t > s) && (
'+' == *(t-1)) && (
'=' == *t)) || ((t > s) && (
'-' == *(t-1)) && (
'=' == *t))
1791 || ((t > s) && (
'*' == *(t-1)) && (
'=' == *t)) || ((t > s) && (
'/' == *(t-1)) && (
'=' == *t))
1792 || ((t > s) && (
'%' == *(t-1)) && (
'=' == *t)) || ((t > s) && (
'&' == *(t-1)) && (
'=' == *t))
1793 || ((t > s) && (
'|' == *(t-1)) && (
'=' == *t)) || ((t > s) && (
'^' == *(t-1)) && (
'=' == *t))) {
1796 (void) fprintf(
STDERR,
" Sorry!To avoid side effects, ANSI-C assignation %c%c\n", *(t-1), *t);
1797 (void) fprintf(
STDERR,
" cannot be used explicitely in the NAPA netlist description\n");
1801 if ((
'\'' == *t) && (0 == dq)) {
1803 }
else if (
'"' == *t) {
1806 if ((0L == (c0 % 2L)) && (0L == (c1 % 2L))) {
1815 (void) fprintf(
STDERR,
" unmatched closing parenthesis in <%s> ?\n", s);
1816 (void) fprintf(
STDERR,
" %*s^\n", (
int)
ABS(t-s),
" ");
1827 (void) fprintf(
STDERR,
" unmatched closing bracket in <%s> ?\n", s);
1828 (void) fprintf(
STDERR,
" %*s^\n", (
int)
ABS(t-s),
" ");
1839 (void) fprintf(
STDERR,
" unmatched closing curly bracket in <%s> ?\n", s);
1850 if (0L != (c0 % 2L)) {
1852 (void) fprintf(
STDERR,
" unmatched single quote in C expression <%s> ?\n", s);
1855 if (0L != (c1 % 2L)) {
1857 (void) fprintf(
STDERR,
" unmatched double quote in C expression <%s> ?\n", s);
1862 (void) fprintf(
STDERR,
" missing closing parenthesis in C expression <%s> ?\n", s);
1867 (void) fprintf(
STDERR,
" unmatched opening parenthesis in C expression <%s> ?\n", s);
1872 (void) fprintf(
STDERR,
" missing closing rectangular bracket in C expression <%s> ?\n", s);
1877 (void) fprintf(
STDERR,
" unmatched opening rectangular bracket in C expression <%s> ?\n", s);
1882 (void) fprintf(
STDERR,
" missing closing curly bracket in C expression <%s> ?\n", s);
1887 (void) fprintf(
STDERR,
" unmatched curly bracket in C expression <%s> ?\n", s);
1897 static int flag =
false;
1898 char* s = (
char*) NULL;
1901 while (
'\0' != *(s+1)) {
1902 if (
'=' == *(s+1)) {
1903 if ((
'=' == *s) || (
'!' == *s) || (
'>' == *s) || (
'<' == *s)) {
1907 if (
'=' == *(s+2)) {
1910 }
else if ((
'>' == *(s+2)) || (
'<' == *(s+2)) || (
'!' == *(s+2))) {
1912 (void) fprintf(
STDERR,
" no assignation is expected in expression ' %s '\n", str);
1921 (void) fprintf(
STDERR,
" no assignation is expected in expression ' %s '\n", str);
void print_location(const unsigned long *mlin, const unsigned long *mfil)
void print_warning_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
long constant_type(char *identifier)
long get_type(char *identifier)
long update_id(const char *identifier, long num)
long array_id(const char *identifier)
long op_id(const char *identifier)
long node_id(const char *identifier)
long var_id(const char *identifier)
int is_node_flagged(long num)
long record_id(const char *identifier)
void process_array_error(const char *tok1)
void process_record_error(const char *tok1)
void process_node_error(const char *tok1)
void process_variable_error(const char *tok1)
#define DROP_SEGMENT_TYPE
EXTERN VAR_TYPE Var_List[2047L]
EXTERN RECORD_TYPE Record_List[127L]
EXTERN ARRAY_TYPE Array_List[63L]
EXTERN NODE_TYPE Node_List[4095L]
#define DIFFERENTIATOR_KIND
EXTERN SAMPLING_TYPE Sampling_List
EXTERN char * Record_Cell_File_Table[511L]
EXTERN DIRECTIVE_TYPE Directive_List[255L]
EXTERN long Num_Directives
EXTERN long Num_FileCells
EXTERN CMDLINE_TYPE Cmdline_List[63L]
EXTERN int Terminate_Flag
EXTERN TERMINATE_TYPE Terminate_List
EXTERN SEGMENT_TYPE Segment_List[127L]
#define DIGITAL_DATA_TYPE
EXTERN UPDATE_TYPE Update_List[2047L]
void print_error_banner_and_exit(void)
char * upper_to_lower(char *s)
char * get_token(char *str, char *tok, long keep_quotes)
int is_a_string(char *str)
int is_an_identifier(const char *tok)
void strip_quotes(char *str)
void replace_dollar(char *tok)
char * get_token_between_braces(char *str, char *brc, char *tok)
char * get_sign_and_token(char *str, char *sgn, char *tok)
void syntax_command_line(void)
void authorize_option(long num, long id)
void syntax_updates(void)
void syntax_directives(void)
void syntax_variables(void)
void sanity_check(char *s, const unsigned long *mlin, const unsigned long *mfil)
void syntax_records(void)
long check_syntax(long to_be, long no_sign, const char *sgn, char *tok, long id, const char *txt)
void syntax_terminate(void)
long something_else(const char *tok, long id)
void syntax_segment_value(void)
void C_syntax_checker(char *str, const unsigned long *mlin, const unsigned long *mfil)