/* Parser grammar for quick source code scan of Java(TM) language programs.
- Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
+along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
#include "config.h"
#include "system.h"
-
+#include "coretypes.h"
+#include "tm.h"
+#include "input.h"
#include "obstack.h"
#include "toplev.h"
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-extern char *input_filename;
extern FILE *finput, *out;
+
+/* Current position in real source file. */
+
+location_t input_location;
/* Obstack for the lexer. */
struct obstack temporary_obstack;
/* The current parser context. */
-static struct parser_ctxt *ctxp;
+struct parser_ctxt *ctxp;
-/* Error and warning counts, current line number, because they're used
- elsewhere */
+/* Error and warning counts, because they're used elsewhere */
int java_error_count;
int java_warning_count;
-int lineno;
/* Tweak default rules when necessary. */
static int absorber;
};
#define NEW_METHOD_DECLARATOR(D,N,A) \
{ \
- (D) = \
- (struct method_declarator *)xmalloc (sizeof (struct method_declarator)); \
+ (D) = xmalloc (sizeof (struct method_declarator)); \
(D)->method_name = (N); \
(D)->args = (A); \
}
/* Two actions for this grammar */
-static int make_class_name_recursive PARAMS ((struct obstack *stack,
- struct class_context *ctx));
-static char *get_class_name PARAMS ((void));
-static void report_class_declaration PARAMS ((const char *));
-static void report_main_declaration PARAMS ((struct method_declarator *));
-static void push_class_context PARAMS ((const char *));
-static void pop_class_context PARAMS ((void));
+static int make_class_name_recursive (struct obstack *stack,
+ struct class_context *ctx);
+static char *get_class_name (void);
+static void report_class_declaration (const char *);
+static void report_main_declaration (struct method_declarator *);
+static void push_class_context (const char *);
+static void pop_class_context (void);
-void report PARAMS ((void));
+void report (void);
#include "lex.h"
#include "parse.h"
}
%{
+extern int flag_assert;
+
#include "lex.c"
%}
/* Create a new parser context */
void
-java_push_parser_context ()
+java_push_parser_context (void)
{
- struct parser_ctxt *new =
- (struct parser_ctxt *) xcalloc (1, sizeof (struct parser_ctxt));
+ struct parser_ctxt *new = xcalloc (1, sizeof (struct parser_ctxt));
new->next = ctxp;
ctxp = new;
}
static void
-push_class_context (name)
- const char *name;
+push_class_context (const char *name)
{
struct class_context *ctx;
- ctx = (struct class_context *) xmalloc (sizeof (struct class_context));
+ ctx = xmalloc (sizeof (struct class_context));
ctx->name = (char *) name;
ctx->next = current_class_context;
current_class_context = ctx;
}
static void
-pop_class_context ()
+pop_class_context (void)
{
struct class_context *ctx;
/* Recursively construct the class name. This is just a helper
function for get_class_name(). */
static int
-make_class_name_recursive (stack, ctx)
- struct obstack *stack;
- struct class_context *ctx;
+make_class_name_recursive (struct obstack *stack, struct class_context *ctx)
{
if (! ctx)
return 0;
/* Return a newly allocated string holding the name of the class. */
static char *
-get_class_name ()
+get_class_name (void)
{
char *result;
int last_was_digit;
/* Actions defined here */
static void
-report_class_declaration (name)
- const char * name;
+report_class_declaration (const char * name)
{
extern int flag_dump_class, flag_list_filename;
}
static void
-report_main_declaration (declarator)
- struct method_declarator *declarator;
+report_main_declaration (struct method_declarator *declarator)
{
extern int flag_find_main;
}
void
-report ()
+report (void)
{
extern int flag_complexity;
if (flag_complexity)
/* Reset global status used by the report functions. */
-void reset_report ()
+void reset_report (void)
{
previous_output = 0;
package_name = NULL;
}
void
-yyerror (msg)
- const char *msg ATTRIBUTE_UNUSED;
+yyerror (const char *msg ATTRIBUTE_UNUSED)
{
- fprintf (stderr, "%s: %d: %s\n", input_filename, lineno, msg);
+ fprintf (stderr, "%s: %d: %s\n", input_filename, input_line, msg);
exit (1);
}