Mercurial > hg > index.cgi
diff lwbasic/lwbasic.h @ 25:87590f43e76d
Started lwbasic parser; checkpoint
author | lost@l-w.ca |
---|---|
date | Mon, 24 Jan 2011 20:08:09 -0700 |
parents | 25a4aef9c5ed |
children | 26aa76da75ad |
line wrap: on
line diff
--- a/lwbasic/lwbasic.h Mon Jan 24 18:31:07 2011 -0700 +++ b/lwbasic/lwbasic.h Mon Jan 24 20:08:09 2011 -0700 @@ -26,18 +26,73 @@ #ifndef __lwbasic_h_seen__ #define __lwbasic_h_seen__ +#include <stdint.h> + +/* note: integer and uinteger will be the same for positive values from 0 +through 0x7FFFFFFF; the unsigned type should be used for doing ascii +conversions and then if a negative value was discovered, it should be +negated IFF it is in range. */ + +union lexer_numbers +{ + uint32_t uinteger; + int32_t integer; +}; + typedef struct { char *output_file; char *input_file; int debug_level; + + char *lexer_token_string; + union lexer_numbers lexer_token_number; + int lexer_token; + int lexer_curchar; + int lexer_ignorechar; + + int parser_state; void *input_state; } cstate; +/* parser states */ +enum +{ + parser_state_global = 0, /* only global decls allowed */ + parser_state_error +}; + +/* token types */ +enum +{ + token_kw_sub, /* SUB keyword */ + token_kw_function, /* FUNCTION keyword */ + token_kw_as, /* AS keyword */ + token_kw_public, /* PUBLIC keyword */ + token_kw_private, /* PRIVATE keyword */ + token_kw_params, /* PARAMS keyword */ + token_kw_returns, /* RETURNS keyword */ + token_kw_integer, /* INTEGER keyword */ + token_identifier, /* an identifier (variable, function, etc. */ + token_char, /* single character; fallback */ + token_uint, /* unsigned integer up to 32 bits */ + token_int, /* signed integer up to 32 bits */ + token_eol, /* end of line */ + token_eof /* end of file */ +}; + #ifndef __input_c_seen__ extern int input_getchar(cstate *state); #endif +#ifndef __main_c_seen__ +extern void lwb_error(const char *fmt, ...); +#endif + +#ifndef __lexer_c_seen__ +extern void lexer(cstate *state); +#endif + #endif /* __lwbasic_h_seen__ */