From: Jordan Date: Fri, 16 Dec 2016 20:44:11 +0000 (-0800) Subject: more bug fixes X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=commitdiff_plain;h=c74e77d70a21bd97bc6a8826c9cc278989b9d5bd more bug fixes --- diff --git a/src/ir.c b/src/ir.c index 316486d..d9b1dc5 100644 --- a/src/ir.c +++ b/src/ir.c @@ -65,6 +65,8 @@ push_cdat(struct name*); void pop_cdat(void); void +insert_refid(int); +void insert_link_name(struct name*); void insert_link_namelist(struct name*); @@ -780,6 +782,8 @@ insert_map /* set cdat idx values for both set and odat */ curr_mem_setp->cdat_idx = num_cdats; + /* TODO: INSERT MAP HEIGHT/WIDTH/NAME/FILEPATH INTO ODAT */ + /* Generate refid if needed, put into ref_buf */ if(!refid) @@ -854,6 +858,8 @@ insert_framesheet name_u8_cpy(&curr_modelp->name, model_name); curr_modelp->spritesheet[direction].height = height; curr_modelp->spritesheet[direction].width = width; + /* TODO: INSERT FILEPATH INTO VDAT */ + u8_stpncpy(curr_modelp->spritesheet[direction].filepath, filepath, FPATH_MAX); name_u8_cpy(last_model_name, model_name); @@ -976,7 +982,7 @@ insert_vdat } void -insert_statement +insert_refid ( refid ) int refid; { CURR_SS_ODATP()->refid = refid; diff --git a/src/lexer_fsm.rl b/src/lexer_fsm.rl index e3b075f..96d999a 100644 --- a/src/lexer_fsm.rl +++ b/src/lexer_fsm.rl @@ -32,7 +32,7 @@ int lexer_setstr(uint8_t*, int); action push_ref { PUSHTOK(REF, ttov, ref); } action push_val { PUSHTOK(NUM, ttov, val); } action push_name { printf("Lexer_lexstring:: action:push_name: from %s to %s\n", ts, p); - PUSHTOK(NAME, tton, str); + PUSHTOK(NAME, tton, name); } action push_map { printf("Lexer_lexstring:: action:push_map: pushing '~'\n"); yylval.str = (uint8_t*) '~'; @@ -84,11 +84,9 @@ int lexer_setstr(uint8_t*, int); PUSHTOK(WIDTH, ttov, val); } action push_link {yylval.str = (uint8_t*) '#'; lexer_pushtok(LINK),yylval); } - action lex_error { printf("input error: character %c in filename %s is invalid\n p = %s\n", fc, str, p);} + #action lex_error { printf("input error: character %c in filename %s is invalid\n p = %s\n", fc, str, p);} action p { printf("Lexer_lexstring:: p = %s\n", p);} - # Parses a regular filename (not a mapping) and pushes - # tokens to the parser N = 'N' %push_N; W = 'W' %push_W; S = 'S' %push_S; @@ -98,7 +96,10 @@ int lexer_setstr(uint8_t*, int); SW = 'SW' %push_SW; SE = 'SE' %push_SE; + #what goes in between tokens in a filename tok_delimiter = [_]; + + #types of tokes a filename can contain direction = (N | W | S | E | NW | NE | SW | SE) ; #make sure 0x123123 doesnt get mistaken for a ref dimensions = (digit+ - '0') >set_ts %push_height 'x' (digit+ - '0') >set_ts %push_width; @@ -108,10 +109,10 @@ int lexer_setstr(uint8_t*, int); val = digit+ >set_ts %push_val ; name = (lower+ >set_ts) %push_name ; map = '+MAP' %to(push_map); - tok = name %to(push_name) ; + tok = (name | val | ref | dimensions | map | link | SS | direction); - tok_lexer := ((name | val | ref | dimensions | map) tok_delimiter)+ tok [\0]; + tok_lexer := (tok tok_delimiter)+ tok [\0]; write data; @@ -121,17 +122,17 @@ int lexer_lexstring (uint8_t* str, int size) { uint8_t *p; - uint8_t *ts, *pe, *eof; - int cs, ntok, tok_t, direction; + uint8_t *ts, *pe; + int cs, ntok, tok_t; - ntok = direction = 0; + ntok = 0; p = ts = str; - pe = p + size +1; + pe = p + size + 1; printf("|---Begin lexstring on p = %s, pe = %s.\n",p, pe); %%write init; - %%write exec ; + %%write exec; printf("Ending lexstring of file %s, pushed %d tokens.\n",str, ntok); @@ -139,6 +140,17 @@ lexer_lexstring } +/**************************/ +/****Abandon All Hope******/ +/**************************/ +/*** ***/ +/*** ***/ +/*** ***/ +/*** ***/ + + +#if 0 + %%{ machine setdirection; @@ -166,9 +178,11 @@ lexer_lexstring main := direction; write data; - + + }%% + int lexer_setdirection (uint8_t* str, int size) @@ -191,16 +205,6 @@ lexer_setdirection -/**************************/ -/****Abandon All Hope******/ -/**************************/ -/*** ***/ -/*** ***/ -/*** ***/ -/*** ***/ - - -#if 0 %%{ machine setstr; diff --git a/src/parser.y b/src/parser.y index e509890..e47ae97 100644 --- a/src/parser.y +++ b/src/parser.y @@ -15,7 +15,6 @@ extern void push_cdat(struct name*); extern void insert_vdat(void); extern void insert_refid(int); - extern void insert_refid(int); extern void insert_set_name(struct name*); extern void insert_set_namelist(struct name*); extern void insert_link_name(struct name*);