00001
00009 #ifndef _KERNEL_SEXP_LEXER_H_
00010 #define _KERNEL_SEXP_LEXER_H_
00011
00012 #include "lib/gas.h"
00013
00014 union sl_token_data
00015 {
00016 const char *v_string;
00017 uns v_integer;
00018 real v_real;
00019 };
00020
00021 struct sexp_lexer
00022 {
00023 struct vcl_growing_array buffer;
00024 FILE *src;
00025 int (* state)(struct sexp_lexer *ps, union sl_token_data *s);
00026 union sl_token_data last_token_data;
00027 int last_token_type;
00028 int char_counter, line_counter;
00029 };
00030
00031 enum
00032 {
00033 SLT_NONE,
00034 SLT_EOF,
00035 SLT_ERROR,
00036 SLT_ERROR_TOKEN,
00037 SLT_OPEN_PAREN,
00038 SLT_CLOSE_PAREN,
00039 SLT_STRING,
00040 SLT_SYMBOL,
00041 SLT_INTEGER,
00042 SLT_REAL,
00043 SLT_BOOLEAN
00044 };
00045
00046
00047
00048 void sexp_lexer_init(struct sexp_lexer *ps, FILE *src);
00049 int sl_read_token_direct(struct sexp_lexer *ps, union sl_token_data *td);
00050 int sl_read_token(struct sexp_lexer *ps, union sl_token_data *td);
00051 int sl_see_token(struct sexp_lexer *ps, union sl_token_data *td);
00052 void sexp_lexer_finish(struct sexp_lexer *ps);
00053 void dump_token(int token_type, union sl_token_data *td);
00054
00055 #endif