25 #include "pips_config.h"
122 #define IS_QUOTED(c) (c>=256)
123 #define QUOTE(c) (c+256)
124 #define UNQUOTE(c) (IS_QUOTED(c) ? (c)-256 : (c))
134 #define FIRST_LINE 100
135 #define CONTINUATION_LINE 101
151 #define INITIAL_BUFFER_SIZE (128)
163 pips_debug(9,
"allocating comment buffers\n");
244 #define SIZE_UNDEF ((size_t) UNDEF)
278 size_t i=0, j=0, column=6;
279 char * tmp = (
char*)
malloc(
lStmt+200), * ndecls, * odecls;
282 for (; i<
lStmt; i++, j++, column++)
357 #define NONINQUOTES 1
359 #define INQUOTEQUOTE 3
360 #define INQUOTEBACKSLASH 4
477 static int FirstCall =
true;
478 char letcour, *keywcour;
485 for (i = 0; i < 26; i += 1)
491 while ((keywcour =
keywtbl[i].keywstr) != NULL) {
492 if (keywcour[0] != letcour) {
495 letcour = keywcour[0];
521 debug(9,
"IsCapKeyword",
"%s\n", s);
527 while ( (c = *s++) ) {
537 while ((kwcour =
keywtbl[i].keywstr)!=0 && kwcour[0]==
buffer[0]) {
538 if (strcmp(
buffer, kwcour) == 0) {
539 debug(9,
"IsCapKeyword",
"%s %d\n", kwcour, i);
547 user_warning(
"IsCapKeyword",
"[scanner] keyword expected near %s\n",
598 return((eof) ? EOF :
UNQUOTE(c));
618 static FILE * previous_fp = NULL;
626 if( previous_fp != fp ) {
634 "A parser error must have occured previously.\n");
641 int EmptyBuffer =
true;
642 int LineTooLong =
false;
643 bool first_column =
true;
644 bool in_comment =
false;
648 while ((c = getc(fp)) !=
'\n' && c != EOF) {
655 first_column =
false;
673 int nspace = 8-
col%8;
675 for (i = 0; i < nspace; i++) {
679 }
else if (c ==
'\r') {
685 if(
col > 72 && !LineTooLong && !in_comment &&
688 "Line %d truncated, col=%d and l_getchar=%d\n",
694 if(
col <= 72 || in_comment) {
708 "incomplete last line !!!\n");
715 debug(8,
"GetChar",
"An empty line has been detected\n");
731 "Input line after tab expansion is empty:\n");
735 "Input line after tab expansion l_getchar=%d, col=%d:\n",
742 (void) putc(
'\n', stderr);
767 static char QuoteChar =
'\000';
786 "Empty comment line detected at line %d "
787 "for comment starting at line %d\n",
806 for (i = 0; i < 5; i++) {
815 "non numeric character in label!\n");
822 label[ilabel] =
'\0';
875 while ((c =
GetChar(fp)) !=
'\n') {
876 if (c ==
'\'' || c ==
'"') {
969 "[scanner] incorrect continuation line as first line\n");
1023 for(i=0; i<
lStmt; i++)
1039 for (i = 0; i <
lStmt; i++) {
1041 if (parenthese == 0) {
1051 if(parenthese < 0) {
1052 for (i=0; i <
lStmt; i++)
1056 "unbalanced paranthesis (too many ')')\n"
1057 "Due to line truncation at column 72?\n");
1059 if(parenthese > 0) {
1060 for (i=0; i <
lStmt; i++)
1063 "unbalanced paranthesis (too many '(')\n"
1064 "Due to line truncation at column 72?\n");
1202 register size_t i =
iStmt+6;
1222 register size_t i =
iStmt;
1277 while (i < lStmt && parenthese > 0) {
1294 if (strlen(s) <=
lStmt-i) {
1301 result = (*s) ?
false : i;
1310 int l = i+strlen(s);
1312 if ((
size_t) l <=
lStmt) {
1322 "[scanner] internal error in CapitalizeStmt\n");
1337 while ((kwcour =
keywtbl[i].keywstr)!=0 &&
1347 ParserError(
"NeedKeyword",
"[scanner] keyword expected\n");
1376 if((c = getc(
syn_in))==(
int)
'\n') i++;
1377 pips_assert(
"The end of file cannot be reached", c!=EOF);
1383 if((c = getc(
syn_in))==(
int)
'\n') i++;
1384 pips_assert(
"The end of file cannot be reached", c!=EOF);
void const char const char const int
FILE * safe_fopen(const char *filename, const char *what)
int safe_fclose(FILE *stream, const char *filename)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
entity get_current_module_entity(void)
Get the entity of the current module.
static struct Skeyword keywtbl[]
CE FICHIER A ETE GENERE AUTOMATIQUEMENT.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define user_warning(fn,...)
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
string concatenate(const char *,...)
Return the concatenation of the given strings.
int PipsGetc(FILE *fp)
Routine de lecture pour l'analyseur lexical, lex ou flex.
static int * getchar_buffer
int IsCapKeyword(char *s)
Fonction appelee par sslex sur la reduction de la regle de reconnaissance des mot clefs.
static void init_line_buffer(void)
static size_t iStmt
indexes in the buffer...
int ReadLine(FILE *fp)
All physical lines of a statement are put together in a unique buffer called "line_buffer".
#define CONTINUATION_LINE
static bool parser_warn_for_columns_73_80
memoization des properties
#define INITIAL_BUFFER_SIZE
Comm contains the comments for the current statement in ReadStmt().
static void init_comment_buffers(void)
lazy initialization of the comment buffer
void dump_current_statement()
static int line_buffer_size
static char * OperateurPoints[]
La table des operateurs du type '.XX.
int line_b_I
Indicates where the current instruction (in fact statement) starts and ends in the input file and giv...
static void resize_comment_buffers(void)
static int keywidx[26]
Une table pour accelerer les recherche des keywords.
size_t FindMatchingPar(size_t i)
static int tmp_b_I
Variables qui serviront a mettre a jour les numeros de la premiere et de la derniere ligne de comment...
static int * stmt_buffer
le buffer contenant le statement courant, l'indice courant et la longueur.
void parser_reset_all_reader_buffers(void)
static size_t stmt_buffer_size
int get_statement_number()
eturn the line number of the statement being parsed
void ScanNewFile(void)
La fonction a appeler pour l'analyse d'un nouveau fichier.
int CapitalizeStmt(char s[], int i)
static void init_getchar_buffer(void)
number of elements in the array
int StmtEqualString(char *s, int i)
void append_data_current_stmt_buffer_to_declarations(void)
static void init_stmt_buffer(void)
int ReadStmt(FILE *fp)
regroupement des lignes du statement en une unique ligne sans continuation
void init_parser_reader_properties()
int FindDoWhile(void)
This function is redundant with FindDo() but much easier to understand.
static void resize_getchar_buffer(void)
int GetChar(FILE *fp)
Routine de lecture physique.
static int * line_buffer
le buffer contenant la ligne que l'on doit lire en avance pour se rendre compte qu'on a finit de lire...
static void resize_line_buffer(void)
static void resize_stmt_buffer(void)
static int getchar_buffer_size
size_t FindProfZero(int c)
code EntityCode(entity e)
this function checks that e has an initial value code.
#define code_decls_text(x)
FILE * syn_in
lex yacc interface
#define START_COMMENT_LINE
Legal characters to start a comment line.
char * CurrentFN
Pre-parser for Fortran syntax idiosyncrasy.
bool ParserError(const char *f, const char *m)