HGADDR := https://hg.libsdl.org/SDL
# No autogen for SDL
undefine AUTOGEN
-# Ensure we have our other libraries, and their associated
-# accutrements (like jpeg/tiff, etc from SDL2_image)
LIBDEPS := SDL2_image SDL2_ttf SDL2_net
+LINK_ORDER :=
# Modifications to the build process when using specific compilers
define emccMOD =
$(eval CONFIGURE += --enable-joystick=no)
HGADDR := https://hg.libsdl.org/SDL_image
# SDL2_image depends on zlib, libpng, libtiff libpjeg, and libwebp
LIBDEPS := webp png tiff z
+LINK_ORDER := SDL2 webp png tiff z
################################################################################
# Download location
HGADDR := https://hg.libsdl.org/SDL_net
-
+# Dependency libraries
+LINK_ORDER := SDL2
################################################################################
# Download location
HGADDR := https://hg.libsdl.org/SDL_ttf
+
+LINK_ORDER := SDL2
################################################################################
# Desc: Make functions for creating rules (Make making Make)
-# Author: Ken Grimes
+# Author: ksg
# Date: 2016
################################################################################
# This file consists of library functions for make-making-make functionality
# available in the current working directory of the source file(i.e. if you
# '#include "something.h"' in 'mymodule/horseradish.c', you would expect to
# include 'mymodule/something.h'. this check lets that happen), otherwise it is
-# some kind of user error #######################################################
+# some kind of user error ######################################################
define SRC_LANG_RULE =
$(if $($1),,$(eval $1 := t)\
$(eval MOD := $(filter $(MODULES),$(firstword $(subst /, ,$(subst $(SRC_DIR),,$(dir $1))))))\
$(eval ALLDEPS := $(subst $(dep),\
$(if $(wildcard $(LIBINC_DIR)/$(dep)),$(LIBINC_DIR),$(SRC_DIR))/$(dep),$(ALLDEPS))))
-# Find any deps that aren't built yet, which the compiler has flagged
-# as missing, but which we know the expected location of libs for
-# this language should have their includes in 'LIBINC_DIR'
+# Find any deps that aren't built yet, which the compiler has flagged as
+# missing, but which we know the expected location of libs for this language
+# should have their includes in 'LIBINC_DIR'
$(eval BUILDDEPS := $(filter $($2_LIBS:%=%/%),$(ALLDEPS)))
$(eval ALLDEPS := $(filter-out $(BUILDDEPS),$(ALLDEPS)) $(BUILDDEPS:%=$(LIBINC_DIR)/%))
# Object for $1
$(DBG_OBJ): $(ALLDEPS) | $(dir $(DBG_OBJ))
$($2_C) $$($2_FLAGS) $(FLG) -Og -g$($2_DBG) -c -o $$@ $1
))
-#/SRC_LANG_RULE##################################################################
+#/SRC_LANG_RULE#################################################################
endef
-#SRC_LANG_DRVRULE################################################################
-# establish a build and link rule given a source driver and language ############
+#LANG_LIB_DEPLIST###############################################################
+# Crawl the tree of dependencies for static libraries, terminating at root
+# dependencies or any dynamic link #############################################
+define LANG_LIB_DEPLIST =
+$(if $($2_INIT),,$(call LANG_LIB_INIT,$1,$2))
+$(foreach dep,$($2_DEPS)
+endef
+
+
+define LIB_PARSELINKS =
+$(
+$(eval DLIBS := $(patsubst +%,%,$(filter +%,$(LINK_ORDER))))
+$(eval SLIBS := $(patsubst -%,%,$(filter -%,$(LINK_ORDER))))
+$(foreach ldobj,$(patsubst +%,%,$(LINK_ORDER:-%=%)),
+$(if $(or $(filter $(ldobj),$(DLIBS)),$(and $(filter-out $(SLIBS),$(ldobj)), $(filter $(ldobj),$($($2_C)_LDLIBS)))),
+$(eval DRIVER_LDINFO += -l$(ldobj)),
+$(if $(filter $(ldobj),$(MODULES)),
+$(eval DRIVER_LDINFO += $(SRC_DIR)/$(ldobj).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(SRC_DIR)/.$($2_DBG)/$(ldobj).$($2_AROBJ)),
+$(if $($(ldobj)_INIT),,$(call LANG_LIB_INIT,$2,$(ldobj),$1))
+$(foreach dep,$($(ldobj)_DEPS)
+
+endef
+
+#SRC_LANG_DRVRULE###############################################################
+# establish a build and link rule given a source driver and language ###########
define SRC_LANG_DRVRULE =
$(eval DRIVER_NAME := $(basename $(notdir $1)))
$(eval DRIVER_TARG := $(1:$(SRC_DIR)/%.$2=$(ROOT_DIR)/%$($2_OUT)))
# available, all libraries will attempt static linking - and if those static
# libs are not available, the system will attempt to retrieve the source code
# and build the static lib
-$(eval DRIVER_LDFILE := $(1:%.$2=%.ld))
+$(eval DRIVER_LDFILE := $(1:%.$2=%.mk))
$(if $(filter test%,$(DRIVER_NAME)),
-$(eval DRV_LD := $(subst $(DRIVER_NAME).$2,$(DRIVER_NAME:test%=%).ld,$1))
+$(eval DRV_LD := $(subst $(DRIVER_NAME).$2,$(DRIVER_NAME:test%=%).mk,$1))
$(if $(wildcard $(DRV_LD)),
$(eval DRIVER_LDFILE := $(DRV_LD))
))
-$(eval $1_LD := $(file <$(DRIVER_LDFILE)))
+$(eval undefine LINK_ORDER)
+$(eval undefine LINK_ORDER_D)
+$(eval $(file <$(DRIVER_LDFILE)))
$(eval undefine DRIVER_LDINFO)
$(eval undefine DRIVER_LDINFO_D)
$(eval DRIVER_LDINFO += $(1:%.$2=%.$($2_OBJ)))
$(eval DRIVER_LDINFO_D += $(1:$(dir $1)%.$2=$(dir $1).$($2_DBG)/%.$($2_OBJ)))
-$(foreach ldobj,$($1_LD),
+$(eval DLIBS := $(patsubst +%,%,$(filter +%,$(LINK_ORDER))))
+$(eval SLIBS := $(patsubst -%,%,$(filter -%,$(LINK_ORDER))))
+$(foreach ldobj,$(patsubst +%,%,$(LINK_ORDER:-%=%)),
+$(if $(or $(filter $(ldobj),$(DLIBS)),$(and $(filter-out $(SLIBS),$(ldobj)), $(filter $(ldobj),$($($2_C)_LDLIBS)))),
+$(eval DRIVER_LDINFO += -l$(ldobj)),
+$(if $(filter $(ldobj),$(MODULES)),
+$(eval DRIVER_LDINFO += $(SRC_DIR)/$(ldobj).$($2_AROBJ))
+$(eval DRIVER_LDINFO_D += $(SRC_DIR)/.$($2_DBG)/$(ldobj).$($2_AROBJ)),
+$(if $($(ldobj)_INIT),,$(call LANG_LIB_INIT,$2,$(ldobj),$1))
+$(foreach dep,$($(ldobj)_DEPS)
+
$(if $(filter -l%,$(ldobj)),
$(eval ldlibname := $(ldobj:-l%=%))
$(if $(filter $(ldlibname),$($($2_C)_LDLIBS)),
MKINSTALL := make -k install
MKCLEAN := make clean
MKDBGCMD := make -k
-LIBDEPS :=
+LINK_ORDER :=
LIBLANGS := c cpp go
LIBLDPATH := $(if $($($1_C)_LD),$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):,/usr/lib:)$(abspath $(LIB_DIR)))
# One of these must be defined in the .mk file imported
$(foreach var, WEBTARG WEBINIT CVSGET CVSPASS CONFIGUREDBG,
$(eval undefine $(var)))
)
-# If there is a .mk file for this lib, import it. Otherwise, we'll try to link
-# it later, unless there is no linker for the language's compiler.
+# If there is a .mk file for this lib, import it. Otherwise, inform user of
+# error
$(if $(wildcard $(CONF_DIR)/$2.mk),$(eval $(file <$(CONF_DIR)/$2.mk)),\
-$(if $($($1_C)_LD),\
-$(warning No $2.mk for lib$2, attempting to link from the system),\
-$(error No $2.mk for lib$2 and '$($1_C)' is not configured for linking)))\
+$(error Expected $(CONF_DIR)/$2.mk for lib$2))
# Add dependencies we found (potentially recursively, ignore repeats until later
# so we can preserve ordering information for interdependency build ordering)
-$(if $(LIBDEPS),\
+$(eval undefine $2_LDINFO)
+$(foreach ldobj,$(LINK_ORDER),\
+$(eval $2_LDINFO +=
+)
+$(if $(LINK_ORDER),\
$(eval $1_LIBS += $(LIBDEPS))\
$(if $3,$(eval $3_DEPS += $(LIBDEPS)))\
$(eval $2_DEPS += $(LIBDEPS))\
endef
# Create a phony target and rule for the specified source driver
-define DRVSRC_DRIVERPHONY
+define DRVSRC_DRIVERPHONY =
$(eval PH_TARG := $(basename $(notdir $1)))
$(eval PH_TARGS += $(PH_TARG))
$(eval PH_LANG := $(lastword $(subst ., ,$1)))
CONFIGURE += && sed -i -e 's@^LIBS \= \-lz@LIBS = -L$(abspath $(LIB_DIR))@g' ./Makefile
# Don't check
MKCMD := make -k
+# png can be built with zlib for efficiency
+LINK_ORDER := z
+#+STARTUP: indent
* Project Deadlines
** October
/env/deco/
name of archetype
numbers signify variants
-alpha+ . '_m' . [digit]+ signifies mapping varriants
+alpha+ . '_m' . [digit]+ signifies mapping varriant
+***** TODO Add x,y to filenames
**** TODO Scanner :ATTACH:
:PROPERTIES:
:Attachments: scanner.c
:Attachments: parser.y irmem.c ir.c ir.h
:ID: fb24c302-4743-4a45-845a-4249d2b1a378
:END:
+***** TODO Add mdats to IR to handle multiple mappings for archetypes
+ CLOCK: [2016-10-20 Thu 20:12]--[2016-10-20 Thu 23:12] => 3:00
+ Recording: Lexer Lex(Mapfile)
+ Maps can have variants and animations. Adding a state machine
+ into the lexer that will parse png files and return its frame information.
+ CLOCK: [2016-10-20 Thu 19:28]--[2016-10-20 Thu 19:46] => 0:18
+ insert_mdat now compiles
+ CLOCK: [2016-10-20 Thu 18:10]--[2016-10-20 Thu 18:53] => 0:43
+ CLOCK: [2016-10-20 Thu 15:24]--[2016-10-20 Thu 16:24] => 1:00
+ CLOCK: [2016-10-20 Thu 13:13]--[2016-10-20 Thu 14:10] => 0:57
+ #+BEGIN: clocktable :maxlevel 2 :scope subtree
+ #+CAPTION: Clock summary at [2016-10-20 Thu 14:10]
+ | Headline | Time |
+ |--------------+--------|
+ | *Total time* | *0:57* |
+ |--------------+--------|
+ #+END:
+****** DONE Create variant_list in odat
+****** DONE Init num_variants
+****** DONE Create mdat struct
+****** DONE Create new quad struct
+****** DONE Change insert_quad() to insert x,y,z, and ref_id
+****** DONE Change parser.y to include quad_list
+****** DONE In elements, populate parent_id with set. In sets, set parent_id to null.
+****** DONE Incorporate mdat into parser and ir
+****** TODO Implement Lexer_lexmapfile
+Where are we storing the map file animations? Mdats will have framesheets.
+****** TODO Remove set name token in elements being passed back
+****** DONE Lexer_lex should pass control to lexer_lexmapfile
+When it recognizes a '_m\0', call lexer_lexmapfile
+The const str passed to lexer_lex is screwing up the state machine because
+the suffix isnt truly pruned (so pe == . instead of \0)
+Mappings come before archetypes.
+****** TODO
+****** TODO
+****** TODO
+****** TODO
+****** TODO
+parent_id should be pointer or ref_id? pointer
+Root mandatory, hitbox optional? Only a variant list?
+mopen/close in skeleton rule requires lexer to pass a operator
+for every new skeleton
+inesrt_mdat() needs more?
+
**** TODO Output
DEADLINE: <2016-10-20 Thu>
*** TODO Test Suite for APC
+* Notes
+11/2 Changes to grammar
+ Mapfiles and vdats are now going to be extracted at binary output time. This means
+ that we dont have to handle text strings in the grammar, just filename and directory structure.
+ E.g. mdats (which were mapfile data structs and are now called variants), no longer consist of quad
+ lists but of the height/width of the frames inside the variant and the name of the filename so that
+ it can be processed later at binary out. This is also true for vdats, which used to consist of spritesheets
+ and are now just a height/width of the frames and the name of the file.
+
+Filepath is stored in vdat/variant. When should this get passed back? After height/width has
+been lexed.
+
+Theres a filename for every element. Not true for a set.
+
+Need to finish insert_vdat, insert_variant, lexfilename, ?
+* Current TODO list
+** TODO Make Null vdat
+** DONE Fix all shift/reduce errors in new grammar
+** DONE Add map variant changes (create new odat, share vdat)
+** DONE Add map operator changes to lexer.c
+** DONE Rename mapping files
+** TODO Review parser.y, irmem.c, ir.c, ir.h, lexer.c
----------------------------------------------------------------------------*/\r
#include <errno.h>\r
#include <stdio.h>\r
+#include <unitypes.h> //uint8_t as a char\r
+#include <unistr.h> //u32_cpy\r
#include <stdint.h> //uint64_t\r
-#include <string.h> //memmove\r
#include <stdlib.h> //malloc\r
#include <apc/ir.h>\r
\r
-\r
+//extern\r
+//scanner_scanpixels(int*, int);\r
\r
/* functions needed from irmem.c */\r
extern\r
alloc_odat(void);\r
\r
extern\r
-void\r
+struct vdat*\r
alloc_vdat(void);\r
\r
+extern\r
+void\r
+alloc_mdat(void);\r
+\r
extern\r
struct link*\r
alloc_link(void);\r
struct odat*\r
curr_odat(void);\r
\r
+extern\r
+struct map*\r
+curr_map(void);\r
+\r
+extern\r
+struct map*\r
+alloc_map(void);\r
+\r
extern\r
struct vdat*\r
curr_vdat(void);\r
struct model*\r
curr_model(void);\r
\r
+extern\r
+struct quad*\r
+curr_quad(void);\r
+\r
/* struct definitions needed from irmem.c */\r
extern int num_cdats;\r
extern struct cdat** cdat_stackp;\r
extern struct odat* curr_set_odatp;\r
-extern uint64_t ss_ref_id;\r
+extern int ss_ref_id;\r
\r
extern int num_vdats;\r
/* Dynamically allocate memory for a class data structure,\r
which is a list of all allocated cdats*/\r
void\r
push_cdat\r
-( char* name\r
+( uint8_t* name\r
)\r
{\r
struct cdat* curr_cdatp;\r
\r
curr_cdatp = alloc_cdat();\r
\r
- memmove(curr_cdatp->name, name, 32);\r
+ u8_cpy(curr_cdatp->name, name, 32);\r
curr_cdatp->idx = num_cdats;\r
\r
/* Set the cdat as a subclass of the previous cdat */\r
cdat_stackp--;\r
}\r
\r
+\r
+/* Every odat has a single map variant. We track the odats that have related map variants\r
+ by adding the name of the map to the end of the odat name. E.g. for an odat with name\r
+ A and map variants a,b,c we get A_a, A_b, A_c. We create new odats for each map variant*/\r
+void\r
+insert_map\r
+( uint8_t* name,\r
+ int height,\r
+ int width,\r
+ uint8_t* filepath\r
+)\r
+{\r
+ struct odat* curr_odatp;\r
+ int curr_odat_vdatid;\r
+\r
+ curr_odatp = curr_odat();\r
+\r
+ curr_odat_vdatid = curr_odatp->vdat_id;\r
+ \r
+\r
+ \r
+ if(curr_odatp->map.name[0] != 0) //odat already has a map so make a new odat\r
+ { curr_odatp = alloc_odat();\r
+ curr_odatp->vdat_id = curr_odat_vdatid;\r
+ }\r
+ /* Add a delimiter '_' in between odat name and map variant name */\r
+ u8_strcat(curr_odatp->map.name, (uint8_t*) '_'); \r
+ u8_strcat(curr_odatp->map.name, name);\r
+ \r
+ u8_strcpy(curr_odatp->map.filepath, filepath);\r
+ curr_odatp->map.height = height;\r
+ curr_odatp->map.width = width;\r
+ \r
+}\r
+ \r
+\r
+\r
+\r
+\r
/* Called in the reduction of a set. While both odats (eles and sets)\r
have identical label terminals, we are unable to give a single grammatical rule\r
for both due to how we allocate odats in the odat buf. Due to the\r
\r
void\r
insert_set_label\r
-( char* name,\r
- uint64_t ref_id\r
+( uint8_t* name,\r
+ int ref_id\r
)\r
{\r
\r
curr_setp = curr_set();\r
curr_set_odatp = alloc_odat();\r
\r
- memmove(curr_set_odatp->name, name, 32);\r
- memmove(curr_setp->name, name, 32);\r
+ u8_cpy(curr_set_odatp->name, name, 32);\r
+ u8_cpy(curr_setp->name, name, 32);\r
+ curr_set_odatp->parent_odatp = NULL;\r
+ curr_set_odatp->map.name[0] = 0;\r
\r
if(ref_id != -1)\r
{ curr_set_odatp->ref_id = ref_id;\r
for another set. Allocate the memory for the set so taht it can be populated*/\r
void\r
insert_set_olink\r
-( uint64_t ref_id\r
+( int ref_id\r
)\r
{\r
struct set* curr_setp;\r
\r
void\r
insert_set_vlink\r
-( uint64_t ref_id,\r
- char* anim_name\r
+( int ref_id,\r
+ uint8_t* anim_name\r
)\r
{\r
struct cdat* curr_cdatp;\r
curr_linkp->type = 2;\r
/* Store the target odat information*/\r
curr_linkp->link_t.vlink.ref_id = ref_id;\r
- memmove(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
+ u8_cpy(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
/* Store the linking odat/cdat information */\r
curr_linkp->classp = curr_cdatp;\r
curr_linkp->odatp = curr_odatp;\r
/* Svlinks dont have animation names */\r
void\r
insert_set_svlink\r
-( uint64_t ref_id \r
+( int ref_id \r
)\r
{\r
struct cdat* curr_cdatp;\r
void\r
insert_set\r
()\r
-{ uint64_t ref_id;\r
+{ int ref_id;\r
struct odat* curr_odatp;\r
struct cdat* curr_cdatp;\r
struct set* curr_setp;\r
struct ref* curr_refp;\r
struct vdat* curr_vdatp;\r
\r
- curr_odatp = curr_set_odatp; //allocated at insert_set_label, preserved in global space\r
+ curr_odatp = curr_set_odatp; //allocated at insert_set_label\r
curr_cdatp = curr_cdat();\r
curr_setp = curr_set();\r
prev_refp = curr_ref();\r
curr_vdatp->creator = curr_set_odatp;\r
\r
curr_setp->cdat_idx = curr_cdatp->idx; //does a set need its class idx?\r
- memmove(curr_setp->name, curr_odatp->name, 32);\r
+ u8_cpy(curr_setp->name, curr_odatp->name, 32);\r
curr_cdatp->num_sets++;\r
\r
curr_odatp->cdat_idx = curr_cdatp->idx;\r
the functions to use via curr_odat(). */\r
void\r
insert_ele_label\r
-( char* name,\r
- uint64_t ref_id\r
+( uint8_t* name,\r
+ int ref_id\r
)\r
{\r
struct odat* curr_odatp;\r
\r
curr_odatp = alloc_odat();\r
\r
- memmove(curr_odatp->name, name, 32);\r
+ u8_cpy(curr_odatp->name, name, 32);\r
+ curr_odatp->map.name[0] = 0;\r
\r
if(ref_id != -1)\r
curr_odatp->ref_id = ref_id;\r
the ref_id to the corresponding odat. */\r
void\r
insert_ele_olink\r
-( uint64_t ref_id\r
+( int ref_id\r
)\r
{\r
/* Do nothing because we already know the ref_id that\r
\r
void\r
insert_ele_vlink\r
-( uint64_t ref_id,\r
- char* anim_name\r
+( int ref_id,\r
+ uint8_t* anim_name\r
)\r
{\r
struct cdat* curr_cdatp;\r
curr_linkp->set_idx = curr_cdatp->num_sets;\r
//curr_linkp->ele_idx = curr_setp->num_ele;\r
curr_linkp->link_t.vlink.ref_id = ref_id;\r
- memmove(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
+ u8_cpy(curr_linkp->link_t.vlink.anim_name, anim_name, 32);\r
\r
}\r
\r
void\r
insert_ele_svlink\r
-( uint64_t ref_id\r
+( int ref_id\r
)\r
{\r
struct cdat* curr_cdatp;\r
void\r
insert_ele()\r
{\r
- uint64_t ref_id;\r
+ int ref_id;\r
struct cdat* curr_cdatp;\r
struct odat* curr_odatp;\r
struct vdat* curr_vdatp;\r
/* Populate odat for ele */\r
curr_odatp->cdat_idx = curr_cdatp->idx;\r
curr_odatp->refp = curr_refp;\r
+ curr_odatp->parent_odatp = curr_set_odatp;\r
\r
ref_id = curr_odatp->ref_id;\r
\r
}\r
\r
void\r
-insert_quad\r
-( void* quad_filep\r
-)\r
+insert_vdat\r
+(uint8_t* filename, int height, int width, uint8_t* filepath)\r
{\r
- struct odat* curr_odatp;\r
-\r
- curr_odatp->quad_filep = quad_filep;\r
-}\r
-\r
-/* Inserting the hitbox into the set\r
- odat. Elements that don't have\r
- a hitbox will use the sets root. */\r
-void\r
-insert_hitbox\r
-( int hitbox\r
-)\r
-{ struct odat* curr_odatp;\r
-\r
- curr_odatp = curr_odat();\r
- curr_odatp->hitbox = hitbox;\r
-}\r
-\r
-/* Inserting the root into the set\r
- odat. Elements that don't have\r
- a root will use the sets root. */\r
-void\r
-insert_root\r
-( int x,\r
- int y,\r
- int z\r
-)\r
-{ struct odat* curr_odatp;\r
-\r
- curr_odatp = curr_odat();\r
- curr_odatp->root.x = x;\r
- curr_odatp->root.y = y;\r
- curr_odatp->root.z = z;\r
-}\r
-\r
-\r
-void\r
-insert_framesheet\r
-( char direction,\r
- char* name,\r
- uint64_t ref_id,\r
- int height ,\r
- int width,\r
- int num_frames\r
-)\r
-{ struct vdat* curr_vdatp;\r
- struct model* curr_modelp;\r
+ struct vdat* curr_vdatp;\r
+ int filename_len, filepath_len;\r
\r
- curr_vdatp = curr_vdat();\r
- curr_modelp = curr_model();\r
+ curr_vdatp = alloc_vdat();\r
\r
- curr_modelp->spritesheet[(int)direction].height = height;\r
- curr_modelp->spritesheet[(int)direction].width = width;\r
- curr_modelp->spritesheet[(int)direction].num_frames = num_frames;\r
- curr_vdatp->num_models++;\r
+ u8_strcpy(curr_vdatp->filename, filename);\r
+ u8_strcpy(curr_vdatp->filepath, filepath);\r
+ curr_vdatp->height = height;\r
+ curr_vdatp->width = width;\r
+ curr_vdatp->creator = curr_odat();\r
+ \r
}\r
\r
-void\r
-insert_frame_pointer\r
-( char direction,\r
- void* frame\r
-)\r
-{ struct model* curr_modelp;\r
-\r
- curr_modelp = curr_model();\r
\r
- curr_modelp->spritesheet[(int)direction].frames[curr_modelp->spritesheet[(int)direction].num_frames++] = frame;\r
-}\r
+ \r
+\r
+/* void */\r
+/* insert_quad */\r
+/* ( int x, int y, int z, int ref_id */\r
+/* ) */\r
+/* { */\r
+/* struct quad* curr_quadp; */\r
+\r
+/* curr_quadp = curr_quad(); */\r
+\r
+/* curr_quadp->x = x; */\r
+/* curr_quadp->y = y; */\r
+/* curr_quadp->z = z; */\r
+/* curr_quadp->ref_id = ref_id; */\r
+ \r
+\r
+\r
+/* } */\r
+\r
+/* /\* serting the hitbox into the set */\r
+/* odat. Elements that don't have */\r
+/* a hitbox will use the sets root. *\/ */\r
+/* void */\r
+/* insert_hitbox */\r
+/* ( int hitbox */\r
+/* ) */\r
+/* { struct odat* curr_odatp; */\r
+\r
+/* curr_odatp = curr_odat(); */\r
+/* curr_odatp->hitbox = hitbox; */\r
+/* } */\r
+\r
+/* /\* Inserting the root into the set */\r
+/* odat. Elements that don't have */\r
+/* a root will use the sets root. *\/ */\r
+/* void */\r
+/* insert_root */\r
+/* ( int x, */\r
+/* int y, */\r
+/* int z */\r
+/* ) */\r
+/* { struct odat* curr_odatp; */\r
+\r
+/* curr_odatp = curr_odat(); */\r
+/* curr_odatp->root.x = x; */\r
+/* curr_odatp->root.y = y; */\r
+/* curr_odatp->root.z = z; */\r
+/* } */\r
+\r
+\r
+\r
+/* void */\r
+/* insert_framesheet */\r
+/* ( uint8_t direction, */\r
+/* uint8_t* name, */\r
+/* int ref_id, */\r
+/* int height , */\r
+/* int width, */\r
+/* int num_frames */\r
+/* ) */\r
+/* { struct vdat* curr_vdatp; */\r
+/* struct model* curr_modelp; */\r
+\r
+/* curr_vdatp = curr_vdat(); */\r
+/* curr_modelp = curr_model(); */\r
+\r
+/* curr_modelp->spritesheet[(int)direction].height = height; */\r
+/* curr_modelp->spritesheet[(int)direction].width = width; */\r
+/* curr_modelp->spritesheet[(int)direction].num_frames = num_frames; */\r
+/* curr_vdatp->num_models++; */\r
+/* } */\r
+\r
+/* void */\r
+/* insert_frame_pointer */\r
+/* ( uint8_t direction, */\r
+/* void* frame */\r
+/* ) */\r
+/* { struct model* curr_modelp; */\r
+\r
+/* curr_modelp = curr_model(); */\r
+\r
+/* curr_modelp->spritesheet[(int)direction].frames[curr_modelp->spritesheet[(int)direction].num_frames++] = frame; */\r
+/* } */\r
\r
\r
\r
#include <stdint.h>\r
+#include <unitypes.h>\r
+#include <limits.h>\r
\r
#define BUF_SIZE 256\r
#define MAX_SETS 256\r
#define MAX_ELES 256\r
#define MAX_QUADS 256\r
#define MAX_MODELS 256\r
+#define MAX_MODEL_LEN 256\r
+#define MAX_MAPS 8\r
#define MAX_POSTS 256\r
#define MAX_CLASS_DEPTH 256\r
#define MAX_CLASSES 256\r
elements are populated, due to the nature of bottom up parsing. */\r
\r
struct set {\r
- char name[32];\r
- uint64_t ref_id;\r
+ uint8_t name[32];\r
+ int ref_id;\r
int cdat_idx;\r
};\r
\r
/* TODO: Should classes point to their parent class? */\r
\r
struct cdat {\r
- char name[32];\r
+ uint8_t name[32];\r
int idx;\r
int num_classes;\r
int num_sets;\r
struct ref* nextref;\r
struct ref* lastref;\r
struct odat* odatp;\r
- uint64_t ref_id; //0xFFFFFF->digit\r
+ int ref_id; //0xFFFFFF->digit\r
};\r
\r
\r
differ from vlinks because they do not have a name */\r
\r
struct svlink {\r
- uint64_t ref_id;\r
+ int ref_id;\r
};\r
\r
/* A vlink is what it sounds like, a link to a vdat */\r
struct vlink {\r
- uint64_t ref_id;\r
- char anim_name[32];\r
+ int ref_id;\r
+ uint8_t anim_name[32];\r
};\r
\r
union link_t {\r
int ele_idx;\r
};\r
\r
+struct root {\r
+ int x, y, z;\r
+};\r
+\r
+struct quad {\r
+ int x;\r
+ int y;\r
+ int z;\r
+ int ref_id;\r
+};\r
+\r
+/* maps: maps store the different map data for each archetype. */\r
+struct map {\r
+ uint8_t name[NAME_MAX];//TODO:Rename\r
+ uint8_t filepath[PATH_MAX];//TODO: Rename\r
+ int height;\r
+ int width;\r
+ };\r
\r
/* Odats: Odats consist of the object data necessary for\r
each object. Odats are sometimes referred to as archetypes\r
a runtime object and a compile-time object.\r
TODO: Need more info about objects at runtime, to described\r
the reasoning behind odat structure at compile-time*/\r
-\r
-struct root {\r
- int x, y, z;\r
-};\r
-\r
struct odat {\r
- char name[32];\r
+ uint8_t name[32];\r
struct vdat* vdatp;\r
int vdat_id; //\r
int cdat_idx;\r
int hitbox;\r
- uint64_t ref_id;\r
+ int ref_id;\r
+ struct odat* parent_odatp; // odat == set ? null : set ref_id\r
struct root root;\r
struct ref* refp; /* pointer to it's ref on ref_list */\r
- void* quad_filep;\r
+ struct map map;\r
+ //int mli; //map list index\r
};\r
\r
struct odat* curr_set_odatp; //when a set has elements, insert_set() can no longer\r
direction (N,W,S,E,NW,NE,SW,SE)*/\r
/* NAMED spritesheet */\r
struct model {\r
- char name[32];\r
+ uint8_t name[MAX_MODEL_LEN];\r
+ uint8_t filepath[PATH_MAX];\r
struct framesheet spritesheet[8]; //one for each\r
};\r
\r
/* Vdat: Vdats are the video data of each object. They can not be\r
created as a stand alone object (because they consist solely\r
- of animation information and not the skeleton on which the\r
+ of animation information and not the map which the\r
animation manipulates). Vdats have a list of models for every\r
animation that the vdats odat can do for that vdat*/\r
struct vdat {\r
struct odat* creator; //pointer to odat that made this vdat\r
int num_models;\r
+ uint8_t filename[NAME_MAX/sizeof(ucs4_t)];\r
+ int height;\r
+ int width;\r
+ uint8_t filepath[PATH_MAX/sizeof(ucs4_t)];\r
struct model model_list[MAX_MODELS];\r
};\r
\r
the space for a cdat on the cdat_buf, pushes that pointer onto\r
the cdat_stack */\r
void\r
-push_cdat(char*);\r
+push_cdat(uint8_t*);\r
\r
/* Called after a cdat end operator has been recognized in grammar. Sets\r
top stack cdat ** to null and decrements stack pointer */\r
the next odat. */\r
\r
void\r
-insert_set_label(char*, uint64_t);\r
+insert_set_label(uint8_t*, int);\r
\r
/* Populate the sets representation in CURR_CDAT with a ref_id and insert a link\r
into the link_buf that will resolve the ref_id to an actual odat after parse time. */\r
void\r
-insert_set_olink(uint64_t);\r
+insert_set_olink(int);\r
\r
/* Put the vlink in the link_buf to be processed after parsetime */\r
void\r
-insert_set_vlink(uint64_t, char*);\r
+insert_set_vlink(int, uint8_t*);\r
\r
/* Put svlink in the link_buf to be processed after parsetime */\r
void\r
-insert_set_svlink(uint64_t);\r
+insert_set_svlink(int);\r
\r
/* Called for every set reduction except for sets with olinks. Populates the\r
set data structures in the CDAT and in the ODAT. Uses the name and ref_id\r
insert_set_vdatid(void);\r
\r
void\r
-insert_ele_label(char*, uint64_t);\r
+insert_ele_label(uint8_t*, int);\r
\r
/* Insert an ele olink into the CURR_ODAT */\r
void\r
-insert_ele_olink(uint64_t);\r
+insert_ele_olink(int);\r
\r
/* Insert a ele vlink into CURR_ODAT*/\r
void\r
-insert_ele_vlink(uint64_t, char*);\r
+insert_ele_vlink(int, uint8_t*);\r
\r
/* Inserts an ele short vlink into CURR_ODAT*/\r
void\r
-insert_ele_svlink(uint64_t);\r
+insert_ele_svlink(int);\r
\r
/* inserts ele into CURR_CLASS and CURR_ODAT */\r
void\r
void\r
insert_ele_vdatid(void);\r
\r
+void\r
+insert_vdat(uint8_t*, int, int, uint8_t*);\r
/* Inserts the hitbox into the CURR_ODAT */\r
void\r
insert_hitbox(int);\r
\r
/* Inserts a quad into the CURR_ODAT */\r
void\r
-insert_quad(void*);\r
+insert_quad(int, int, int, int);\r
\r
void\r
-insert_model(void);\r
+insert_map(uint8_t*, int, int, uint8_t*);\r
\r
void\r
-insert_framesheet(char, char*, uint64_t, int, int, int);\r
+insert_model(void);\r
\r
void\r
-insert_frame_pointer(char, void*);\r
+insert_framesheet(uint8_t, uint8_t*, int, int, int, int);\r
\r
void\r
-alloc_vdat(void);\r
+insert_frame_pointer(uint8_t, void*);\r
+\r
+\r
alloc_cdat(void);
struct odat*
alloc_odat(void);
-void
+struct vdat*
alloc_vdat(void);
struct link*
alloc_link(void);
curr_odat(void);
struct vdat*
curr_vdat(void);
+struct map*
+curr_map(void);
struct set*
curr_set(void);
struct ref*
void* dsp[MAX_CHUNKS]; //dat stack pointer (per chunk)
int chunk_size; //size of a chunk (including its forfeited page)
int max_dats; //number of dats per chunk for this stack
-} ocs, vcs, ccs, rcs, lcs, pcs; //odat, vdat, and cdat, ref, link, post stacks
+} ocs, vcs, ccs, rcs, lcs, pcs, mcs; //odat, vdat, cdat,map, ref, link, post stacks
//type safety handled by macro expansion (do not call these directly from code, make dependent macros for access to these)
#define CHUNKS_LEN(STACK) ((STACK).csp - (STACK).chunks)
#define CDAT_FULL() (DATA_FULL(ccs, struct cdat))
#define CDAT_ALLOC() (ALLOC_DAT(ccs, struct cdat))
#define CCS_FULL() (CHUNKS_FULL(ccs))
+#define INIT_MAP() (INIT_STACK(mcs, struct map))
+#define CURRENT_MAP() (CURRENT_DATP(mcs, struct map))
+#define MAP_FULL() (DATA_FULL(mcs, struct map))
+#define MAP_ALLOC() (ALLOC_DAT(mcs, struct map))
+#define MCS_FULL() (CHUNKS_FULL(mcs))
#define INIT_LINK() (INIT_STACK(lcs, struct link))
#define CURRENT_LINK() (CURRENT_DATP(lcs,struct link))
#define LDAT_FULL() (DATA_FULL(lcs, struct link))
#define RCS_FULL() (CHUNKS_FULL(rcs))
//Metadata
#define CURRENT_SET() (CURRENT_CDAT()->set_list[CURRENT_CDAT()->num_sets])
-#define CURRENT_MODEL() (CURRENT_VDAT()->model_list[CURRENT_VDAT()->num_models])
+//#define CURRENT_QUAD() (CURRENT_MAP()->quad_list[CURRENT_MAP()->num_quads])
+//#define CURRENT_MODEL() (CURRENT_VDAT()->model_list[CURRENT_VDAT()->num_models])
-#define CURR_QUAD (CURR_ODAT->quad_file)
long pagesize;
int num_vdats = 0;
+int num_maps = 0;
+
int num_refs = 0;
-uint64_t ss_ref_id = 0x00FFFFFF; /* system space for ref_ids */
+int ss_ref_id = 0x0FFFFFFF; /* system space for ref_ids */
int num_posts = 0;
INIT_CDAT();
*cdat_stackp = CURRENT_CDAT();
+
memmove((*cdat_stackp)->name, root, 32);
INIT_ODAT();
INIT_VDAT();
+ INIT_MAP();
INIT_LINK();
INIT_REF();
INIT_POST();
alloc_odat
()
{
- num_odats++;
+ num_odats++;
if(ODAT_FULL())
{ if(!OCS_FULL())
{ fprintf(stderr, "You have allocated to many (%d) odats ", num_odats);
return CURRENT_ODAT();
}
-void
+struct vdat*
alloc_vdat
()
{ num_vdats++;
}
else
VDAT_ALLOC();
+
+ return CURRENT_VDAT();
+}
+
+struct map*
+alloc_map
+()
+{ num_maps++;
+ if(MAP_FULL())
+ { if(!MCS_FULL())
+ { fprintf(stderr, "You have allocated to many (%d) maps ", num_maps);
+ exit(EXIT_FAILURE);
+ }
+ else
+ CSP_PUSH(mcs);
+ }
+ else
+ MAP_ALLOC();
+
+ return CURRENT_MAP();
}
+
struct link*
alloc_link
()
{
return CURRENT_REF();
}
-struct model*
-curr_model
+struct map*
+curr_map
()
{
- return &CURRENT_MODEL();
+ return CURRENT_MAP();
}
+/* struct quad* */
+/* curr_quad */
+/* () */
+/* { */
+/* return &CURRENT_QUAD(); */
+/* } */
+/* struct model* */
+/* curr_model */
+/* () */
+/* { */
+/* return &CURRENT_MODEL(); */
+/* } */
/* Standard */
#include <stdio.h>
#include <string.h>
+#include <stdint.h>
#include <errno.h>
/* Posix */
#include <unistd.h>
+#include <unitypes.h>
+#include <unistr.h>
+#include <uniconv.h>
+#include <uniname.h>
+#include <unistdio.h>
#include <stdlib.h>
-#include <limits.h> //realpath, NAME_MAX, PATH_MAX
+#include <limits.h> //realpath, NAME_MAX, FPATH_MAX
#include <dirent.h>
+
/* Local */
#include "parser.tab.h"
#ifndef DE_STACKSIZE
#ifndef TK_STACKSIZE
#define TK_STACKSIZE 1024
#endif
+#ifndef MAX_SETNAME_LEN //max setname length
+#define MAX_SETNAME_LEN 32
+#endif
+#ifndef MAX_ELENAME_LEN //max setname length
+#define MAX_ELENAME_LEN 32
+#endif
+#define FNAME_MAX 1024
+#define FPATH_MAX 8192
+
/* Public */
int lexer_init(void);
int lexer(void);
-int lexer_lexfile(const char*);
+int lexer_lexfile(const uint8_t*);
void lexer_pushtok(int, YYSTYPE);
-char const* lexer_get_current_filepath(void);
+uint8_t const* lexer_get_current_filepath(void);
+int lexer_lexfilename(uint8_t*);
struct dirent* lexer_direntpa[DE_STACKSIZE],** lexer_direntpp,** lexer_direntpb;
/* Private */
-extern //lexer_lex.rl
-int lexer_lex(const char*);
+extern //lexer_fsm.rl
+int lexer_lexstring(uint8_t*, int);
+extern //lexer_fsm.rl
+int lexer_setstr(uint8_t*, int);
extern //scanner.c
int scanner_init(void);
extern //scanner.c
extern //bison
YYSTYPE yylval;
static
-char const* current_filename;
+uint8_t const* current_filename;
+static
+uint8_t prev_setname[MAX_SETNAME_LEN];
+static
+uint8_t prev_elename[MAX_ELENAME_LEN];
+static
+uint8_t map_key[] = "~";
static
struct tok
{ YYSTYPE lval; //token val
()
{ TK_INIT();
DE_INIT();
- current_filename = NULL;
return scanner_init();
}
} while (0)
()
{ struct tok token;
- start:
- while (DE_LEN() > 0) //lex any directory entries in our stack
- if (lexer_lexfile(DE_POP()->d_name) == 0)
- FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKB)->d_name);
+ start:
+ while (DE_LEN() > 0)//lex any directory entries in our stack
+ {
+ if (lexer_lexfile(DE_POP()->d_name) == 0)
+ FAIL("Lexer failed to tokenize [%s]\n",(*DE_STACKB)->d_name);
+ }
if (TK_EMPTY) //if there are no tokens,
{ TK_INIT(); //initialize the token stack back to 0
switch (scanner())
*/
int lexer_lexfile
#define HIDDEN_WARNING "%s is hidden and will not be parsed!\n", filename
-( const char *filename
+( const uint8_t *filename
)
-{ static char fname[NAME_MAX];
- char *last_period = NULL, *iter;
+{ static uint8_t fname[FNAME_MAX];
+ uint8_t *last_period = NULL, *iter;
- if (*filename == '.')
+ if (*filename == '.')
{ fprintf (stderr, HIDDEN_WARNING);
return 0;
}
/* Copy the filename and remove its suffix */
- strncpy(fname,filename,NAME_MAX);
+ u8_strncpy(fname,filename,FNAME_MAX);
last_period = NULL;
for (iter = fname; *iter; iter++) //find the last '.' char
- if (*iter == '.')
+ if (*iter == '.')
last_period = iter;
if (last_period) //if we found one,
- *last_period = '\0'; //truncate the string there
+ *last_period = 0; //truncate the string there
/* Register the current_filename */
current_filename = filename;
-
- return lexer_lex(fname);
+ printf("lexer_lexfilename(%s)\n",fname);
+ return lexer_lexfilename(fname);
}
-char const* lexer_get_current_filepath
+uint8_t const* lexer_get_current_filepath
()
-{ static char current_path[PATH_MAX];
- static char const* last_filename;
+{ static uint8_t current_path[FPATH_MAX];
+ static uint8_t const* last_filename;
if ((!last_filename || last_filename != current_filename) &&
- (realpath(current_filename, current_path) != current_path))
+ ((uint8_t*) realpath(current_filename, current_path) != (uint8_t*) current_path))
{ perror("realpath: ");
return NULL;
}
- return (const char*)current_path;
+ return (const uint8_t*)current_path;
+}
+
+/* Returns 1 on success, 0 on failure */
+int
+lexer_ismapfile(uint8_t* str)
+{
+ int i, len;
+
+ len = u8_strlen(str);
+ for(i = 0; i < len; i++)
+ if(str[i] == '~')
+ return 1;
+}
+
+
+/* Scan filename and push the its tokens
+ onto the stack */
+int lexer_lexfilename
+(uint8_t* str)
+#define REF(STR) (STR[0] <= 0x39 && STR[0] >= 0x30)
+#define DEL_FTOK(STR) (STR = u8_strchr(STR, '_') + 1)
+#define NEXT_TOK(STR) (u8_strchr(STR, '_') + 1)
+#define SET_CURR_SETNAME(STR) \
+ do { \
+ printf("setting curr_setname of str(%s)\n", STR); \
+ setname_end = u8_chr(STR, FNAME_MAX, '_'); \
+ setname_len = setname_end - str; \
+ u8_move(curr_setname, STR, setname_len); \
+ printf("curr_setname is now %s\n",curr_setname); \
+ } while (0)
+#define SET_CURR_ELENAME(STR) \
+ do { \
+ printf("setting curr_elename of str(%s)\n", STR); \
+ setname_end = u8_chr(STR, FNAME_MAX, '_') + 1; \
+ if(REF(setname_end)) \
+ setname_end = u8_chr(setname_end, FNAME_MAX, '_') + 1; \
+ elename_end = u8_chr(setname_end, FNAME_MAX, '_'); \
+ elename_len = elename_end - setname_end; \
+ u8_move(curr_elename, setname_end, elename_len); \
+ printf("curr_elename is now %s\n", curr_elename); \
+ } while (0)
+
+#define SETNAME_MATCHES() (u8_strcmp(curr_setname, prev_setname) == 0)
+#define ELENAME_MATCHES() (u8_strcmp(curr_elename, prev_elename) == 0)
+#define UPDATE_PREV_SETNAME(STR) \
+ do { \
+ printf("updating prev_setname from (%s)", prev_setname); \
+ u8_set(prev_setname , (ucs4_t) 0, MAX_SETNAME_LEN ); \
+ u8_move(prev_setname, curr_setname, setname_len); \
+ printf(" to %s\n", prev_setname); \
+ } while (0)
+#define UPDATE_PREV_ELENAME(STR) \
+ do { \
+ u8_set(prev_elename , (ucs4_t) 0, MAX_ELENAME_LEN ); \
+ u8_move(prev_elename, curr_elename, elename_len); \
+ } while (0)
+#define PREV_MAPFILE() (TK_STACKX - 5)->tok_t == MOPEN || (TK_STACKX-3)->tok_t == MOPEN
+#define SET_MAPSTR(STR) (STR = u8_strstr(STR, map_key))
+
+{ int ntok, len, newstrt;
+ uint8_t *filepath;
+ typedef enum filetypes {
+ error = 0,
+ set_model,
+ set_map,
+ ele_model,
+ ele_map,
+ ele_vlink,
+ set_olink,
+ set_vlink
+ } filetypes;
+
+ ntok = 0;
+
+ printf("|---- Begin lexerfilename on %s ----|\n", str);
+
+ if(*str == 0)
+ perror("Lexfilename:: str is NULL so fail\n");
+
+ /* Determine the filetype of str */
+ len = u8_strlen(str);
+ newstrt = lexer_setstr(str,len);
+
+ str = str + newstrt;
+
+ len = u8_strlen(str);
+
+ ntok += lexer_lexstring(str, len);
+
+ /* Need to add map variant name 'default' if user did not specify a
+ map variant name */
+ /* if(filetype == ele_map) */
+ /* { if(!u8_strchr(str, '_')) //map variant name not provided */
+ /* { yylval.str = "default"; */
+ /* lexer_pushtok(NAME, yylval); */
+ /* ntok++; */
+ /* printf("Pushing default ele_map name\n"); */
+ /* } */
+ /* } */
+
+ /* Pass back filepath as end of statment operator */
+ filepath = u8_strdup(lexer_get_current_filepath());
+ yylval.str = filepath;
+ lexer_pushtok(NAME, yylval);
+ printf("Pushing filepath %s\n", filepath);
+ ntok++;
+
+ printf("|---- Ending lexer_lexfilename on %s, %d tokens were lexed ----|\n", str, ntok);
+ return ntok;
+}
+
+int
+lexer_lexelemap
+( uint8_t* str)
+{ int setname_len, elename_len, strlen;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ SET_CURR_ELENAME(newstrt);
+ if(PREV_MAPFILE())
+ { printf("*previous file was mapfile*\n");
+ SET_MAPSTR(newstrt);
+ }
+ else
+ {
+ if(SETNAME_MATCHES())
+ { DEL_FTOK(newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+ printf("setname matches\n");
+ if(ELENAME_MATCHES())
+ DEL_FTOK(newstrt);
+ if(REF(str))
+ DEL_FTOK(newstrt);
+ }
+ }
+ UPDATE_PREV_ELENAME(newstrt);
+ UPDATE_PREV_SETNAME(newstrt);
+
+ return newstrt - str;
+
+
}
+
+int
+lexer_lexelemodel
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ printf("In lexelemodel, str is %s\n", str);
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ SET_CURR_ELENAME(newstrt);
+ if(SETNAME_MATCHES())
+ { printf("in ele_model: setname matches\n");
+ DEL_FTOK(newstrt);
+ printf("newstrt is now %s\n", newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+ if(ELENAME_MATCHES())
+ { printf("in ele_model: elename matches\n");
+ DEL_FTOK(newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+ }
+ }
+ UPDATE_PREV_ELENAME(newstrt);
+ UPDATE_PREV_SETNAME(newstrt);
+
+ return newstrt - str;
+}
+
+int
+lexer_lexsetmap
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ if(PREV_MAPFILE())
+ SET_MAPSTR(newstrt);
+ else
+ if( SETNAME_MATCHES())
+ DEL_FTOK(newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+
+ UPDATE_PREV_SETNAME(newstrt);
+
+ return newstrt - str;
+}
+
+int
+lexer_lexsetmodel
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ if( SETNAME_MATCHES())
+ DEL_FTOK(newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+ UPDATE_PREV_SETNAME(newstrt);
+
+ return newstrt - str;
+
+}
+
+int
+lexer_lexsetvlink
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ if( SETNAME_MATCHES())
+ DEL_FTOK(newstrt);
+ if(REF((NEXT_TOK(newstrt)))) //if NAME REF REF
+ DEL_FTOK(newstrt);
+ UPDATE_PREV_SETNAME(newstrt);
+
+ return newstrt - str;
+
+}
+
+int
+lexer_lexelevlink
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ SET_CURR_ELENAME(newstrt);
+ if(SETNAME_MATCHES())
+ { DEL_FTOK(newstrt);
+ if(REF(NEXT_TOK(newstrt))) //NAME REF REF, where is set_label
+ DEL_FTOK(newstrt);
+ }
+
+ return newstrt - str;
+}
+
+int
+lexer_lexsetolink
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ return 0;
+
+ //do nothing
+}
+
+int
+lexer_lexeleolink
+(uint8_t* str)
+{ int setname_len, elename_len;
+ uint8_t* setname_end, *elename_end, *newstrt;
+ uint8_t curr_setname[MAX_SETNAME_LEN] = {0};
+ uint8_t curr_elename[MAX_ELENAME_LEN] = {0};
+
+ newstrt = str;
+
+ SET_CURR_SETNAME(newstrt);
+ printf("prev_setname %s, curr_setname %s\n", prev_setname, curr_setname);
+ if(SETNAME_MATCHES())
+ { DEL_FTOK(newstrt);
+ if(REF(newstrt))
+ DEL_FTOK(newstrt);
+ }
+
+ return newstrt - str;
+
+
+}
+
+
+/**************************/
+/****Abandon All Hope******/
+/**************************/
+/*** ***/
+/*** ***/
+/*** ***/
+/*** ***/
+
+
+
+/* int lexer_lexmapfile */
+/* #define INC_X() */
+/* (int height, int width) */
+/* { */
+/* int x, y; */
+
+/* /\* Give scanner_scanpixels a buffer and a len. Iterate through */
+/* buf with buf[n]. If n == 0, do nothing. if n has a value, push x, */
+/* push y, push (z = n << 24), push (ref_id = n >> 8) *\/ */
+/* //scanner_scanpixels() */
+
+/* for(i = 0; i < len; i++) */
+/* if(buf[i] == 0) */
+/* if(x == width) */
+/* x = 0; */
+/* else */
+
+
+
+
+/* } */
+/* fname_bytes = (uint8_t*)(DE_POP()->d_name); */
+ /* printf("d_name is %s\n", fname_bytes); */
+ /* for (fnp = filename, i = 0; i < FNAME_MAX; i += unit_size, fnp++) */
+ /* { unit_size = u8_mblen(fname_bytes + i, min(4, FNAME_MAX - i)); */
+ /* if (u8_mbtouc(fnp, fname_bytes + i, unit_size) == -1) //add ucs4 char to the filename */
+ /* FAIL("Lexer failed to convert ^%s to unicode\n", (fname_bytes + i)); */
+ /* if (*fnp == 0) //added a terminating char */
+ /* break; */
+ /* } */
+ /* if(u8_mbtouc(filename, DE_POP()->d_name, FNAME_MAXy) == -1) */
+ /* FAIL("Lexer failed to convert d_name into uint8_t\n"); */
+ /* ulc_fprintf(stdout, "filename is %11U\n c", filename); */
--- /dev/null
+#include <stdio.h>
+#include <stdint.h>
+#include <apc/parser.tab.h>
+#include <unistdio.h>
+
+extern void lexer_pushtok(int, YYSTYPE);
+extern int lexer_lexmapfile(int, int);
+extern int lexer_lexelemodel(uint8_t*);
+extern int lexer_lexsetmodel(uint8_t*);
+extern int lexer_lexsetmap(uint8_t*);
+extern int lexer_lexelemap(uint8_t*);
+extern int lexer_lexsetvlink(uint8_t*);
+extern int lexer_lexelevlink(uint8_t*);
+extern int lexer_lexsetolink(uint8_t*);
+extern int lexer_lexeleolink(uint8_t*);
+extern int ipower(int, int);
+extern int ttov(uint8_t*, int);
+extern uint8_t* ttos(const uint8_t*, int);
+
+int lexer_lexstring(uint8_t*, int);
+int lexer_setstr(uint8_t*, int);
+
+#define $($)#$
+#define PUSHTOK(TOK,LFUNC,UTYPE) \
+ do { \
+ printf("PUSHTOK(" $(TOK) $(LFUNC) $(UTYPE) ")\n"); \
+ tok_t = TOK; \
+ yylval.UTYPE = LFUNC(ts, p-ts); \
+ lexer_pushtok(tok_t, yylval); \
+ ++ntok; \
+ } while (0);
+
+%%{
+ machine setstr;
+
+
+ action lex_setvlink {printf("Returning setvlink filetype for %s\n", str); type = 5; newstrt = lexer_lexsetvlink(str); fbreak;}
+ action lex_elevlink {printf("Returning elevlink filetype for %s\n", str); type = 6; newstrt = lexer_lexelevlink(str); fbreak;}
+ action lex_setmodel {printf("Returning setmodel filetype\n"); newstrt = lexer_lexsetmodel(str); type = 1; fbreak;}
+ action lex_setmap {printf("Returning setmap filetype\n"); newstrt = lexer_lexsetmap(str); type = 2; fbreak;}
+ action lex_elemodel {printf("Returning elemodel filetype for %s\n", str); newstrt = lexer_lexelemodel(str); type = 3; fbreak;}
+ action lex_elemap {printf("Returning elemap filetype for %s\n", str); newstrt = lexer_lexelemap(str); type = 4; fbreak;}
+ action lex_setolink { printf("Returning setolink filetype\n"); type = 8; newstrt = lexer_lexsetolink(str); fbreak;}
+ action lex_eleolink { printf("Returning eleolink filetype\n"); type = 7; newstrt = lexer_lexeleolink(str); fbreak;}
+ action p {printf("p = %s \n",p);}
+
+
+ SSN = 'SSN';
+ SSW = 'SSW';
+ SSS = 'SSS';
+ SSE = 'SSE';
+ SSNW = 'SSNW';
+ SSNE = 'SSNE';
+ SSSW = 'SSSW';
+ SSSE = 'SSSE';
+ direction = (SSN | SSW | SSS | SSE | SSNW | SSNE | SSSW | SSSE);
+
+ nm = alpha >p;
+ name = alpha+;
+ num = digit+;
+ refs = digit >p;
+ ref = refs+;
+
+
+ set_label = name | (name '_' ref);
+ ele_label = (name | name '_' ref);
+
+ set_model = set_label '_' (name | name '_' num '_' num ) [\0] %to(lex_setmodel) ;
+ set_map = set_label '_' '~' '_' (name | name '_' num '_' num ) [\0] %to(lex_setmap) >p;
+ ele_model = set_label '_' ele_label '_' direction '_' (name | name '_' num '_' num) [\0] %to(lex_elemodel);
+ ele_map = set_label '_' ele_label '_' '~' '_' (name | name '_' num '_' num) [\0] %to(lex_elemap);
+ set_olink = ref %to(lex_setolink) [\0] ;
+ ele_olink = set_label '_' '~' '_' ref [\0] %to(lex_eleolink);
+ set_vlink = set_label '_' '#' '_' (ref | ref '_' name) [\0] %to(lex_setvlink);
+ ele_vlink = set_label '_' ele_label '_' '#' '_' (ref | ref '_' name) [\0] >p %to(lex_elevlink);
+
+ #main := (set_model | set_map | ele_model | ele_map | set_link | ele_link);
+
+ #main := (set_olink | set_vlink | set_model | set_map | ele_map | ele_model | ele_olink | ele_vlink);
+ main := name;
+
+
+
+
+ write data;
+
+
+}%%
+
+int
+lexer_setstr
+(uint8_t* str, int size)
+{ uint8_t *p, *pe, *eof;
+ int cs, type, newstrt;
+
+ type = newstrt = 0;
+
+ p = str;
+ pe = str + size ;
+
+ printf("Starting fsm filetype with str = %s, p = %s, pe = %s\n", str,p, pe);
+
+ %%write init;
+ %%write exec noend;
+
+ printf("lexer_setstr is incrementing str by %d, type is %d\n", newstrt, type);
+
+ return newstrt;
+}
+
+%%{
+ machine lexstring;
+
+ # set up yylval and tok_t to be pushed to stack
+ action push_ref { PUSHTOK(REF, ttov, ref); }
+ action push_val { PUSHTOK(NUM, ttov, val); }
+ action push_name { printf("pushing NAME token from %s to %s\n", ts, p); PUSHTOK(NAME, ttos, str); }
+ action push_map { printf("Pushing map file\n"); yylval.str = (uint8_t*) '~'; lexer_pushtok(MOPEN, yylval); ntok++; }
+ action set_ts { printf("Lexstring: Setting ts (%s) = p(%s)\n", ts, p); ts = p; }
+ action lex_error { printf("input error: character %c in filename %s is invalid\n p = %s\n", fc, str, p);}
+
+ # Parses a regular filename (not a mapping) and pushes
+ # tokens to the parser
+
+ ref = '0x'. alnum+ %push_ref;
+ val = digit+ %push_val;
+ name = alpha+ %push_name ;
+ map = '~' %push_map;
+ tok = (ref | val | name | map);
+ segment = tok . [_\0] %set_ts;
+ segment_end = tok;
+
+ tok_lexer := segment+ [\0];
+
+ write data;
+
+}%%
+
+int
+lexer_lexstring
+(uint8_t* str, int size)
+{ uint8_t *p;
+ uint8_t *ts, *pe, *eof;
+ int cs, ntok, tok_t;
+
+ ntok = 0;
+ p = ts = str;
+ pe = p + size + 1;
+
+ printf("Starting lexstring on str %s.\n",str);
+
+ %%write init;
+ %%write exec;
+
+ printf("Ending lexstring of file %s, pushed %d tokens.\n",str, ntok);
+
+ return ntok;
+}
+
+
+/**************************/
+/****Abandon All Hope******/
+/**************************/
+/*** ***/
+/*** ***/
+/*** ***/
+/*** ***/
+
+
+/* %%{ */
+/* machine file_matcher; */
+
+/* action call_ml { ts = p; fgoto set_hw ;} */
+/* action call_tl { return 0;} */
+/* action set_height {height = ttov(p, p-ts+1); ts = p;} */
+/* action set_width { width = ttov(p, p-ts+1);} */
+/* action call_lmf {lexer_lexmapfile(height, width); } */
+/* action lex_error {printf("input error: character %c in filename %s is invalid\n = %s\n", fc, str, p);} */
+
+/* #This machine determines the type of file we are lexing */
+/* #and calls the appropriate machine to handle it. */
+
+/* #TODO add mapping name */
+/* width = digit+ %set_width; */
+/* height = digit+ %set_height; */
+
+/* set_hw := height . '_' . width [\0] %to(call_lmf); */
+
+/* tok_segment = alnum; */
+/* map_end = 'm' . '_' %to(call_ml); */
+/* tok_end = alnum+ . [\0] %to(call_tl); */
+
+/* file_matcher := (tok_segment+ . '_' )+ ( map_end | tok_end ); */
+
+/* write data; */
+/* }%% */
+
+/* int */
+/* lexer_matchfile */
+/* (char* str, int size) */
+/* { *p, *pe; */
+/* char* ts; */
+/* int cs, ntok, height, width; */
+
+/* p = str; */
+/* pe = p + size; */
+/* height = width = 0; */
+
+/* printf("Checking if filename is a map file:: filename = %s, p = %c, pe = %c\n", str, *p, *pe); */
+
+/* %%write init; */
+/* %%write exec noend; */
+
+/* printf("Ending lexer_ismapfile on %s\n", str); */
+
+/* return ntok; */
+/* } */
+
+/* %%{ */
+/* machine vartype; */
+
+/* action isele {return 0;} */
+/* action ismodel {return 1;} */
+
+/* set_name = alpha+; */
+/* ele_name = alpha+; */
+/* model_name = alpha+; */
+
+/* ele = set_name '_' model_name '_' ele_name %isele; */
+/* model = set_name '_' model_name [\0] %ismodel; */
+
+
+/* ismodel := (ele | model); */
+
+/* write data; */
+
+/* }%% */
+
+/* int */
+/* lexer_ismodel */
+/* (uint8_t* str, int size) */
+/* { uint8_t *p, *pe, *eof; */
+/* int cs; */
+
+/* p = str; */
+/* pe = p + size + 1; */
+
+/* %%write init; */
+/* %%write exec; */
+
+
+/* } */
#include <string.h>\r
#include <apc/parser.tab.h>\r
\r
+\r
extern void lexer_pushtok(int, YYSTYPE);\r
+//extern char* scanner_current_file();\r
+extern int lexer_ismapfile(const char*, int);\r
+extern int lexer_tokfile(const char*, int);\r
+\r
\r
int lexer_lex(const char*);\r
int ipow(int, int);\r
-int ttov(const char* str, int);\r
-uint64_t ttor(const char* str, int);\r
-char* ttos(const char* str, int);\r
+int ttov(const uint8_t* , int);\r
+uint64_t ttor(const uint8_t* , int);\r
+char* ttos(const uint8_t* , int);\r
\r
\r
#define MAX_TOK_LEN 64\r
#define MAX_TOKENS 16\r
#define MAX_STR_SIZE (MAX_TOK_LEN * MAX_TOKENS)\r
-#define $($)#$\r
-#define PUSHTOK(TOK,LFUNC,UTYPE) \\r
- do { \\r
- printf("PUSHTOK(" $(TOK) $(LFUNC) $(UTYPE) ")\n"); \\r
- tok_t = TOK; \\r
- yylval.UTYPE = LFUNC(ts, p-ts+1); \\r
- lexer_pushtok(tok_t, yylval); \\r
- ++ntok; \\r
- } while (0)\r
-\r
-%%{\r
- machine token_matcher;\r
-\r
- # set up yylval and tok_t to be pushed to stack\r
- action set_ref { PUSHTOK(REF, ttor, ref); }\r
- action set_val { PUSHTOK(NUM, ttov, val); }\r
- action set_name { PUSHTOK(NAME, ttos, str); }\r
- action set_ts { ts = p; }\r
- action lex_error {printf("input error: character %c in filename %s is invalid\n", fc, str);}\r
-\r
- # instantiate machines for each possible token\r
- ref = '0x'. xdigit+ %set_ref;\r
- val = digit+ %set_val;\r
- name = alpha+ %set_name;\r
- tok = (ref | val | name);\r
- segment = tok . [_\0] %set_ts;\r
-\r
- main := segment+ ;\r
-\r
-}%%\r
-\r
-\r
-%%write data;\r
+\r
/* Scan filename and push the its tokens\r
onto the stack */\r
int lexer_lex (const char* str)\r
{\r
- const char *p, *pe, *ts, *eof;\r
- int cs, tok_t, ntok = 0;\r
- printf ("Lexing: %s\n",str);\r
- p = ts = str;\r
- pe = p + strlen(str) + 1;\r
- %%write init;\r
- %%write exec;\r
- printf ("Lexed %i tokens\n",ntok);\r
+ int ntok, len;\r
+\r
+\r
+ len = strlen(str);\r
+ printf("Calling lexer_lex on %s\n", str);\r
+ \r
+ \r
return ntok;\r
}\r
\r
}\r
\r
/* Token to Value */\r
-int ttov(const char* str, int len)\r
+int ttov(const uint8_t* str, int len)\r
{\r
int i, val = 0;\r
\r
return val;\r
}\r
\r
-uint64_t ttor(const char* str, int len)\r
+uint64_t ttor(const uint8_t* str, int len)\r
{\r
int i;\r
uint64_t num = 0;\r
return num;\r
}\r
\r
-char* ttos(const char* str, int len)\r
+char* ttos(const uint8_t* str, int len)\r
{\r
int i;\r
char token_buf[MAX_TOK_LEN];\r
/* Asset Package Compiler */
%code requires{
#include <stdint.h>
+ #include <unitypes.h>
}
%{
#include <stdio.h>
%define lr.type ielr
%union {
- uint64_t ref;
+ int ref;
int val;
- char *str;
+ uint8_t *str;
void *voidp;
-
}
//operators
%token EOPEN // [
%token ECLOSE // ]
%token VOPEN // /
-%token VCLOSE // \
+%token VCLOSE // '\'
+%token MOPEN // {
+%token MCLOSE
+%token HB
+%token ROOT
%token QOPEN // !
%token QCLOSE // @
-%token RT // &
-%token HB // #
-//nonterminal types
+
+ //nonterminal types
%type <ref> olink
%type <ref> ele_svlink
%type <ref> set_svlink
%token <str> STR
%token <val> SS
%token <str> NAME
+%token <str> FNAME
%token <ref> REF
%token <val> SSD
-%token <voidp> FPTR
-%token <voidp> QPTR
// Change width, height, num_ptrs to NUM because
// when scanning, we can't determine which NUM
// is which.
%token <val> WIDTH
%token <val> HEIGHT
%token <val> NUM_PTRS
+%token <voidp> FPTR
//precedence
%precedence LP
%precedence MP
%precedence HP
-
/* Syntax Directed Translation Scheme of the APC grammar */
/* Rules */
class_list
;
+class:
+ NAME CLOPEN {push_cdat($1);} class_block CLCLOSE {pop_cdat();};
+;
+
class_list:
class_list class
| class
;
-class:
- CLOPEN NAME {push_cdat($2);} class_block CLCLOSE {pop_cdat();};
-;
-
class_block:
class_list
| class_list set_list
| set
;
-root:
-RT NUM NUM NUM {insert_root($2, $3, $4);};
+map_list:
+map_list map MP
+| map LP
;
-quad_file:
-QOPEN QPTR QCLOSE {insert_quad($2);};
-
-hitbox:
-HB NUM {insert_hitbox($2);}
+map:
+MOPEN NAME NUM NUM NAME {insert_map($2, $3, $4, $5);};
+| MOPEN NAME NAME {insert_map($2, 0, 0, $3);};
;
set_map_data:
-quad_file
-| quad_file hitbox
-| quad_file hitbox root
-| hitbox root
-| hitbox
-| root
+map_list MP
;
set:
-SOPEN set_label set_map_data element_list {alloc_vdat();} vdat SCLOSE {insert_set(); insert_set_vdatid();};
-| SOPEN set_label set_map_data element_list set_vlink SCLOSE {insert_set();};
-| SOPEN set_label set_map_data element_list set_svlink SCLOSE {insert_set_svlink($5); insert_set(); };
-| SOPEN set_label element_list {alloc_vdat();} vdat SCLOSE {insert_set(); insert_set_vdatid();};
-| SOPEN set_label element_list set_vlink SCLOSE {insert_set(); }
-| SOPEN set_label element_list set_svlink SCLOSE {insert_set_svlink($4); insert_set();};
-| SOPEN olink SCLOSE {insert_set_olink($2);};
+set_label vdat set_map_data element_list HP {insert_set(); insert_set_vdatid();};
+| set_label set_vlink set_map_data element_list MP {insert_set();};
+| set_label set_svlink set_map_data element_list LP {insert_set_svlink($2); insert_set(); };
+| set_label set_map_data element_list MP {insert_set(); };
+| set_label set_map_data LP {insert_set(); };
+| set_label vdat element_list MP {insert_set(); insert_set_vdatid();};
+| set_label set_vlink element_list LP {insert_set(); };
+| set_label set_svlink element_list MP {insert_set_svlink($2); insert_set();};
+| set_label element_list MP
+| set_label vdat LP
+| olink {insert_set_olink($1);};
;
+
set_label:
-HP NAME REF {insert_set_label($2,$3);};
-| LP NAME {insert_set_label($2, -1);};
+NAME REF MP {insert_set_label($1,$2);};
+| NAME LP {insert_set_label($1, -1);};
;
set_svlink:
-REF
-
+REF MP
;
set_vlink:
-REF NAME {insert_set_vlink($1, $2);};
+REF NAME HP {insert_set_vlink($1, $2);};
;
olink:
-REF
+REF LP
;
//parent_id is the set_index of the subclass_index.
element_list:
-element_list element MP
+element_list element HP
| element LP
;
ele_label:
-HP NAME REF {insert_ele_label($2, $3);};
-| LP NAME {insert_ele_label($2, -1);};
+NAME REF MP {insert_ele_label($1, $2);};
+| NAME LP {insert_ele_label($1, -1);};
;
ele_vlink:
-REF NAME {insert_ele_vlink($1, $2);};
+REF NAME HP {insert_ele_vlink($1, $2);};
;
ele_svlink:
-REF
+REF MP
+;
+
+ele_map_data:
+map MP
+| map_list HP
;
element:
-EOPEN ele_label hitbox root {alloc_vdat();} vdat ECLOSE {insert_ele(); insert_ele_vdatid();};
-| EOPEN ele_label hitbox root ele_vlink ECLOSE {insert_ele(); };
-| EOPEN ele_label hitbox root ele_svlink ECLOSE {insert_ele_svlink($5);insert_ele(); };
-| EOPEN ele_label root {alloc_vdat();} vdat ECLOSE {insert_ele(); insert_ele_vdatid();};
-| EOPEN ele_label root ele_vlink ECLOSE {insert_ele(); };
-| EOPEN ele_label root ele_svlink ECLOSE {insert_ele_svlink($4); insert_ele(); };
-| EOPEN olink ECLOSE {insert_ele_olink($2);};
+ ele_label vdat ele_map_data {insert_ele(); insert_ele_vdatid();};
+| ele_label ele_vlink ele_map_data {insert_ele(); };
+| ele_label ele_svlink ele_map_data {insert_ele_svlink($2);insert_ele(); };
+| ele_label ele_map_data {insert_ele();};
+| ele_label vdat {insert_ele(); insert_ele_vdatid();};
+| ele_label ele_vlink {insert_ele(); };
+| ele_label ele_svlink {insert_ele_svlink($2); insert_ele(); ;};
+| MOPEN olink {insert_ele_olink($2);};
;
vdat:
-VOPEN model_list VCLOSE
+model_list LP
+| NAME NUM NUM NAME MP {insert_vdat($1, $2, $3, $4);};
+| NAME NAME {insert_vdat($1, 0, 0, $2);};
;
model_list:
;
framesheet:
-SSD NAME REF HEIGHT WIDTH NUM_PTRS frame_pointers LP {insert_framesheet($1, $2, $3, $4, $5, $6);};
+SSD NAME REF HEIGHT WIDTH NUM_PTRS frame_pointers LP //{insert_framesheet($1, $2, $3, $4, $5, $6);};
;
frame_pointers:
-frame_pointers SSD HP FPTR {insert_frame_pointer($2, $4);};
-| SSD FPTR {insert_frame_pointer($1, $2);};
+frame_pointers SSD HP FPTR //{insert_frame_pointer($2, $4);};
+| SSD FPTR //{insert_frame_pointer($1, $2);};
;
%%
int scanner_scanpixels(int*,int);
/* Private */
extern //lexer.c
-int lexer_lexstring(const char*);
+int lexer_lexstring(const uint8_t*);
extern //lexer.c
void lexer_pushtok(int, int);
static
if (DL_CD_LEN() > 0) //There are entities to process
{ if (DL_CD_POP() == NULL) //If the dirent is null, then the
goto libfail; //lib function in dirent has failed
+<<<<<<< HEAD
ntok += lexer_lexstring(DL_CD_CURNAME());//lex the directory name
+=======
+ ntok += lexer_lexstring(DL_CD_CURNAME()); //lex the directory name
+>>>>>>> 15d3ab5e7871ff459af13089b82bf5f17f731ebd
if (DL_LEN() >= DL_STACKSIZE) //fail if maxdepth exceeded
{ fprintf(stderr, ERR_DEPTH);
goto fail;
}
if (chdir(DL_CD_CURNAME())) //move into the new directory
goto libfail;
- DL_PUSH(opendir(CWDSTR));
if (DL_CURDIR() == NULL) //open the cwd
goto libfail;
lexer_pushtok(CLOPEN, 0); //Push "Open Directory" token
return -1;
}
//Verify file header, get row_len/col_len
- if (read_img_header(&row_len, &col_len))
- return -1;
+ //if (read_img_header(&row_len, &col_len))
+ //return -1;
row = 0;
}
//Read pixels into the buffer if there are rows left in the image
/* Standard */
#include <stdio.h> //print
#include <errno.h> //errors
-#include <string.h> //strnlen
+#include <string.h> //strndupa
/* Posix */
#include <stdlib.h> //exit
#include <unistd.h> //getopt
#include <stdio.h> //print
#include <errno.h> //errors
#include <string.h> //strnlen
+#include <setjmp.h> //non-local jumps
/* Posix */
#include <stdlib.h> //exit
#include <unistd.h> //getopt
int test_yyparse(void);
extern //bison
-int yyparse(void);
+int yyparse(void);
extern //lexer.c
int lexer_init(void);
+extern //scanner.c
+int scanner_init(void);
extern //apc.c
const char* cargs['Z'];
extern //lexer.c
int lexer(void);
+static
+jmp_buf testapc_jump;
+
/* Ansi Term Colors */
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
( int argc,
char* argv[]
)
-{ apc_main(argc, argv);
+{ setjmp(testapc_jump);
+ apc_main(argc, argv);
printf(GREEN "PASS" CLRC "\n");
exit(EXIT_SUCCESS);
}
return YYABORT;
}
bPassedTest = 't';
- apc_main(0,NULL);
+ longjmp(testapc_jump,0);
}
return yyparse();
}