/* Implementation of Fortran lexer
- Copyright (C) 1995-1998 Free Software Foundation, Inc.
- Contributed by James Craig Burley (burley@gnu.org).
+ Copyright (C) 1995, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ Contributed by James Craig Burley.
This file is part of GNU Fortran.
#include "lex.h"
#include "malloc.h"
#include "src.h"
+#include "debug.h"
#if FFECOM_targetCURRENT == FFECOM_targetGCC
-#include "flags.j"
-#include "input.j"
-#include "toplev.j"
-#include "tree.j"
-#include "output.j" /* Must follow tree.j so TREE_CODE is defined! */
+#include "flags.h"
+#include "input.h"
+#include "toplev.h"
+#include "output.h"
+#include "ggc.h"
#endif
-#ifdef DWARF_DEBUGGING_INFO
-void dwarfout_resume_previous_source_file (register unsigned);
-void dwarfout_start_new_source_file (register char *);
-void dwarfout_define (register unsigned, register char *);
-void dwarfout_undef (register unsigned, register char *);
-#endif DWARF_DEBUGGING_INFO
-
static void ffelex_append_to_token_ (char c);
static int ffelex_backslash_ (int c, ffewhereColumnNumber col);
static void ffelex_bad_1_ (ffebad errnum, ffewhereLineNumber ln0,
case EOF:
case '\n':
- fatal ("Badly formed directive -- no closing quote");
+ error ("Badly formed directive -- no closing quote");
done = TRUE;
break;
#if FFECOM_targetCURRENT == FFECOM_targetGCC
static void
-ffelex_file_pop_ (char *input_filename)
+ffelex_file_pop_ (const char *input_filename)
{
if (input_file_stack->next)
{
input_file_stack = p->next;
free (p);
input_file_stack_tick++;
-#ifdef DWARF_DEBUGGING_INFO
- if (debug_info_level == DINFO_LEVEL_VERBOSE
- && write_symbols == DWARF_DEBUG)
- dwarfout_resume_previous_source_file (input_file_stack->line);
-#endif /* DWARF_DEBUGGING_INFO */
+ if (write_symbols == DWARF_DEBUG)
+ (*debug_hooks->end_source_file) (input_file_stack->line);
}
else
error ("#-lines for entering and leaving files don't match");
#endif
#if FFECOM_targetCURRENT == FFECOM_targetGCC
static void
-ffelex_file_push_ (int old_lineno, char *input_filename)
+ffelex_file_push_ (int old_lineno, const char *input_filename)
{
struct file_stack *p
= (struct file_stack *) xmalloc (sizeof (struct file_stack));
p->name = input_filename;
input_file_stack = p;
input_file_stack_tick++;
-#ifdef DWARF_DEBUGGING_INFO
- if (debug_info_level == DINFO_LEVEL_VERBOSE
- && write_symbols == DWARF_DEBUG)
- dwarfout_start_new_source_file (input_filename);
-#endif /* DWARF_DEBUGGING_INFO */
+
+ if (write_symbols == DWARF_DEBUG)
+ (*debug_hooks->start_source_file) (0, input_filename);
/* Now that we've pushed or popped the input stack,
update the name in the top element. */
|| c == EOF)
{
if (looking_for != 0)
- fatal ("Bad directive -- missing close-quote");
+ error ("Bad directive -- missing close-quote");
*p++ = '\0';
*text = directive_buffer;
static char buffer [128];
char * buff = buffer;
- /* Read the pragma name into a buffer. */
- while (isspace (c = getc (finput)))
+ /* Read the pragma name into a buffer.
+ ISSPACE() may evaluate its argument more than once! */
+ while (((c = getc (finput)), ISSPACE(c)))
continue;
do
* buff ++ = c;
c = getc (finput);
}
- while (c != EOF && ! isspace (c) && c != '\n'
+ while (c != EOF && ! ISSPACE (c) && c != '\n'
&& buff < buffer + 128);
pragma_ungetc (c);
c = ffelex_get_directive_line_ (&text, finput);
-#ifdef DWARF_DEBUGGING_INFO
if ((debug_info_level == DINFO_LEVEL_VERBOSE)
&& (write_symbols == DWARF_DEBUG))
- dwarfout_define (lineno, text);
-#endif /* DWARF_DEBUGGING_INFO */
+ (*debug_hooks->define) (lineno, text);
goto skipline;
}
c = ffelex_get_directive_line_ (&text, finput);
-#ifdef DWARF_DEBUGGING_INFO
if ((debug_info_level == DINFO_LEVEL_VERBOSE)
&& (write_symbols == DWARF_DEBUG))
- dwarfout_undef (lineno, text);
-#endif /* DWARF_DEBUGGING_INFO */
+ (*debug_hooks->undef) (lineno, text);
goto skipline;
}
&& getc (finput) == 't'
&& ((c = getc (finput)) == ' ' || c == '\t'))
{
- /* #ident. The pedantic warning is now in cccp.c. */
+ /* #ident. The pedantic warning is now in cpp. */
/* Here we have just seen `#ident '.
A string constant should follow. */
&& (ffelex_token_type (token) == FFELEX_typeNUMBER))
{
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
ffewhereFile wf;
/* subtract one, because it is the following line that
lineno = l;
if (ffelex_kludge_flag_)
- input_filename = ffelex_token_text (token);
+ input_filename = ggc_strdup (ffelex_token_text (token));
else
{
wf = ffewhere_file_new (ffelex_token_text (token),
{
lineno = 1;
input_filename = old_input_filename;
- fatal ("Use `#line ...' instead of `# ...' in first line");
+ error ("Use `#line ...' instead of `# ...' in first line");
}
if (num == 1)
{
lineno = 1;
input_filename = old_input_filename;
- fatal ("Use `#line ...' instead of `# ...' in first line");
+ error ("Use `#line ...' instead of `# ...' in first line");
+ }
+ if (c == '\n' || c == EOF)
+ {
+ if (token != NULL && !ffelex_kludge_flag_)
+ ffelex_token_kill (token);
+ return c;
}
}
else
= ffewhere_line_filelinenum (current_wl);
#if FFECOM_targetCURRENT == FFECOM_targetGCC
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
#endif
if (card_length != 0)
return t;
}
-static char *
+static const char *
ffelex_type_string_ (ffelexType type)
{
- static char *types[] = {
+ static const char *types[] = {
"FFELEX_typeNONE",
"FFELEX_typeCOMMENT",
"FFELEX_typeEOS",
/* Make a new CHARACTER token. */
ffelexToken
-ffelex_token_new_character (char *s, ffewhereLine l, ffewhereColumn c)
+ffelex_token_new_character (const char *s, ffewhereLine l, ffewhereColumn c)
{
ffelexToken t;
/* Make a new NAME token. */
ffelexToken
-ffelex_token_new_name (char *s, ffewhereLine l, ffewhereColumn c)
+ffelex_token_new_name (const char *s, ffewhereLine l, ffewhereColumn c)
{
ffelexToken t;
/* Make a new NAMES token. */
ffelexToken
-ffelex_token_new_names (char *s, ffewhereLine l, ffewhereColumn c)
+ffelex_token_new_names (const char *s, ffewhereLine l, ffewhereColumn c)
{
ffelexToken t;
in the original string. */
ffelexToken
-ffelex_token_new_number (char *s, ffewhereLine l, ffewhereColumn c)
+ffelex_token_new_number (const char *s, ffewhereLine l, ffewhereColumn c)
{
ffelexToken t;
ffeTokenLength len;