Simplify lexer. Implement --enable-mapped-location support.
* jcf-parse.c (parse_class_file): Use linemap_line_start. (parse_source_file_1): Pass filename as extra parameter, so we can call linemap_add and set input_location here, rather than in both callers. (read_class): Pass copied filename to parse_source_file_1. Don't initialize wfl_operator - only needed for source compilation. (read_class, jcf_parse): Call linemap_add with LC_LEAVE. * lex.h: Remove a bunch of debugging macros. * lex.h (struct_java_line, struct java_error): Remove types. (JAVA_COLUMN_DELTA): Remove - use java_lexer.next_colums instead. (struct java_lc_s): Remove prev_col field. (struct java_lexer): New fields next_unicode, next_columns, and avail_unicode. New position field, and maybe token_start field. Don't need hit_eof field - use next_unicode == -1 instead. (JAVA_INTEGERAL_RANGE_ERROR): Rename to JAVA_RANGE_ERROR. (JAVA_RANGE_ERROR, JAVA_FLOAT_ANGE_ERROR): Update accordingly. * parse.h: Various changes for USE_MAPPED_LOCATION. (EXPR_WFL_EMIT_LINE_NOTE): XXX (BUILD_EXPR_WFL, EXPR_WFL_ADD_COL): Remove no-longer-used macros. (struct parser_ctxt): New file_start_location field. Remove p_line, c_line fields since we no longer save lines. Remove elc, lineno, and current_jcf fields - no longer used. * parse.y: Updates for USE_MAPPED_LOCATION and new lexer. Don't use EXPR_WFL_ADD_COL since that isn't trivial with source_location and is probably not needed anymore anyway. Use new expr_add_Location function. (SET_EXPR_LOCATION_FROM_TOKEN): New convenience macro. (java_pop_parser_context): Minor cleanup. (java_parser_context_save_global, java_parser_context_restore_global, java_pop_parser_context): Save/restore input_location as a unit. (issue_warning_error_from_context): If USE_MAPPED_LOCATION take a source_location instead of a wfl context node. (check_class_interface_creation): input_filename is not addressable. (create_artificial_method): Calling java_parser_context_save_global and java_parser_context_restore_global is overkill. Instead, temporarily set input_location from class decl. (java_layout_seen_class_methods): Set input_location from method decl. (fix_constructors): Make more robust if no EXPR_WITH_FILE_LOCATION. (finish_loop_body): Likewise. * lex.c: Updates for USE_MAPPED_LOCATION. Use build_unknwon_wfl. (java_sprint_unicode): Take a character, not index in line. (java_sneak_uncode): Replaced by java_peek_unicode. (java_unget_unicode): No longer used. (java_allocate_new_line. java_store_unicode): Removed, since we no longer remember "lines". (java_new_lexer): Update for new data structures. (java_read_char): Move unget_value checking to java_read_unicode. (java_get_unicode, java_peek_unicode, java_next_unicode): New more efficient functions that are used directly when lexing. (java_read_unicode_collapsing_terminators): No longer needed. (java_parse_end_comment, java_parse_escape_sequence, do_java_lex): Re-organize to use java_peek_unicode to avoid java_unget_unicode. (java_parse_escape_sequence): Rewrite to be simpler / more efficient. (do_java_lex): Lots of movings around to avoid java_unget_unicode, combine switch branches, and test for common token kinds earlier. (java_lex_error): Rewrite. * jv-scan.c (expand_location): New function, copied from tree.c. (main): Set ctxp->filename instead of setting input_filename directly. From-SVN: r88367
This commit is contained in:
parent
cb3a14307a
commit
9ec819d49c
@ -1,3 +1,64 @@
|
||||
2004-09-30 Per Bothner <per@bothner.com>
|
||||
|
||||
Simplify lexer. Implement --enable-mapped-location support.
|
||||
* jcf-parse.c (parse_class_file): Use linemap_line_start.
|
||||
(parse_source_file_1): Pass filename as extra parameter, so we can call
|
||||
linemap_add and set input_location here, rather than in both callers.
|
||||
(read_class): Pass copied filename to parse_source_file_1.
|
||||
Don't initialize wfl_operator - only needed for source compilation.
|
||||
(read_class, jcf_parse): Call linemap_add with LC_LEAVE.
|
||||
* lex.h: Remove a bunch of debugging macros.
|
||||
* lex.h (struct_java_line, struct java_error): Remove types.
|
||||
(JAVA_COLUMN_DELTA): Remove - use java_lexer.next_colums instead.
|
||||
(struct java_lc_s): Remove prev_col field.
|
||||
(struct java_lexer): New fields next_unicode, next_columns, and
|
||||
avail_unicode. New position field, and maybe token_start field.
|
||||
Don't need hit_eof field - use next_unicode == -1 instead.
|
||||
(JAVA_INTEGERAL_RANGE_ERROR): Rename to JAVA_RANGE_ERROR.
|
||||
(JAVA_RANGE_ERROR, JAVA_FLOAT_ANGE_ERROR): Update accordingly.
|
||||
* parse.h: Various changes for USE_MAPPED_LOCATION.
|
||||
(EXPR_WFL_EMIT_LINE_NOTE): XXX
|
||||
(BUILD_EXPR_WFL, EXPR_WFL_ADD_COL): Remove no-longer-used macros.
|
||||
(struct parser_ctxt): New file_start_location field.
|
||||
Remove p_line, c_line fields since we no longer save lines.
|
||||
Remove elc, lineno, and current_jcf fields - no longer used.
|
||||
* parse.y: Updates for USE_MAPPED_LOCATION and new lexer.
|
||||
Don't use EXPR_WFL_ADD_COL since that isn't trivial with
|
||||
source_location and is probably not needed anymore anyway.
|
||||
Use new expr_add_Location function.
|
||||
(SET_EXPR_LOCATION_FROM_TOKEN): New convenience macro.
|
||||
(java_pop_parser_context): Minor cleanup.
|
||||
(java_parser_context_save_global, java_parser_context_restore_global,
|
||||
java_pop_parser_context): Save/restore input_location as a unit.
|
||||
(issue_warning_error_from_context): If USE_MAPPED_LOCATION take
|
||||
a source_location instead of a wfl context node.
|
||||
(check_class_interface_creation): input_filename is not addressable.
|
||||
(create_artificial_method): Calling java_parser_context_save_global
|
||||
and java_parser_context_restore_global is overkill. Instead,
|
||||
temporarily set input_location from class decl.
|
||||
(java_layout_seen_class_methods): Set input_location from method decl.
|
||||
(fix_constructors): Make more robust if no EXPR_WITH_FILE_LOCATION.
|
||||
(finish_loop_body): Likewise.
|
||||
* lex.c: Updates for USE_MAPPED_LOCATION. Use build_unknwon_wfl.
|
||||
(java_sprint_unicode): Take a character, not index in line.
|
||||
(java_sneak_uncode): Replaced by java_peek_unicode.
|
||||
(java_unget_unicode): No longer used.
|
||||
(java_allocate_new_line. java_store_unicode): Removed, since we
|
||||
no longer remember "lines".
|
||||
(java_new_lexer): Update for new data structures.
|
||||
(java_read_char): Move unget_value checking to java_read_unicode.
|
||||
(java_get_unicode, java_peek_unicode, java_next_unicode): New more
|
||||
efficient functions that are used directly when lexing.
|
||||
(java_read_unicode_collapsing_terminators): No longer needed.
|
||||
(java_parse_end_comment, java_parse_escape_sequence, do_java_lex):
|
||||
Re-organize to use java_peek_unicode to avoid java_unget_unicode.
|
||||
(java_parse_escape_sequence): Rewrite to be simpler / more efficient.
|
||||
(do_java_lex): Lots of movings around to avoid java_unget_unicode,
|
||||
combine switch branches, and test for common token kinds earlier.
|
||||
(java_lex_error): Rewrite.
|
||||
* jv-scan.c (expand_location): New function, copied from tree.c.
|
||||
(main): Set ctxp->filename instead of setting input_filename directly.
|
||||
|
||||
2004-09-30 Per Bothner <per@bothner.com>
|
||||
|
||||
More cleanup for --enable-mapped-location.
|
||||
@ -30,7 +91,7 @@
|
||||
|
||||
2004-09-29 Per Bothner <per@bothner.com>
|
||||
|
||||
* java-tree.h: Redefine some macros and add soem declaration
|
||||
* java-tree.h: Redefine some macros and add some declaration
|
||||
to handle the USE_MAPPED_LOCATION case.
|
||||
* parse.h (EXPR_WFL_QUALIFICATION): Use operand 1, not 2.
|
||||
* java-tree.h (EXPR_WFL_FILENAME_NODE): Use operand 2, not 1.
|
||||
|
@ -98,7 +98,7 @@ static char *compute_class_name (struct ZipDirectory *zdir);
|
||||
static int classify_zip_file (struct ZipDirectory *zdir);
|
||||
static void parse_zip_file_entries (void);
|
||||
static void process_zip_dir (FILE *);
|
||||
static void parse_source_file_1 (tree, FILE *);
|
||||
static void parse_source_file_1 (tree, const char *, FILE *);
|
||||
static void parse_source_file_2 (void);
|
||||
static void parse_source_file_3 (void);
|
||||
static void parse_class_file (void);
|
||||
@ -544,27 +544,27 @@ read_class (tree name)
|
||||
java_push_parser_context ();
|
||||
|
||||
given_file = get_identifier (filename);
|
||||
filename = IDENTIFIER_POINTER (given_file);
|
||||
real_file = get_identifier (lrealpath (filename));
|
||||
|
||||
generate = IS_A_COMMAND_LINE_FILENAME_P (given_file);
|
||||
if (wfl_operator == NULL_TREE)
|
||||
wfl_operator = build_expr_wfl (NULL_TREE, NULL, 0, 0);
|
||||
EXPR_WFL_FILENAME_NODE (wfl_operator) = given_file;
|
||||
input_filename = ggc_strdup (filename);
|
||||
output_class = current_class = NULL_TREE;
|
||||
current_function_decl = NULL_TREE;
|
||||
|
||||
if (! HAS_BEEN_ALREADY_PARSED_P (real_file))
|
||||
{
|
||||
if (! (finput = fopen (input_filename, "r")))
|
||||
fatal_error ("can't reopen %s: %m", input_filename);
|
||||
if (! (finput = fopen (filename, "r")))
|
||||
fatal_error ("can't reopen %s: %m", filename);
|
||||
|
||||
parse_source_file_1 (real_file, finput);
|
||||
parse_source_file_1 (real_file, filename, finput);
|
||||
parse_source_file_2 ();
|
||||
parse_source_file_3 ();
|
||||
|
||||
if (fclose (finput))
|
||||
fatal_error ("can't close %s: %m", input_filename);
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
|
||||
#endif
|
||||
}
|
||||
JCF_FINISH (current_jcf);
|
||||
java_pop_parser_context (generate);
|
||||
@ -577,7 +577,7 @@ read_class (tree name)
|
||||
java_parser_context_save_global ();
|
||||
java_push_parser_context ();
|
||||
output_class = current_class = class;
|
||||
input_filename = current_jcf->filename;
|
||||
ctxp->save_location = input_location;
|
||||
if (JCF_SEEN_IN_ZIP (current_jcf))
|
||||
read_zip_member(current_jcf,
|
||||
current_jcf->zipd, current_jcf->zipd->zipf);
|
||||
@ -710,6 +710,9 @@ jcf_parse (JCF* jcf)
|
||||
code = jcf_parse_final_attributes (jcf);
|
||||
if (code != 0)
|
||||
fatal_error ("error while parsing final attributes");
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
|
||||
#endif
|
||||
|
||||
/* The fields of class_type_node are already in correct order. */
|
||||
if (current_class != class_type_node && current_class != object_type_node)
|
||||
@ -804,10 +807,11 @@ parse_class_file (void)
|
||||
continue;
|
||||
}
|
||||
|
||||
input_line = 0;
|
||||
input_location = file_start_location;
|
||||
if (DECL_LINENUMBERS_OFFSET (method))
|
||||
{
|
||||
int i;
|
||||
int min_line = 0;
|
||||
unsigned char *ptr;
|
||||
JCF_SEEK (jcf, DECL_LINENUMBERS_OFFSET (method));
|
||||
linenumber_count = i = JCF_readu2 (jcf);
|
||||
@ -818,9 +822,16 @@ parse_class_file (void)
|
||||
int line = GET_u2 (ptr);
|
||||
/* Set initial input_line to smallest linenumber.
|
||||
* Needs to be set before init_function_start. */
|
||||
if (input_line == 0 || line < input_line)
|
||||
input_line = line;
|
||||
}
|
||||
if (min_line == 0 || line < min_line)
|
||||
min_line = line;
|
||||
}
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
if (min_line != 0)
|
||||
input_location = linemap_line_start (&line_table, min_line, 1);
|
||||
#else
|
||||
if (min_line != 0)
|
||||
input_line = min_line;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -845,22 +856,20 @@ parse_class_file (void)
|
||||
|
||||
finish_class ();
|
||||
|
||||
(*debug_hooks->end_source_file) (save_location.line);
|
||||
(*debug_hooks->end_source_file) (LOCATION_LINE (save_location));
|
||||
input_location = save_location;
|
||||
}
|
||||
|
||||
/* Parse a source file, as pointed by the current value of INPUT_FILENAME. */
|
||||
|
||||
static void
|
||||
parse_source_file_1 (tree real_file, FILE *finput)
|
||||
parse_source_file_1 (tree real_file, const char *filename, FILE *finput)
|
||||
{
|
||||
int save_error_count = java_error_count;
|
||||
|
||||
/* Mark the file as parsed. */
|
||||
HAS_BEEN_ALREADY_PARSED_P (real_file) = 1;
|
||||
|
||||
jcf_dependency_add_file (input_filename, 0);
|
||||
|
||||
lang_init_source (1); /* Error msgs have no method prototypes */
|
||||
|
||||
/* There's no point in trying to find the current encoding unless we
|
||||
@ -874,6 +883,18 @@ parse_source_file_1 (tree real_file, FILE *finput)
|
||||
if (current_encoding == NULL || *current_encoding == '\0')
|
||||
current_encoding = DEFAULT_ENCODING;
|
||||
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
linemap_add (&line_table, LC_ENTER, false, filename, 0);
|
||||
input_location = linemap_line_start (&line_table, 0, 125);
|
||||
#else
|
||||
input_filename = filename;
|
||||
input_line = 0;
|
||||
#endif
|
||||
ctxp->file_start_location = input_location;
|
||||
ctxp->filename = filename;
|
||||
|
||||
jcf_dependency_add_file (input_filename, 0);
|
||||
|
||||
/* Initialize the parser */
|
||||
java_init_lex (finput, current_encoding);
|
||||
java_parse_abort_on_error ();
|
||||
@ -1147,21 +1168,24 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
|
||||
java_push_parser_context ();
|
||||
java_parser_context_save_global ();
|
||||
|
||||
parse_source_file_1 (real_file, finput);
|
||||
parse_source_file_1 (real_file, filename, finput);
|
||||
java_parser_context_restore_global ();
|
||||
java_pop_parser_context (1);
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
linemap_add (&line_table, LC_LEAVE, false, NULL, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
for (ctxp = ctxp_for_generation; ctxp; ctxp = ctxp->next)
|
||||
{
|
||||
input_filename = ctxp->filename;
|
||||
input_location = ctxp->file_start_location;
|
||||
parse_source_file_2 ();
|
||||
}
|
||||
|
||||
for (ctxp = ctxp_for_generation; ctxp; ctxp = ctxp->next)
|
||||
{
|
||||
input_filename = ctxp->filename;
|
||||
input_location = ctxp->file_start_location;
|
||||
parse_source_file_3 ();
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ FILE *finput, *out;
|
||||
/* Executable name. */
|
||||
char *exec_name;
|
||||
|
||||
struct line_maps line_table;
|
||||
|
||||
/* Flags matching command line options. */
|
||||
int flag_find_main = 0;
|
||||
int flag_dump_class = 0;
|
||||
@ -129,6 +131,29 @@ version (void)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
/* FIXME - this is the same as the function in tree.c, which is awkward.
|
||||
Probably the cleanest solution is to move the function to line-map.c.
|
||||
This is difficult as long as we still support --disable-mapped-location,
|
||||
since whether expanded_location has a column fields depends on
|
||||
USE_MAPPED_LOCATION. */
|
||||
|
||||
expanded_location
|
||||
expand_location (source_location loc)
|
||||
{
|
||||
expanded_location xloc;
|
||||
if (loc == 0) { xloc.file = NULL; xloc.line = 0; xloc.column = 0; }
|
||||
else
|
||||
{
|
||||
const struct line_map *map = linemap_lookup (&line_table, loc);
|
||||
xloc.file = map->to_file;
|
||||
xloc.line = SOURCE_LINE (map, loc);
|
||||
xloc.column = SOURCE_COLUMN (map, loc);
|
||||
};
|
||||
return xloc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* jc1-lite main entry point */
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
@ -198,8 +223,8 @@ main (int argc, char **argv)
|
||||
for ( i = optind; i < argc; i++ )
|
||||
if (argv [i])
|
||||
{
|
||||
input_filename = argv [i];
|
||||
if ( (finput = fopen (argv [i], "r")) )
|
||||
char *filename = argv[i];
|
||||
if ( (finput = fopen (filename, "r")) )
|
||||
{
|
||||
/* There's no point in trying to find the current encoding
|
||||
unless we are going to do something intelligent with it
|
||||
@ -213,6 +238,7 @@ main (int argc, char **argv)
|
||||
encoding = DEFAULT_ENCODING;
|
||||
|
||||
java_init_lex (finput, encoding);
|
||||
ctxp->filename = filename;
|
||||
yyparse ();
|
||||
report ();
|
||||
if (ftell (out) != ft)
|
||||
|
986
gcc/java/lex.c
986
gcc/java/lex.c
File diff suppressed because it is too large
Load Diff
121
gcc/java/lex.h
121
gcc/java/lex.h
@ -42,65 +42,9 @@ typedef unsigned short unicode_t;
|
||||
/* Default encoding to use if no encoding is specified. */
|
||||
#define DEFAULT_ENCODING "UTF-8"
|
||||
|
||||
/* Debug macro to print-out what we match */
|
||||
#ifdef JAVA_LEX_DEBUG
|
||||
#ifdef JAVA_LEX_DEBUG_CHAR
|
||||
#define JAVA_LEX_CHAR(c) printf ("java_lex:%d: char '%c'.%d\n", \
|
||||
lineno, (c < 128 ? c : '.'), c);
|
||||
#else
|
||||
#define JAVA_LEX_CHAR(c)
|
||||
#endif
|
||||
#define JAVA_LEX_KW(c) printf ("java_lex:%d: keyword: '%s'\n", lineno,c)
|
||||
#define JAVA_LEX_ID(s) printf ("java_lex:%d: ID: '%s'\n", \
|
||||
lineno, \
|
||||
(all_ascii ? s : "<U>"))
|
||||
#define JAVA_LEX_LIT(s, r) printf ("java_lex:%d: literal '%s'_%d\n", \
|
||||
lineno, s, r)
|
||||
#define JAVA_LEX_CHAR_LIT(s) printf ("java_lex:%d: literal '%d'\n", lineno, s)
|
||||
#define JAVA_LEX_STR_LIT(s) { \
|
||||
int i; \
|
||||
printf ("java_lex:%d: literal '%s'\n", \
|
||||
lineno, s); \
|
||||
}
|
||||
#define JAVA_LEX_SEP(c) printf ("java_lex:%d: separator '%c'\n",lineno,c)
|
||||
#define JAVA_LEX_OP(c) printf ("java_lex:%d: operator '%s'\n", lineno,c)
|
||||
#else
|
||||
#define JAVA_LEX_CHAR(c)
|
||||
#define JAVA_LEX_KW(c)
|
||||
#define JAVA_LEX_ID(s)
|
||||
#define JAVA_LEX_LIT(s,r)
|
||||
#define JAVA_LEX_CHAR_LIT(s)
|
||||
#define JAVA_LEX_STR_LIT(s)
|
||||
#define JAVA_LEX_SEP(c)
|
||||
#define JAVA_LEX_OP(s)
|
||||
#endif
|
||||
|
||||
/* Line information containers */
|
||||
struct java_line {
|
||||
unicode_t *line; /* The line's unicode */
|
||||
char *unicode_escape_p; /* The matching char was a unicode escape */
|
||||
unicode_t ahead[1]; /* Character ahead */
|
||||
char unicode_escape_ahead_p; /* Character ahead is a unicode escape */
|
||||
int max; /* buffer's max size */
|
||||
int size; /* number of unicodes */
|
||||
int current; /* Current position, unicode based */
|
||||
int char_col; /* Current position, input char based */
|
||||
int lineno; /* Its line number */
|
||||
int white_space_only; /* If it contains only white spaces */
|
||||
};
|
||||
#define JAVA_COLUMN_DELTA(p) \
|
||||
(ctxp->c_line->unicode_escape_p [ctxp->c_line->current+(p)] ? 6 : \
|
||||
(ctxp->c_line->line [ctxp->c_line->current+(p)] == '\t' ? 8 : 1))
|
||||
|
||||
struct java_error {
|
||||
struct java_line *line;
|
||||
int error;
|
||||
};
|
||||
|
||||
typedef struct java_lc_s GTY(()) {
|
||||
int line;
|
||||
int prev_col;
|
||||
int col;
|
||||
int line; /* line number (1-based) */
|
||||
int col; /* column number number (1-based) */
|
||||
} java_lc;
|
||||
|
||||
struct java_lexer
|
||||
@ -111,15 +55,33 @@ struct java_lexer
|
||||
/* Number of consecutive backslashes we've read. */
|
||||
int bs_count;
|
||||
|
||||
/* If nonzero, a value that was pushed back. */
|
||||
/* Next available Unicode character.
|
||||
* This is post-Unicode-escape-processing. -1 if EOF. */
|
||||
int next_unicode;
|
||||
|
||||
/* True if next_unicode is next available character, or EOF. */
|
||||
bool avail_unicode;
|
||||
|
||||
/* Number of source columns of the previous Unicode character (next_unicode).
|
||||
If next_unicode==-2, then this is the number of columns of the previous
|
||||
Unicode character (most recent result of java_{get,peek}_unicode). */
|
||||
int next_columns;
|
||||
|
||||
/* If nonzero, a value that was pushed back. This is a unicode character,
|
||||
but (unlike next_unicode) is pre-'\uXXXX'-processing. It is also used
|
||||
when a '\r' is *not* followed by a '\n'. */
|
||||
unicode_t unget_value;
|
||||
|
||||
/* If nonzero, we've hit EOF. Used only by java_get_unicode(). */
|
||||
unsigned int hit_eof : 1;
|
||||
|
||||
/* Name of the character encoding we're using. */
|
||||
const char *encoding;
|
||||
|
||||
/* Current source position. */
|
||||
java_lc position;
|
||||
|
||||
#ifndef USE_MAPPED_LOCATION
|
||||
java_lc token_start; /* Error's line column info */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
/* Nonzero if we've read any bytes. We only recognize the
|
||||
byte-order-marker (BOM) as the first word. */
|
||||
@ -168,7 +130,12 @@ extern void java_destroy_lexer (java_lexer *);
|
||||
#define JAVA_LINE_MAX 80
|
||||
|
||||
/* Build a location compound integer */
|
||||
#define BUILD_LOCATION() ((ctxp->elc.line << 12) | (ctxp->elc.col & 0xfff))
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
#define BUILD_LOCATION() input_location
|
||||
#else
|
||||
#define BUILD_LOCATION() ((ctxp->lexer->token_start.line << 12) \
|
||||
| (ctxp->lexer->token_start.col & 0xfff))
|
||||
#endif
|
||||
|
||||
/* Those macros are defined differently if we compile jc1-lite
|
||||
(JC1_LITE defined) or jc1. */
|
||||
@ -190,7 +157,7 @@ extern void java_destroy_lexer (java_lexer *);
|
||||
#define SET_LVAL_NODE(NODE)
|
||||
#define BUILD_ID_WFL(EXP) (EXP)
|
||||
#define JAVA_FLOAT_RANGE_ERROR(S) {}
|
||||
#define JAVA_INTEGRAL_RANGE_ERROR(S) do { } while (0)
|
||||
#define JAVA_RANGE_ERROR(S) do { } while (0)
|
||||
|
||||
#else
|
||||
|
||||
@ -227,21 +194,19 @@ extern void java_destroy_lexer (java_lexer *);
|
||||
/* Wrap identifier around a wfl */
|
||||
#define BUILD_ID_WFL(EXP) build_wfl_node ((EXP))
|
||||
/* Special ways to report error on numeric literals */
|
||||
#define JAVA_FLOAT_RANGE_ERROR(m) \
|
||||
{ \
|
||||
char msg [1024]; \
|
||||
int i = ctxp->c_line->current; \
|
||||
ctxp->c_line->current = number_beginning; \
|
||||
sprintf (msg, "Floating point literal exceeds range of `%s'", (m)); \
|
||||
java_lex_error (msg, 0); \
|
||||
ctxp->c_line->current = i; \
|
||||
#define JAVA_FLOAT_RANGE_ERROR(m) \
|
||||
{ \
|
||||
char *msg = xmalloc (100 + strlen (m)); \
|
||||
sprintf (msg, "Floating point literal exceeds range of `%s'", (m)); \
|
||||
JAVA_RANGE_ERROR(msg); \
|
||||
free (msg); \
|
||||
}
|
||||
#define JAVA_INTEGRAL_RANGE_ERROR(m) \
|
||||
do { \
|
||||
int i = ctxp->c_line->current; \
|
||||
ctxp->c_line->current = number_beginning; \
|
||||
java_lex_error (m, 0); \
|
||||
ctxp->c_line->current = i; \
|
||||
#define JAVA_RANGE_ERROR(msg) \
|
||||
do { \
|
||||
int save_col = ctxp->lexer->position.col; \
|
||||
ctxp->lexer->position.col = number_beginning; \
|
||||
java_lex_error (msg, 0); \
|
||||
ctxp->lexer->position.col = save_col; \
|
||||
} while (0)
|
||||
|
||||
#endif /* Definitions for jc1 compilation only */
|
||||
|
@ -89,6 +89,23 @@ extern tree stabilize_reference (tree);
|
||||
#define MODIFIER_WFL(M) (ctxp->modifier_ctx [(M) - PUBLIC_TK])
|
||||
|
||||
/* Check on modifiers */
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
#define THIS_MODIFIER_ONLY(f, m, v, count, l) \
|
||||
if ((f) & (m)) \
|
||||
{ \
|
||||
tree node = MODIFIER_WFL (v); \
|
||||
if (!l) \
|
||||
l = node; \
|
||||
else \
|
||||
{ \
|
||||
expanded_location lloc = expand_location (EXPR_LOCATION (l)); \
|
||||
expanded_location nloc = expand_location (EXPR_LOCATION (node)); \
|
||||
if (nloc.column > lloc.column || nloc.line > lloc.line) \
|
||||
l = node; \
|
||||
} \
|
||||
count++; \
|
||||
}
|
||||
#else
|
||||
#define THIS_MODIFIER_ONLY(f, m, v, count, l) \
|
||||
if ((f) & (m)) \
|
||||
{ \
|
||||
@ -101,6 +118,7 @@ extern tree stabilize_reference (tree);
|
||||
l = node; \
|
||||
count++; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ABSTRACT_CHECK(FLAG, V, CL, S) \
|
||||
if ((FLAG) & (V)) \
|
||||
@ -163,11 +181,13 @@ extern tree stabilize_reference (tree);
|
||||
&& !TREE_TYPE (NODE) \
|
||||
&& TREE_CODE (TYPE_NAME (NODE)) == IDENTIFIER_NODE)
|
||||
|
||||
#ifndef USE_MAPPED_LOCATION
|
||||
/* Set the EMIT_LINE_NOTE flag of a EXPR_WLF to 1 if debug information
|
||||
are requested. Works in the context of a parser rule. */
|
||||
#define JAVA_MAYBE_GENERATE_DEBUG_INFO(node) \
|
||||
(debug_info_level != DINFO_LEVEL_NONE ? \
|
||||
EXPR_WFL_EMIT_LINE_NOTE (node) = 1, node : node)
|
||||
do {if (debug_info_level != DINFO_LEVEL_NONE) \
|
||||
EXPR_WFL_EMIT_LINE_NOTE (node) = 1; } while (0)
|
||||
#endif
|
||||
|
||||
/* Types classification, according to the JLS, section 4.2 */
|
||||
#define JFLOAT_TYPE_P(TYPE) (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)
|
||||
@ -610,20 +630,14 @@ typedef struct jdeplist_s jdeplist;
|
||||
#define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) : \
|
||||
current_static_block)
|
||||
|
||||
#ifndef USE_MAPPED_LOCATION
|
||||
/* Retrieve line/column from a WFL. */
|
||||
#define EXPR_WFL_GET_LINECOL(V,LINE,COL) \
|
||||
{ \
|
||||
(LINE) = (V) >> 12; \
|
||||
(COL) = (V) & 0xfff; \
|
||||
}
|
||||
/* Add X to the column number information */
|
||||
#define EXPR_WFL_ADD_COL(V, X) \
|
||||
(V) = (((V) & 0xfffff000) | ((((V) & 0xfff) + (X)) & 0xfff))
|
||||
|
||||
/* Build a WFL for expression nodes */
|
||||
#define BUILD_EXPR_WFL(NODE, WFL) \
|
||||
build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), \
|
||||
EXPR_WFL_COLNO ((WFL)))
|
||||
#endif
|
||||
|
||||
#define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 1)
|
||||
#define QUAL_WFL(NODE) TREE_PURPOSE (NODE)
|
||||
@ -671,10 +685,17 @@ typedef struct jdeplist_s jdeplist;
|
||||
}
|
||||
|
||||
/* Set wfl_operator for the most accurate error location */
|
||||
#ifdef USE_MAPPED_LOCATION
|
||||
#define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
|
||||
SET_EXPR_LOCATION (WHICH, \
|
||||
(TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
|
||||
EXPR_LOCATION (WFL) : EXPR_LOCATION (NODE)))
|
||||
#else
|
||||
#define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
|
||||
EXPR_WFL_LINECOL (WHICH) = \
|
||||
(TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
|
||||
EXPR_WFL_LINECOL (WFL) : EXPR_WFL_LINECOL (NODE))
|
||||
#endif
|
||||
|
||||
#define PATCH_METHOD_RETURN_ERROR() \
|
||||
{ \
|
||||
@ -724,23 +745,23 @@ typedef struct jdeplist_s jdeplist;
|
||||
|
||||
/* Parser context data structure. */
|
||||
struct parser_ctxt GTY(()) {
|
||||
|
||||
const char *filename; /* Current filename */
|
||||
const char *filename; /* Current filename */
|
||||
location_t file_start_location;
|
||||
location_t save_location;
|
||||
struct parser_ctxt *next;
|
||||
|
||||
java_lexer * GTY((skip)) lexer; /* Current lexer state */
|
||||
char marker_begining; /* Marker. Should be a sub-struct */
|
||||
struct java_line * GTY ((skip)) p_line; /* Previous line */
|
||||
struct java_line * GTY ((skip)) c_line; /* Current line */
|
||||
java_lc elc; /* Error's line column info */
|
||||
int ccb_indent; /* Keep track of {} indent, lexer */
|
||||
int first_ccb_indent1; /* First { at ident level 1 */
|
||||
int last_ccb_indent1; /* Last } at ident level 1 */
|
||||
int ccb_indent; /* Number of unmatched { seen. */
|
||||
/* The next two fields are only source_location if USE_MAPPED_LOCATION.
|
||||
Otherwise, they are integer line number, but we can't have #ifdefs
|
||||
in GTY structures. */
|
||||
source_location first_ccb_indent1; /* First { at ident level 1 */
|
||||
source_location last_ccb_indent1; /* Last } at ident level 1 */
|
||||
int parser_ccb_indent; /* Keep track of {} indent, parser */
|
||||
int osb_depth; /* Current depth of [ in an expression */
|
||||
int osb_limit; /* Limit of this depth */
|
||||
int * GTY ((skip)) osb_number; /* Keep track of ['s */
|
||||
int lineno; /* Current lineno */
|
||||
char marker_end; /* End marker. Should be a sub-struct */
|
||||
|
||||
/* The flags section */
|
||||
@ -763,8 +784,6 @@ struct parser_ctxt GTY(()) {
|
||||
tree class_type; /* Current class */
|
||||
tree function_decl; /* Current function decl, save/restore */
|
||||
|
||||
struct JCF * current_jcf; /* CU jcf */
|
||||
|
||||
int prevent_ese; /* Prevent expression statement error */
|
||||
|
||||
int formal_parameter_number; /* Number of parameters found */
|
||||
|
504
gcc/java/parse.y
504
gcc/java/parse.y
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user