qse/ase/stx/parser.h

108 lines
2.4 KiB
C
Raw Normal View History

2005-05-12 15:51:20 +00:00
/*
2007-03-22 11:19:28 +00:00
* $Id: parser.h,v 1.37 2007-03-22 11:19:28 bacon Exp $
2005-05-12 15:51:20 +00:00
*/
2007-03-22 11:19:28 +00:00
#ifndef _ASE_STX_PARSER_H_
#define _ASE_STX_PARSER_H_
2005-05-12 15:51:20 +00:00
2007-03-22 11:19:28 +00:00
#include <ase/stx/stx.h>
#include <ase/stx/name.h>
#include <ase/stx/token.h>
#include <ase/bas/arr.h>
2005-05-22 04:11:54 +00:00
2005-06-05 05:27:02 +00:00
enum
{
2007-03-22 11:19:28 +00:00
ASE_STX_PARSER_ERROR_NONE,
2005-06-08 03:16:34 +00:00
/* system errors */
2007-03-22 11:19:28 +00:00
ASE_STX_PARSER_ERROR_INPUT_FUNC,
ASE_STX_PARSER_ERROR_INPUT,
ASE_STX_PARSER_ERROR_MEMORY,
2005-06-08 03:16:34 +00:00
/* lexical errors */
2007-03-22 11:19:28 +00:00
ASE_STX_PARSER_ERROR_CHAR,
ASE_STX_PARSER_ERROR_CHARLIT,
ASE_STX_PARSER_ERROR_STRLIT,
ASE_STX_PARSER_ERROR_LITERAL,
2005-06-08 03:16:34 +00:00
/* syntatic error */
2007-03-22 11:19:28 +00:00
ASE_STX_PARSER_ERROR_MESSAGE_SELECTOR,
ASE_STX_PARSER_ERROR_ARGUMENT_NAME,
ASE_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS,
ASE_STX_PARSER_ERROR_PRIMITIVE_KEYWORD,
ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER,
ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE,
ASE_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED,
ASE_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED,
ASE_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES,
ASE_STX_PARSER_ERROR_PSEUDO_VARIABLE,
ASE_STX_PARSER_ERROR_PRIMARY,
ASE_STX_PARSER_ERROR_NO_PERIOD,
ASE_STX_PARSER_ERROR_NO_RPAREN,
ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME,
ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST,
ASE_STX_PARSER_ERROR_BLOCK_NOT_CLOSED,
ASE_STX_PARSER_ERROR_UNDECLARED_NAME,
ASE_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 */
2007-03-22 11:19:28 +00:00
ASE_STX_PARSER_INPUT_OPEN,
ASE_STX_PARSER_INPUT_CLOSE,
ASE_STX_PARSER_INPUT_CONSUME,
ASE_STX_PARSER_INPUT_REWIND
2005-06-06 03:47:56 +00:00
};
2007-03-22 11:19:28 +00:00
typedef struct ase_stx_parser_t ase_stx_parser_t;
2005-06-05 05:27:02 +00:00
2007-03-22 11:19:28 +00:00
struct ase_stx_parser_t
2005-05-22 04:11:54 +00:00
{
2007-03-22 11:19:28 +00:00
ase_stx_t* stx;
2005-05-30 15:27:31 +00:00
int error_code;
2005-06-04 07:01:57 +00:00
2007-03-22 11:19:28 +00:00
ase_word_t method_class;
ase_stx_name_t method_name;
2005-06-17 04:39:17 +00:00
2007-03-22 11:19:28 +00:00
ase_char_t* temporaries[256]; /* TODO: different size? or dynamic? */
ase_word_t argument_count;
ase_word_t temporary_count;
2005-07-07 16:32:37 +00:00
2007-03-22 11:19:28 +00:00
ase_word_t literals[256]; /* TODO: make it a dynamic array */
ase_word_t literal_count;
2005-06-12 14:40:35 +00:00
2007-03-22 11:19:28 +00:00
ase_arr_t bytecode;
2005-06-19 16:16:33 +00:00
2007-03-22 11:19:28 +00:00
ase_stx_token_t token;
ase_cint_t curc;
ase_cint_t ungotc[5];
ase_size_t ungotc_count;
2005-06-05 05:27:02 +00:00
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
2007-03-22 11:19:28 +00:00
ase_bool_t __dynamic;
2005-05-22 04:11:54 +00:00
};
2005-05-12 15:51:20 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2007-03-22 11:19:28 +00:00
ase_stx_parser_t* ase_stx_parser_open (ase_stx_parser_t* parser, ase_stx_t* stx);
void ase_stx_parser_close (ase_stx_parser_t* parser);
2005-05-22 15:03:20 +00:00
2007-03-22 11:19:28 +00:00
const ase_char_t* ase_stx_parser_error_string (ase_stx_parser_t* parser);
int ase_stx_parser_parse_method (
ase_stx_parser_t* parser, ase_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