comparison lwbasic/lwbasic.h @ 32:49d608aecc4d

Framework for handling local stack frame and/or variables
author lost@l-w.ca
date Thu, 03 Feb 2011 22:00:47 -0700
parents 574931d87abd
children 890a8f688889
comparison
equal deleted inserted replaced
31:574931d87abd 32:49d608aecc4d
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> 29 #include <stdint.h>
30 30
31 #include "symtab.h"
32
31 /* note: integer and uinteger will be the same for positive values from 0 33 /* 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 34 through 0x7FFFFFFF; the unsigned type should be used for doing ascii
33 conversions and then if a negative value was discovered, it should be 35 conversions and then if a negative value was discovered, it should be
34 negated IFF it is in range. */ 36 negated IFF it is in range. */
35 37
55 int parser_state; 57 int parser_state;
56 58
57 void *input_state; 59 void *input_state;
58 60
59 char *currentsub; 61 char *currentsub;
62 symtab_t *global_syms;
63 symtab_t *local_syms;
64 int returntype;
65 int framesize;
60 } cstate; 66 } cstate;
61 67
62 /* parser states */ 68 /* parser states */
63 enum 69 enum
64 { 70 {
85 token_int, /* signed integer up to 32 bits */ 91 token_int, /* signed integer up to 32 bits */
86 token_eol, /* end of line */ 92 token_eol, /* end of line */
87 token_eof /* end of file */ 93 token_eof /* end of file */
88 }; 94 };
89 95
96 /* symbol types */
97 enum
98 {
99 symtype_sub, /* "sub" (void function) */
100 symtype_func, /* function (nonvoid) */
101 symtype_param, /* function parameter */
102 symtype_var /* variable */
103 };
104
90 #ifndef __input_c_seen__ 105 #ifndef __input_c_seen__
91 extern int input_getchar(cstate *state); 106 extern int input_getchar(cstate *state);
92 #endif 107 #endif
93 108
94 #ifndef __main_c_seen__ 109 #ifndef __main_c_seen__
99 extern void lexer(cstate *state); 114 extern void lexer(cstate *state);
100 extern char *lexer_return_token(cstate *state); 115 extern char *lexer_return_token(cstate *state);
101 #endif 116 #endif
102 117
103 #ifndef __emit_c_seen__ 118 #ifndef __emit_c_seen__
104 extern void emit_prolog(cstate *state, int vis, int framesize); 119 extern void emit_prolog(cstate *state, int vis);
105 extern void emit_epilog(cstate *state, int framesize); 120 extern void emit_epilog(cstate *state);
106 #endif 121 #endif
107 122
108 123
109 #endif /* __lwbasic_h_seen__ */ 124 #endif /* __lwbasic_h_seen__ */