get hello world working again, fix type issues

This commit is contained in:
dtb 2022-12-09 21:03:06 -05:00
parent da0ec7de01
commit add3346ce9
2 changed files with 20 additions and 8 deletions

View File

@ -1,3 +1,4 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -9,16 +10,15 @@ int main(int argc, char **argv){
int c;
void (*op)(struct State *);
s.chart = *argv;
s.chart = *(argv+1);
s.counter = 0;
while((c = getc(stdin)) != EOF){
/* proper exit is ^* */
for(s.counter = 0; ; ++s.counter){
if(s.chart == (char *)0)
return (int)s.hand;
if((op = Ops_lookup(c)) == NULL)
continue;
if((op = Ops_lookup(s.chart[s.counter])) == NULL)
return 127;
else
op(&s);
}
return 1;
}

View File

@ -1,7 +1,19 @@
#if !defined _BLANG_H
# define _BLANG_H
# include <stdint.h>
/* This has to be big enough to hold a char * without degradation.
* Adjust to architecture/system/environment/etc. */
typedef uint64_t hand_t;
/* Just has to be fairly big. (TODO specify) */
typedef uint64_t counter_t;
/* Holds *argv; will not change between environments. */
typedef char * chart_t;
struct State{
unsigned char hand;
char *chart;
chart_t chart;
counter_t counter;
hand_t hand;
};
#endif