ir compiling!
authorJordan <jordanlavatai@gmail.com>
Sat, 14 Jan 2017 07:06:25 +0000 (23:06 -0800)
committerJordan <jordanlavatai@gmail.com>
Sat, 14 Jan 2017 07:06:25 +0000 (23:06 -0800)
src/apc.h
src/ir.c
src/ir.h
src/lexer.c
src/lexer.rl
src/parser.y

index a994d12..348712c 100644 (file)
--- a/src/apc.h
+++ b/src/apc.h
@@ -5,27 +5,6 @@
 enum frame_facing { SFACE, SWFACE, WFACE, NWFACE, NFACE, NEFACE, EFACE, SEFACE, FACING_MAX };
 typedef enum frame_facing apc_facing;
 
-#define BUF_SIZE 256
-#define MAX_SETS 256
-#define MAX_ELES 256
-#define MAX_QUADS 256
-#define MAX_MODELS 256
-#define MAX_MODEL_LEN 256
-#define MAX_MAPS 8
-#define MAX_POSTS 256
-#define MAX_CLASS_DEPTH 64
-#define MAX_CLASSES 64
-#define MAX_FRAMES 256
-#define PTRS_IN_PAGE 1024
-#define MAX_CHUNKS 256
-#define PAGES_PER_CHUNK 16
-#define MAX_DEPTH 8
-//irmem.c
-#define PAGES_PER_CHUNK 16
-#define MAX_NAME_LEN 128
-#define MAX_DEPTH 8
-//lexer.c
-#define FNAME_MAX 1024
-#define FPATH_MAX 8192
+#define APC_NAME_MAX 64
 
 #endif //_APC_H_
index 4cec206..0f8a461 100644 (file)
--- a/src/ir.c
+++ b/src/ir.c
@@ -36,9 +36,6 @@ struct pagelist_t {
   struct pagenode_t* root, * head;\r
   size_t             pagesize;\r
 };\r
-/* Set link data */\r
-enum dtype { FSDAT, MSDAT, ADAT, LDAT, FBDAT };\r
-enum ltype { OLINK, MLINK, VLINK, ALINK };\r
 struct ir_namelist_t;\r
 struct ir_namelist_t\r
 { struct ir_namelist_t* nextsib;\r
index 7c1f4b3..590710e 100644 (file)
--- a/src/ir.h
+++ b/src/ir.h
@@ -5,7 +5,7 @@
 \r
 \details The IR serves as a storage structure that is populated during the\r
          parsing of the input directory structure. After parsing is complete,\r
-         the IR will be condensed (removed of excess allocated space) and then\r
+         the IR will be condensed (removed of excess allocated space) and then \r
          output as the input for the engine. In this file we describe the\r
          semantic actions that are called at each step, and the memory buffers\r
          that they populate.  See parser.y for the description on how the input\r
@@ -27,6 +27,9 @@ typedef struct ir_set_t*     ir_set;
 typedef struct ir_class_t*   ir_class;\r
 typedef struct ir_setld_t*   ir_setld;\r
 typedef struct ir_classld_t* ir_classld;\r
+\r
+enum dtype { FSDAT, MSDAT, ADAT, LDAT, FBDAT };\r
+enum ltype { OLINK, MLINK, VLINK, ALINK };\r
 /* Classes and Sets\r
    Classes are rooted at a special root class, representing the current working\r
    directory at scan-time, named ".".  The root class can always be identified\r
@@ -68,6 +71,7 @@ void       ir_data_assign_path(ir_setdata,uint8_t*);
 ir_setdata ir_framesheet(uint8_t*, apc_facing, int,int);\r
 ir_setdata ir_mapsheet(uint8_t*, apc_facing, int,int);\r
 ir_setdata ir_audio(uint8_t*);\r
+ir_setdata ir_link(enum ltype, ir_setld, uint8_t*);\r
 ir_setdata ir_link_odat(ir_setld);\r
 ir_setdata ir_link_vdat(ir_setld,uint8_t*);\r
 ir_setdata ir_link_mdat(ir_setld,uint8_t*);\r
index 9e08e86..fe4eff7 100644 (file)
@@ -48,13 +48,15 @@ int lexer_lexfile
 ( uint8_t const* filename )
 { uint8_t const* last_period,* iter;
   int            ntok;
+  union YYSTYPE tok_val;
   last_period = NULL;
   for (iter = filename; *iter; iter++)
     if (*iter ==  '.')
       last_period = iter;
   if (last_period)
     { ntok = lexer_lexstring(filename, (int)(last_period - filename));
-      PUSHTOK(PATH,filename);
+      tok_val.str = filename;
+      PUSHTOK(PATH,&tok_val);
       return ntok + 1;
     }
   return lexer_lexstring(filename, (int)(iter - filename));
index 3440e24..f6d25aa 100644 (file)
@@ -38,10 +38,11 @@ yycstate* apc_cstate;
                                }
                              exit(1);
                            }
-                         yypush_parse(apc_pstate, REF, &ref, apc_cstate);
+                         tok_val.ref = ref;
+                         yypush_parse(apc_pstate, REF, &tok_val, apc_cstate);
                           ntok++;
                        }
-  action push_link      { yypush_parse(apc_pstate, LINK, (YYSTYPE) 0, apc_cstate);}
+  action push_link      { tok_val.val = 0; yypush_parse(apc_pstate, LINK, &tok_val , apc_cstate);}
   action push_val       { int val;
                           te = NULL; errno = 0;
                           val = strtoll((char*)ts,(char**)&te,10);
@@ -49,52 +50,65 @@ yycstate* apc_cstate;
                            { fprintf(stderr, "strtoll could not parse %s\n", (char*)str);
                              exit(1);
                            }
-                         yypush_parse(apc_pstate, NUM, &val, apc_cstate);
+                         tok_val.val = val;
+                         yypush_parse(apc_pstate, NUM, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_name      { printf("Lexer_lexstring:: action:push_name: from %s to %s\n", ts, p);
-                          yypush_parse( apc_pstate, NAME, strdndup(ts, p-ts), apc_cstate);
+                          *p = '\0';
+                         tok_val.str = ts;
+                          yypush_parse( apc_pstate, NAME, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_map       { printf("Lexer_lexstring:: action:push_map: pushing map token\n");
-                          yypush_parse(apc_pstate, MAP, (uint8_t*) '~', apc_cstate);
+                          tok_val.str = (uint8_t*) '~';
+                          yypush_parse(apc_pstate, MAP, &tok_val, apc_cstate);
                           ntok++;
                        }
   action set_ts         { printf("Lexer_lexstring:: action:set_ts. ts = %s\n", p); ts = p; }
   action push_SS        { printf("Lexer_lexstring:: action:push_SS. p = %s\n",p);
-                          yypush_parse(apc_pstate, SS, (uint8_t*) "SS", apc_cstate);
+                          tok_val.str = (uint8_t*) "SS";
+                          yypush_parse(apc_pstate, SS, &tok_val, apc_cstate);
                           ntok++;
                         }
   action push_S         { printf("Lexer_lexstring:: action:push_S. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 0, apc_cstate);
+                          tok_val.val = 0;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_SW        { printf("Lexer_lexstring:: action:push_SW. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 1, apc_cstate);
+                          tok_val.val = 1;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                        }
   action push_W         { printf("Lexer_lexstring:: action:push_W. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 2, apc_cstate);
+                          tok_val.val = 2;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_NW        { printf("Lexer_lexstring:: action:push_NW. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 3, apc_cstate);
+                          tok_val.val = 3;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_N         { printf("Lexer_lexstring:: action:push_N. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 4, apc_cstate);
+                          tok_val.val = 4;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_NE        { printf("Lexer_lexstring:: action:push_NE. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 5, apc_cstate);
+                          tok_val.val = 5;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_E         { printf("Lexer_lexstring:: action:push_N. p = %s\n", p);
-                          yypush_parse(apc_pstate, FACING, (YYSTYPE) 6, apc_cstate);
+                          tok_val.val = 6;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action push_SE        { printf("Lexer_lexstring:: action:push_N. p = %s\n", p);
-                          ypush_parse(apc_pstate, FACING, (YYSTYPE) 7, apc_cstate);
+                          tok_val.val = 7;
+                          yypush_parse(apc_pstate, FACING, &tok_val, apc_cstate);
                          ntok++;
                         }
   action ref_error      { printf("ref from %s to %s has an inappropriate amount of hex digits, it must have eight.\n", ts, p);
@@ -135,12 +149,14 @@ int lexer_lexstring
   int size
 )
 { uint8_t *p; 
-  uint8_t *ts, *pe, *te;
-  int cs, ntok, eof;//, tok_t;
+  uint8_t *ts, *pe, *te, *eof;
+  int cs, ntok;
+  union YYSTYPE tok_val; 
 
   ntok = 0;
   p = ts = str;
-  pe = p + size + 1;
+  pe = eof =  p + size + 1;
+  
 
   printf("|---Begin lexstring on p = %s, pe = %s.\n",p, pe);
 
index 959890d..07cf5b8 100644 (file)
@@ -100,13 +100,13 @@ data_spec:
   SS NAME frame_spec     { $$ = ir_framesheet($2,$3.d,$3.w,$3.h); }
 | MAP NAME frame_spec    { $$ = ir_mapsheet($2,$3.d,$3.w,$3.h); }
 | AUDIO NAME             { $$ = ir_audio($2); }
-| LINK set_ld            { $$ = ir_link_odat($2); }
-| LINK set_ld MAP        { $$ = ir_link_mdat($2,NULL); }
-| LINK set_ld MAP NAME   { $$ = ir_link_mdat($2,$4); }
-| LINK set_ld SS         { $$ = ir_link_vdat($2,NULL); }
-| LINK set_ld SS NAME    { $$ = ir_link_vdat($2,$4); }
-| LINK set_ld AUDIO      { $$ = ir_link_adat($2,NULL); }
-| LINK set_ld AUDIO NAME { $$ = ir_link_adat($2,$4); }
+| LINK set_ld            { $$ = ir_link(OLINK, $2, NULL); }
+| LINK set_ld MAP        { $$ = ir_link(MLINK, $2,NULL); }
+| LINK set_ld MAP NAME   { $$ = ir_link(MLINK, $2,$4); }
+| LINK set_ld SS         { $$ = ir_link(VLINK, $2,NULL); }
+| LINK set_ld SS NAME    { $$ = ir_link(VLINK, $2,$4); }
+| LINK set_ld AUDIO      { $$ = ir_link(ALINK, $2,NULL); }
+| LINK set_ld AUDIO NAME { $$ = ir_link(ALINK, $2,$4); }
 ;
 
 set_spec: