#ifndef GCC_JAVA_LEX_H
#define GCC_JAVA_LEX_H
#include "input.h"
extern FILE *finput;
typedef unsigned short unicode_t;
#ifndef HAVE_ICONV_H
#undef HAVE_ICONV
#endif
#if defined HAVE_ICONV
#include <iconv.h>
#endif
#define DEFAULT_ENCODING "UTF-8"
typedef struct java_lc_s GTY(()) {
int line;
int col;
} java_lc;
struct java_lexer
{
FILE *finput;
int bs_count;
int next_unicode;
bool avail_unicode;
int next_columns;
unicode_t unget_value;
const char *encoding;
java_lc position;
#ifndef USE_MAPPED_LOCATION
java_lc token_start;
#endif
#ifdef HAVE_ICONV
unsigned int read_anything : 1;
unsigned int byte_swap : 1;
unsigned int use_fallback : 1;
iconv_t handle;
char buffer[1024];
int first;
int last;
unsigned char out_buffer[1024];
int out_first;
int out_last;
#endif
};
typedef struct java_lexer java_lexer;
extern void java_destroy_lexer (java_lexer *);
#define JAVA_LINE_MAX 80
#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
#ifdef JC1_LITE
#define DCONST0 0
#define REAL_VALUE_TYPE int
#define GET_IDENTIFIER(S) xstrdup ((S))
#define REAL_VALUE_ATOF(LIT,MODE) 0
#define REAL_VALUE_ISINF(VALUE) 0
#define REAL_VALUE_ISNAN(VALUE) 0
#define SET_REAL_VALUE_ATOF(TARGET,SOURCE)
#define FLOAT_TYPE_NODE 0
#define DOUBLE_TYPE_NODE 0
#define SET_MODIFIER_CTX(TOKEN) java_lval->value = (TOKEN)
#define GET_TYPE_PRECISION(NODE) 4
#define BUILD_OPERATOR(TOKEN) return TOKEN
#define BUILD_OPERATOR2(TOKEN) return ASSIGN_ANY_TK
#define SET_LVAL_NODE(NODE)
#define BUILD_ID_WFL(EXP) (EXP)
#define JAVA_FLOAT_RANGE_ERROR(S) {}
#define JAVA_RANGE_ERROR(S) do { } while (0)
#else
#define DCONST0 dconst0
#define GET_IDENTIFIER(S) get_identifier ((S))
#define SET_REAL_VALUE_ATOF(TARGET,SOURCE) (TARGET) = (SOURCE)
#define FLOAT_TYPE_NODE float_type_node
#define DOUBLE_TYPE_NODE double_type_node
#define SET_MODIFIER_CTX(TOKEN) \
{ \
ctxp->modifier_ctx [(TOKEN)-PUBLIC_TK] = build_wfl_node (NULL_TREE); \
java_lval->value = (TOKEN)-PUBLIC_TK; \
}
#define GET_TYPE_PRECISION(NODE) TYPE_PRECISION (long_type_node) / 8;
#define BUILD_OPERATOR(TOKEN) \
{ \
java_lval->operator.token = (TOKEN); \
java_lval->operator.location = BUILD_LOCATION(); \
return (TOKEN); \
}
#define BUILD_OPERATOR2(TOKEN) \
{ \
java_lval->operator.token = (TOKEN); \
java_lval->operator.location = BUILD_LOCATION(); \
return ASSIGN_ANY_TK; \
}
#define SET_LVAL_NODE(NODE) java_lval->node = (NODE)
#define BUILD_ID_WFL(EXP) build_wfl_node ((EXP))
#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_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
#define RANGE(c, l, h) (((c) >= l && (c) <= h))
#define JAVA_WHITE_SPACE_P(c) (c == ' ' || c == '\t' || c == '\f')
#define JAVA_START_CHAR_P(c) ((c < 128 \
&& (ISIDST (c) || c == '$')) \
|| (c >= 128 && java_start_char_p (c)))
#define JAVA_PART_CHAR_P(c) ((c < 128 \
&& (ISIDNUM (c) \
|| c == '$' \
|| c == 0x0000 \
|| RANGE (c, 0x01, 0x08) \
|| RANGE (c, 0x0e, 0x1b) \
|| c == 0x7f)) \
|| (c >= 128 && java_part_char_p (c)))
#define JAVA_ASCII_DIGIT(c) ISDIGIT (c)
#define JAVA_ASCII_OCTDIGIT(c) RANGE (c, '0', '7')
#define JAVA_ASCII_HEXDIGIT(c) ISXDIGIT (c)
#define JAVA_ASCII_FPCHAR(c) (RANGE (c, 'd', 'f') || RANGE (c, 'D', 'F') || \
c == '.' || JAVA_ASCII_DIGIT (c))
#define JAVA_FP_SUFFIX(c) (c == 'D' || c == 'd' || c == 'f' || c == 'F')
#define JAVA_FP_EXP(c) (c == 'E' || c == 'F')
#define JAVA_FP_PM(c) (c == '-' || c == '+')
#define JAVA_ASCII_LETTER(c) ISALPHA (c)
#define JAVA_READ_BUFFER 256
#define JAVA_CHAR_ERROR -2
#define UEOF -1
#endif