X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fparser.y;h=c16dc1880eb16c45e61579d77491959cc1da5117;hp=8a1db87c320840052fbc373cef2300467f8c2770;hb=471aea4902a6ed29a4f539335f12964682544057;hpb=882513ad6569a640cb5c90b83e27e742ace71b63 diff --git a/src/parser.y b/src/parser.y index 8a1db87..c16dc18 100644 --- a/src/parser.y +++ b/src/parser.y @@ -6,7 +6,7 @@ #include "sprite.h" #include "symbol.h" #include - + #include "ir.h" extern int lexer_init(); extern int lexer(); @@ -18,82 +18,154 @@ %define parse.error verbose %define lr.type ielr %define api.value.type union -%token NUM %token WORD //operators -%token PROTOCLASS //+ -%token SIBS //| -%token FNAME //! - //nonterminal types -%type fd -%type fdlist - -/* %token EXT */ -/* %token FW */ -/* %token SPR */ -/* %token CC */ -/* /\* Rules *\/ */ -/* %% */ -/* SS: SPR '/' MD '.' EXT */ -/* MD: CC '_' FW */ -/* | FW */ -/* | CC */ +%token CLOPEN // / +%token CLCLOSE // \ +%token RLS //! +%token RLE //# +%token RT //* +%token HB +//nonterminal types +%type element +%type vdat +%type elem_label +//terminals +%token NUM +%token fd +%token STR +%token VAR +%token SS +//precedence +%right LOW HIGH + +/* Syntax Directed Translation Scheme of the APC grammar */ + /* Rules */ %% +output: +class_list {condense();} //Seperate file? +; -object_defs: - %empty -| arch_id object_defs +class_list: +class_list class {cbi++;}; +| class ; -arch_id: - archetype -| arch_id_ref +class_label: +STR ; -arch_id_list: - arch_id -| arch_id arch_id_list +class: +class_label CLOPEN class_closure CLCLOSE {CB[cbi].label = $1;}; ; -archetype: - PROTOCLASS label arch_id_list SIBS arch_id_list -| PROTOCLASS label arch_id_list -| label arch_id_ref vdat +class_closure: +subclass_list +| subclass_list set_list +| set_list ; -label: - WORD +subclass_list: +subclass_list class {CB[cbi].subclass_index++;}; +| class +; + +set_list: +set_list set {CB[cbi].set_index++;}; +| set +; + + +//set needs a label, vdat_id. +set: +set_map_data element_list {insert_set();}; +| element_list +; + + +//TODO: Figure out what to do with hitbox and root. +set_map_data: +ref_list {}; +| ref_list hitbox +| ref_list hitbox root +| hitbox root +| hitbox +| root +; + +ref_list: +RLS quads RLE +; + +quads: +quads quad {OB[obi].ref_index++;OB[obi].num_ref++;}; +| quad +; + +quad: +NUM NUM NUM NUM {insert_ref($1, $2, $3, $4);}; ; -arch_id_ref: - NUM +hitbox: +HB NUM +; + +root: +RT NUM NUM NUM +; + +//parent_id is the set_index of the subclass_index. +element_list: +element_list element {CB[cbi].set_stack[stack_index].num_ele++;}; +| element +; + +element: +set_label elem_label vdat {insert_ele($2,$3); vbi++;}; +; + +set_label: + STR +; + +elem_label: + STR ; vdat: - spritesheet +vdat model {VB[vbi].num_models++;}; +| model ; -spritesheet: - fdlist +model: +model fdat +| fdat ; -fdlist: - fd -| fd fdlist +fdat: +label SS FNAME {insert_fdat($1, $2, $3);}; ; -fd: - FNAME WORD -| NUM; -%% +label: +STR +; +ref: +NUM +; + +FNAME: +STR +; + +%% int -main(int argc, char** argv) -{ /* Parse cmd line arguments */ +main (argc, argv) +{ lexer_init(); - yyparse(); /* runs handle_fname for each filename */ + yyparse(); return 0; }