1 #include <portability.h>
95 FILE *already_opened_file) {
105 lsf->
file = already_opened_file;
121 print (thisAgent,
"Internal error: tried to stop_lex_from_file at top level\n");
193 "lexer.c: Error: line too long (max allowed is %d chars)\nFile %s, line %llu\n",
212 assert(0 &&
"error in lexer.cpp (control_c_handler() used to be called here)");
215 print (thisAgent,
"I/O error while reading file %s; ignoring the rest of it.\n",
295 for (i=0;i<=len;i++) {
298 for (i=5;i<=len;i++) {
308 Bool possible_id, possible_var, possible_sc, possible_ic, possible_fc;
330 print (thisAgent,
"Error: bad integer (probably too large)\n");
342 print (thisAgent,
"Error: bad floating point number\n");
351 unsigned lti_index = 0;
360 print (thisAgent,
"Error: bad number for identifier (probably too large)\n");
374 print (thisAgent,
"Warning: Suspicious string constant \"%s\"\n", thisAgent->
lexeme.
string);
406 #define lu lex_unknown
413 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
414 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
415 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
416 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
417 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
418 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
419 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
420 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
421 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
422 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
423 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
424 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
425 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
426 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
427 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
428 lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
lu,
561 Bool could_be_floating_point;
567 could_be_floating_point =
TRUE;
580 Bool could_be_floating_point;
586 could_be_floating_point =
TRUE;
601 Bool could_be_floating_point;
607 could_be_floating_point =
TRUE;
619 print (thisAgent,
"Error: Unknown character encountered by lexer, code=%d\n",
645 print (thisAgent,
"Error: opening '|' without closing '|'\n");
674 print (thisAgent,
"Error: opening '\"' without closing '\"'\n");
863 static bool initialized =
false;
872 char extra_constituents[] =
"$%&*+-/:<=>?_@";
873 for (i=0; i<256; i++)
880 if((strchr(extra_constituents, i) != 0) && i != 0)
896 for (i=0; i<256; i++)
902 for (i=0; i<256; i++)
929 for (i=0; i<256; i++)
1083 int parentheses_level) {
1136 *possible_id =
FALSE;
1137 *possible_var =
FALSE;
1138 *possible_sc =
FALSE;
1139 *possible_ic =
FALSE;
1140 *possible_fc =
FALSE;
1141 *rereadable =
FALSE;
1146 if ((*ch==
'+')||(*ch==
'-'))
1148 while (isdigit(*ch))
1150 if ((*ch==0)&&(isdigit(*(ch-1))))
1151 *possible_ic =
TRUE;
1154 while (isdigit(*ch))
1156 if ((*ch==
'e')||(*ch==
'E')) {
1158 if ((*ch==
'+')||(*ch==
'-'))
1160 while (isdigit(*ch))
1164 *possible_fc =
TRUE;
1169 for (ch=s; *ch!=0; ch++)
1174 all_alphanum =
TRUE;
1175 for (ch=s; *ch!=
'\0'; ch++) {
1176 if (!isalnum(*ch)) {
1177 all_alphanum =
FALSE;
1181 if ( all_alphanum ||
1183 ((length_of_s==1)&&(*s==
'*')) )
1189 *possible_sc =
TRUE;
1192 if ((*s==
'<')&&(*(s+length_of_s-1)==
'>'))
1193 *possible_var =
TRUE;
1202 if (isalpha(*ch) && *(++ch) !=
'\0') {
1204 while (isdigit(*ch))
1207 *possible_id =
TRUE;