2005-05-12 15:51:20 +00:00
|
|
|
/*
|
2005-12-05 15:11:29 +00:00
|
|
|
* $Id: parser.h,v 1.35 2005-12-05 15:11:29 bacon Exp $
|
2005-05-12 15:51:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XP_STX_PARSER_H_
|
|
|
|
#define _XP_STX_PARSER_H_
|
|
|
|
|
2005-08-18 15:28:18 +00:00
|
|
|
#include <xp/stx/stx.h>
|
2005-06-12 16:22:47 +00:00
|
|
|
#include <xp/stx/name.h>
|
2005-06-04 07:01:57 +00:00
|
|
|
#include <xp/stx/token.h>
|
2005-06-19 16:16:33 +00:00
|
|
|
#include <xp/bas/array.h>
|
2005-05-22 04:11:54 +00:00
|
|
|
|
2005-06-05 05:27:02 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-06-08 03:16:34 +00:00
|
|
|
XP_STX_PARSER_ERROR_NONE,
|
|
|
|
|
|
|
|
/* system errors */
|
2005-06-12 12:33:31 +00:00
|
|
|
XP_STX_PARSER_ERROR_INPUT_FUNC,
|
2005-06-08 03:16:34 +00:00
|
|
|
XP_STX_PARSER_ERROR_INPUT,
|
2005-06-12 12:33:31 +00:00
|
|
|
XP_STX_PARSER_ERROR_MEMORY,
|
2005-06-08 03:16:34 +00:00
|
|
|
|
|
|
|
/* lexical errors */
|
2005-06-05 16:44:05 +00:00
|
|
|
XP_STX_PARSER_ERROR_CHAR,
|
|
|
|
XP_STX_PARSER_ERROR_CHARLIT,
|
2005-06-08 03:16:34 +00:00
|
|
|
XP_STX_PARSER_ERROR_STRLIT,
|
2005-06-23 04:55:44 +00:00
|
|
|
XP_STX_PARSER_ERROR_LITERAL,
|
2005-06-08 03:16:34 +00:00
|
|
|
|
|
|
|
/* syntatic error */
|
2005-06-11 18:01:25 +00:00
|
|
|
XP_STX_PARSER_ERROR_MESSAGE_SELECTOR,
|
2005-06-12 14:40:35 +00:00
|
|
|
XP_STX_PARSER_ERROR_ARGUMENT_NAME,
|
|
|
|
XP_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS,
|
2005-07-04 10:02:00 +00:00
|
|
|
|
|
|
|
XP_STX_PARSER_ERROR_PRIMITIVE_KEYWORD,
|
|
|
|
XP_STX_PARSER_ERROR_PRIMITIVE_NUMBER,
|
2005-07-07 07:45:05 +00:00
|
|
|
XP_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE,
|
2005-07-04 10:02:00 +00:00
|
|
|
XP_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED,
|
|
|
|
|
2005-06-12 16:46:45 +00:00
|
|
|
XP_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED,
|
|
|
|
XP_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES,
|
2005-06-19 16:16:33 +00:00
|
|
|
XP_STX_PARSER_ERROR_PSEUDO_VARIABLE,
|
2005-06-23 04:55:44 +00:00
|
|
|
XP_STX_PARSER_ERROR_PRIMARY,
|
|
|
|
|
|
|
|
XP_STX_PARSER_ERROR_NO_PERIOD,
|
2005-06-23 07:20:44 +00:00
|
|
|
XP_STX_PARSER_ERROR_NO_RPAREN,
|
|
|
|
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME,
|
|
|
|
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST,
|
2005-06-29 12:02:39 +00:00
|
|
|
XP_STX_PARSER_ERROR_BLOCK_NOT_CLOSED,
|
|
|
|
|
2005-07-11 13:41:59 +00:00
|
|
|
XP_STX_PARSER_ERROR_UNDECLARED_NAME,
|
|
|
|
XP_STX_PARSER_ERROR_TOO_MANY_LITERALS
|
2005-06-05 05:27:02 +00:00
|
|
|
};
|
|
|
|
|
2005-06-06 03:47:56 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-06-08 03:16:34 +00:00
|
|
|
/* input_func cmd */
|
2005-06-06 03:47:56 +00:00
|
|
|
XP_STX_PARSER_INPUT_OPEN,
|
|
|
|
XP_STX_PARSER_INPUT_CLOSE,
|
|
|
|
XP_STX_PARSER_INPUT_CONSUME,
|
|
|
|
XP_STX_PARSER_INPUT_REWIND
|
|
|
|
};
|
|
|
|
|
2005-06-05 05:27:02 +00:00
|
|
|
typedef struct xp_stx_parser_t xp_stx_parser_t;
|
|
|
|
|
2005-05-22 04:11:54 +00:00
|
|
|
struct xp_stx_parser_t
|
|
|
|
{
|
2005-06-08 03:19:31 +00:00
|
|
|
xp_stx_t* stx;
|
2005-05-30 15:27:31 +00:00
|
|
|
int error_code;
|
2005-06-04 07:01:57 +00:00
|
|
|
|
2005-06-12 16:46:45 +00:00
|
|
|
xp_word_t method_class;
|
2005-06-12 16:22:47 +00:00
|
|
|
xp_stx_name_t method_name;
|
2005-06-17 04:39:17 +00:00
|
|
|
|
2005-07-07 16:32:37 +00:00
|
|
|
xp_char_t* temporaries[256]; /* TODO: different size? or dynamic? */
|
2005-06-29 16:01:32 +00:00
|
|
|
xp_word_t argument_count;
|
|
|
|
xp_word_t temporary_count;
|
2005-07-07 16:32:37 +00:00
|
|
|
|
2005-07-04 11:47:25 +00:00
|
|
|
xp_word_t literals[256]; /* TODO: make it a dynamic array */
|
|
|
|
xp_word_t literal_count;
|
2005-06-12 14:40:35 +00:00
|
|
|
|
2005-07-05 09:02:13 +00:00
|
|
|
xp_array_t bytecode;
|
2005-06-19 16:16:33 +00:00
|
|
|
|
2005-06-12 14:40:35 +00:00
|
|
|
xp_stx_token_t token;
|
2005-06-08 16:05:41 +00:00
|
|
|
xp_cint_t curc;
|
|
|
|
xp_cint_t ungotc[5];
|
2005-06-05 05:27:02 +00:00
|
|
|
xp_size_t ungotc_count;
|
|
|
|
|
2005-06-06 03:47:56 +00:00
|
|
|
void* input_owner;
|
|
|
|
int (*input_func) (int cmd, void* owner, void* arg);
|
2005-06-04 07:01:57 +00:00
|
|
|
|
2005-12-05 15:11:29 +00:00
|
|
|
xp_bool_t __dynamic;
|
2005-05-22 04:11:54 +00:00
|
|
|
};
|
|
|
|
|
2005-05-12 15:51:20 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-06-08 03:19:31 +00:00
|
|
|
xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx);
|
2005-05-22 15:03:20 +00:00
|
|
|
void xp_stx_parser_close (xp_stx_parser_t* parser);
|
|
|
|
|
2005-06-29 12:02:39 +00:00
|
|
|
const xp_char_t* xp_stx_parser_error_string (xp_stx_parser_t* parser);
|
2005-06-05 16:44:05 +00:00
|
|
|
int xp_stx_parser_parse_method (
|
2005-06-08 16:05:41 +00:00
|
|
|
xp_stx_parser_t* parser, xp_word_t method_class, void* input);
|
2005-06-02 16:14:58 +00:00
|
|
|
|
2005-05-12 15:51:20 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|