comparison 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
comparison
equal deleted inserted replaced
24:421d7ceb4d86 25:87590f43e76d
24 */ 24 */
25 25
26 #ifndef __lwbasic_h_seen__ 26 #ifndef __lwbasic_h_seen__
27 #define __lwbasic_h_seen__ 27 #define __lwbasic_h_seen__
28 28
29 #include <stdint.h>
30
31 /* note: integer and uinteger will be the same for positive values from 0
32 through 0x7FFFFFFF; the unsigned type should be used for doing ascii
33 conversions and then if a negative value was discovered, it should be
34 negated IFF it is in range. */
35
36 union lexer_numbers
37 {
38 uint32_t uinteger;
39 int32_t integer;
40 };
41
29 typedef struct 42 typedef struct
30 { 43 {
31 char *output_file; 44 char *output_file;
32 char *input_file; 45 char *input_file;
33 46
34 int debug_level; 47 int debug_level;
48
49 char *lexer_token_string;
50 union lexer_numbers lexer_token_number;
51 int lexer_token;
52 int lexer_curchar;
53 int lexer_ignorechar;
54
55 int parser_state;
35 56
36 void *input_state; 57 void *input_state;
37 } cstate; 58 } cstate;
59
60 /* parser states */
61 enum
62 {
63 parser_state_global = 0, /* only global decls allowed */
64 parser_state_error
65 };
66
67 /* token types */
68 enum
69 {
70 token_kw_sub, /* SUB keyword */
71 token_kw_function, /* FUNCTION keyword */
72 token_kw_as, /* AS keyword */
73 token_kw_public, /* PUBLIC keyword */
74 token_kw_private, /* PRIVATE keyword */
75 token_kw_params, /* PARAMS keyword */
76 token_kw_returns, /* RETURNS keyword */
77 token_kw_integer, /* INTEGER keyword */
78 token_identifier, /* an identifier (variable, function, etc. */
79 token_char, /* single character; fallback */
80 token_uint, /* unsigned integer up to 32 bits */
81 token_int, /* signed integer up to 32 bits */
82 token_eol, /* end of line */
83 token_eof /* end of file */
84 };
38 85
39 #ifndef __input_c_seen__ 86 #ifndef __input_c_seen__
40 extern int input_getchar(cstate *state); 87 extern int input_getchar(cstate *state);
41 #endif 88 #endif
42 89
90 #ifndef __main_c_seen__
91 extern void lwb_error(const char *fmt, ...);
92 #endif
93
94 #ifndef __lexer_c_seen__
95 extern void lexer(cstate *state);
96 #endif
97
43 #endif /* __lwbasic_h_seen__ */ 98 #endif /* __lwbasic_h_seen__ */