#include "sprite.h"
#include "symbol.h"
#include <png.h>
-
+ #include "ir.h"
extern int lexer_init();
extern int lexer();
%define parse.error verbose
%define lr.type ielr
%define api.value.type union
-%token <int> NUM
%token <char*> WORD
//operators
-%token PROTOCLASS //+
-%token SIBS //|
-%token FNAME //!
- //nonterminal types
-%type <int> fd
-%type <int*> fdlist
-
-/* %token <str> EXT */
-/* %token <str> FW */
-/* %token <str> 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 <int> element
+%type <int> vdat
+%type <str> elem_label
+//terminals
+%token <int> NUM
+%token <int> fd
+%token <str> STR
+%token <int> VAR
+%token <int> 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;
}