diff --git a/src/dependencies.ini b/src/dependencies.ini index e484f4e..2c5ff12 100644 --- a/src/dependencies.ini +++ b/src/dependencies.ini @@ -1,3 +1,5 @@ +;initial framework, never valid + ;dependencies that are implicitly fufilled by inheritance are not shown ;cross-calling of source is marked with depends ;calling of shared libraries is marked extern diff --git a/src/extensionlanguage/extensionlang.lex b/src/extensionlanguage/extensionlang.lex index 73513df..aaca5d6 100644 --- a/src/extensionlanguage/extensionlang.lex +++ b/src/extensionlanguage/extensionlang.lex @@ -32,7 +32,7 @@ LOGIFF ([Ii]("FF"|"ff")|"⇔"|"<>") LOGXOR ([Ee]?[Xx][Oo][Rr]) EQ ([Ee][Qq]|"≡") EQUALS ([=][=]|[Ee]("QUAL"|"qual")) -APPROX ("?="|[Aa]("PPROX"|"pprox")|"≈") +APPROX ("=~"|[Aa]("PPROX"|"pprox")|"≈") BITNOR ("~|"|"¥") NE ("!="|"≠"|[Nn][Ee]) NPR [Nn][Pp][RrKk] @@ -81,16 +81,16 @@ FI [Ff][Ii] "*/" yy_pop_state(); {TEXT}; -{WHITESPACE} return ' '; +{WHITESPACE} return ' '; "(" yy_push_state(FUNC); return '('; -")" yy_pop_state(); return ')'; +")" yy_pop_state(); return ')'; /*s-expressions and lists*/ "{" yy_push_state(EXPR); return '{'; "}" yy_pop_state(); return '}'; /*infix*/ "[" yy_push_state(ARR); return '['; -"]" yy_pop_state(); return ']'; +"]" yy_pop_state(); return ']'; /*c-like functions, structs, and arrays*/ {NAME} yyval.string = strdup(yytext);return(NAME); @@ -102,7 +102,7 @@ FI [Ff][Ii] {NANTOK} yyval.dval = atof(yytext);return(NANTOK); {HEX} yyval.number = strtoul(yytext,NULL,16);return(RAW); {OCTAL} yyval.number = strtoul(yytext,NULL,8);return(RAW); -{BOOLEAN} yyval.number = !(strcmp(toupper(yytext),"T") || strcmp(toupper(yytext),"TRUE"));return(BOOLEAN); +{BOOLEAN} yyval.number = !(strcmp(yytext,"T") || strcmp(toupper(yytext),"TRUE"));return(BOOLEAN); {ERRVAL} yyval.number = -(!(strcmp(toupper(yytext),"ERR"))));return(ERRVAL); {NULLTOK} return(NULLTOK); "+" return '+'; @@ -159,5 +159,4 @@ FI [Ff][Ii] {FI} return(FI); {BEGIN} return(BEGIN); {END} return(END); -{HUP} return '\003'; %% diff --git a/src/extensionlanguage/extensionlang.y b/src/extensionlanguage/extensionlang.y index 4d2bd75..0ee4c84 100644 --- a/src/extensionlanguage/extensionlang.y +++ b/src/extensionlanguage/extensionlang.y @@ -5,61 +5,45 @@ %top { #include stuff here -#include "runtime.h" -//inherits "../dummy.h" +#include "runtime.c" %} -%union { - long number; +%union +{ + intptr_t number; char* string; double dval; -%} +} %% -varname - : VAR {$$ = $1} - | varname '[' NUMBER ']' {$$ = strcat($1,strcat(strcat("[",$2),"]"))} - | varname STRUCTPTR NAME {$$ = strcat($1,strcat("->",$3))} - | varname '.' NAME {$$ = strcat($1,strcat(".",$3))} - ; - variable - : varname {$$ = runtime__fetchbyname($1)} + : VAR {$$ = runtime__fetch($1)} + | variable STRUCTPTR NAME {$$ = runtime__struct_pointer($1,$3)} + | variable '.' NAME {$$ = runtime__struct($1,$3)} + | variable '[' unsigned ']' {$$ = runtime__arraysub($1,$3)} + | variable '[' literalparenth ']' {$$ = runtime__arraysub($1,$3)} + | variable '[' anything ']' {$$ = runtime__arraysub_noncon($1,$3)} ; assignment - : varname ASSIGN anything {$$ = runtime__assignbyname($1,':',$3)} - | varname ' ' ASSIGN ' ' anything {$$ = runtime__assignbyname($1,':',$5)} - | varname '+' '=' quantity {$$ = runtime__assignbyname($1,'+',$4)} - | varname ' ' '+' '=' ' ' quantity {$$ = runtime__assignbyname($1,'+',$6)} - | varname '-' '=' quantity {$$ = runtime__assignbyname($1,'-',$4)} - | varname ' ' '-' '=' ' ' quantity {$$ = runtime__assignbyname($1,'-',$6)} - | varname '*' '=' quantity {$$ = runtime__assignbyname($1,'*',$4)} - | varname ' ' '*' '=' ' ' quantity {$$ = runtime__assignbyname($1,'*',$6)} - | varname '/' '=' quantity {$$ = runtime__assignbyname($1,'/',$4)} - | varname ' ' '/' '=' ' ' quantity {$$ = runtime__assignbyname($1,'/',$6)} - | varname '%' '=' intergal {$$ = runtime__assignbyname($1,'%',$6)} - | varname ' ' '%' '=' ' ' intergal {$$ = runtime__assignbyname($1,'%',$6)} - | varname BITLEFT '=' intergal {$$ = runtime__assignbyname($1,'L',$4)} - | varname ' ' BITLEFT '=' ' ' intergal {$$ = runtime__assignbyname($1,'L',$6)} - | varname BITRIGHT '=' intergal {$$ = runtime__assignbyname($1,'R',$6)} - | varname ' ' BITRIGHT '=' ' ' intergal {$$ = runtime__assignbyname($1,'R',$6)} - | varname '&' '=' intergal {$$ = runtime__assignbyname($1,'&',$4)} - | varname ' ' '&' '=' ' ' intergal {$$ = runtime__assignbyname($1,'&',$6)} - | varname '|' '=' intergal {$$ = runtime__assignbyname($1,'|',$4)} - | varname ' ' '|' '=' ' ' intergal {$$ = runtime__assignbyname($1,'|',$6)} - | varname '~' '&' '=' intergal {$$ = runtime__assignbyname($1,'N',$5)} - | varname ' ' '~' '&' '=' ' ' intergal {$$ = runtime__assignbyname($1,'N',$7)} - | varname BITNOR '=' intergal {$$ = runtime__assignbyname($1,'Y',$4)} - | varname ' ' BITNOR '=' ' ' intergal {$$ = runtime__assignbyname($1,'N',$6)} - | varname '^' '=' intergal {$$ = runtime__assignbyname($1,'^',$4)} - | varname ' ' '^' '=' ' ' intergal {$$ = runtime__assignbyname($1,'^',$6)} - | varname EQ '=' intergal {$$ = runtime__assignbyname($1,'E',$4)} - | varname ' ' EQ '=' ' ' intergal {$$ = runtime__assignbyname($1,'E',$6)} - | varname '~' '=' intergal {$$ = runtime__assignbyname($1,'~',$4)} - | varname ' ' '~' '=' ' ' intergal {$$ = runtime__assignbyname($1,'~',$6)} + : variable optsp ASSIGN optsp anything {$$ = runtime__assign($1,0,$5)} + | variable optsp '+' '=' optsp quantity {$$ = runtime__assign($1,'+',$6)} + | variable optsp '-' '=' optsp quantity {$$ = runtime__assign($1,'-',$6)} + | variable optsp '*' '=' optsp quantity {$$ = runtime__assign($1,'*',$6)} + | variable optsp '/' '=' optsp quantity {$$ = runtime__assign($1,'/',$6)} + | variable optsp '%' '=' optsp intergal {$$ = runtime__assign($1,'%',$6)} + | variable optsp BITLEFT '=' optsp intergal {$$ = runtime__assign($1,'<',$6)} + | variable optsp BITRIGHT '=' optsp intergal {$$ = runtime__assign($1,'>',$6)} + | variable optsp '&' '=' optsp intergal {$$ = runtime__assign($1,'&',$6)} + | variable optsp '|' '=' optsp intergal {$$ = runtime__assign($1,'|',$6)} + | variable optsp '~' '&' '=' optsp intergal {$$ = runtime__assign($1,~'&',$7)} + | variable optsp '&' '~' '=' optsp intergal {$$ = runtime__assign($1,'~',$7)} + | variable optsp BITNOR '=' optsp intergal {$$ = runtime__assign($1,~'|',$6)} + | variable optsp '^' '=' optsp intergal {$$ = runtime__assign($1,'^',$6)} + | variable optsp EQ '=' optsp intergal {$$ = runtime__assign($1,~'^',$6)} + | variable optsp '~' '=' optsp intergal {$$ = runtime__assign($1,-1,$6)} ; - /*section complete!*/ + /* section complete! */ anything : quantity @@ -114,11 +98,12 @@ expression : anything | literalexpression | expression - /*more later*/ ; + /* more later */ literalexpression : quantityliteral + | literalparenth | literalexpression ' ' '+' ' ' literalexpression {$$ = $2 + $5} | literalexpression ' ' '-' ' ' literalexpression {$$ = $2 - $5} | literalexpression ' ' '*' ' ' literalexpression {$$ = $2 * $5} @@ -127,18 +112,14 @@ literalexpression | literalexpression ' ' '*' '*' '*' ' ' literalexpression {$$ = pow($2,pow($2,$7))} | '!' literalexpression {$$ = !($2)} | literalexpression '!' {$$ = util__factorial($1)} - | literalexpression ' ' '?' ' ' literalexpression ':' literalexpression {$$ = $1 ? $5 : $7} - /*more later*/ - ; - -commaval - : anything {$$ = $1} - | ' ' commaval {$$ = $2} - | commaval ' ' {$$ = $1} + | literalexpression optsp '?' optsp literalexpression optsp ':' optsp literalexpression {$$ = $1 ? $5 : $9} ; + /* more later + * these are the reducibles + */ commalist - : commaval ',' commaval { + : anything ',' anything { $$ = malloc(sizeof(struct runtime__list)); $$->next = malloc(sizeof(struct runtime__list)); $$->prev = $$->next; @@ -151,7 +132,7 @@ commalist $$->next->number = $3->number; $$->next->ddval = $3->ddval; } - | commalist ',' commaval { + | commalist ',' anything { $$ = $1; { foo = malloc(sizeof(struct parser__list)); $$->prev->next = foo; @@ -167,13 +148,17 @@ commalist spacelist : anything ' ' anything { - $$ = malloc(sizeof(struct parser__list)); - $$->next = malloc(sizeof(struct parser__list)); + $$ = malloc(sizeof(struct runtime__list)); + $$->next = malloc(sizeof(struct runtime__list)); $$->prev = $$->next; $$->next->next = $$; $$->next->prev = $$; - $$->data = $1; - $$->next->data = $3; + $$->string = $1->string; + $$->number = $1->number; + $$->ddval = $1->ddval; + $$->next->string = $3->string; + $$->next->number = $3->number; + $$->next->ddval = $3->ddval; } | spacelist ' ' anything { $$ = $1; { @@ -182,7 +167,9 @@ spacelist foo->prev = $$->prev; $$->prev = foo; foo->next = $$; - foo->data = $3; + foo->string = $3->string; + foo->number = $3->number; + foo->ddval = $3->ddval; } } ; @@ -192,31 +179,35 @@ array | TEXT ; +literalparenth + : '(' optsp literalexpression optsp ')' {$$ = $3} + ; + parenth - : '(' commaval ')' {$$ = $2} - | '(' assignment ')' {$$ = $2} + : '(' optsp anything optsp ')' {$$ = $3} + | '(' optsp expression optsp ')' {$$ = $3} + | '(' optsp assignment optsp ')' {$$ = $3} + | literalparenth {$$ = $1} ; function - : NAME '(' ')' {$$ = runtime__queue_noargs($1)} - | NAME '(' anything ')' {$$ = runtime__queue($1,$3)} - | NAME '(' commalist ')' {$$ = runtime__queue_list($1,$3)} - | '(' NAME ')' {$$ = runtime__queue_noargs($2)} - | '(' NAME ' ' anything ')' {$$ = runtime__queue($2,$3)} - | '(' NAME ' ' spacelist ')' {$$ = runtime__queue_list($2,$3)} + : '`' NAME '`' {$$ = runtime__queue_noargs($2)} + | NAME '[' ']' {$$ = runtime__queue_noargs($1)} + | NAME '[' anything ']' {$$ = runtime__queue($1,$3)} + | NAME '[' commalist ']' {$$ = runtime__queue_list($1,$3)} + | '(' optsp NAME optsp ')' {$$ = runtime__queue_noargs($3)} + | '(' optsp NAME ' ' anything optsp ')' {$$ = runtime__queue($3,$5)} + | '(' optsp NAME ' ' spacelist optsp ')' {$$ = runtime__queue_list($3,$5)} | '+' '+' variable {$$ = runtime__queue_incr_pre($3)} | '-' '-' variable {$$ = runtime__queue_decr_pre($3)} | variable '+' '+' {$$ = runtime__queue_incr_post($1)} | variable '-' '-' {$$ = runtime__queue_decr_post($1)} ; - -preparetodie - : HUP {return(ERR);} - ; + /* section complete! */ dostuff : function {$$ = $1} - | parenth {$$ = NULL} + | parenth {$$ = $1} | assignment {$$ = runtime__queue_sane($1)} | ifthen {$$ = $1} | simpleloop {$$ = $1} @@ -271,4 +262,9 @@ caseentry caselist : caseentry caseentry {$$ = runtime__concat_case($1,$2)} | caselist caseentry {$$ = runtime__concat_case($1,$2)} - ; \ No newline at end of file + ; + +optsp + : /* empty */ + | ' ' + ; diff --git a/src/extensionlanguage/runtime.h b/src/extensionlanguage/runtime.h index 830e33e..e3e1a00 100644 --- a/src/extensionlanguage/runtime.h +++ b/src/extensionlanguage/runtime.h @@ -1,4 +1,4 @@ -#include "../dummy.h" +#include "../dummy.c" struct runtime__args @@ -29,4 +29,4 @@ OPCODE_POST_DECR,OPCODE_ADD,OPCODE_SUB,OPCODE_MULT,OPCODE_DIV,OPCODE_MOD,OPCODE_ OPCODE_LOGOR,OPCODE_LOGNAND,OPCODE_LOGNOR,OPCODE_LOGXOR,OPCODE_IFF,OPCODE_LOGNOT, OPCODE_AND,OPCODE_OR,OPCODE_NAND,OPCODE_NOR,OPCODE_XOR,OPCODE_EQ,OPCODE_NOT,OPCODE_GT, OPCODE_GE,OPCODE_EQUAL,OPCODE_NE,OPCODE_LT,OPCODE_LE,OPCODE_APPROX,OPCODE_EXP,OPCODE_TETRA, -OPCODE_RETURN,OPCODE_BREAK,OPCODE_NPR,OPCODE_NCR,OPCODE_FACT, \ No newline at end of file +OPCODE_RETURN,OPCODE_BREAK,OPCODE_NPR,OPCODE_NCR,OPCODE_FACT, diff --git a/src/iwannaflycurses.messy b/src/iwannaflycurses.messy index 5e75e8f..aa1cb6b 100644 --- a/src/iwannaflycurses.messy +++ b/src/iwannaflycurses.messy @@ -1,6 +1,8 @@ #error NOT READY FOR COMPILATION /* to preserve the file history, * this file will eventually become main.h, main.c, or util.c + * a dummy.h and dummy.c will provide externs and macros for linkage. + * some of the larger comment blocks will be moved to man, info, and/or doc * * the bulk of it's contents, however, will be moved. * @@ -52,8 +54,8 @@ * - a savefile editor * * enviromental requirements: - * - UTF-8 terminal of at least 25*80 characters - * "Fixed" font is recommended (specifically because + * - UTF-8 terminal of at least 24*80 characters + * "Fixed" font is recommended (specifically because * it is a raster font; monospaced raster fonts are more uniform in width than the majority of vector so-called "monospaced" fonts; * it is unicode, having a wide range of characters; and * it is extreamly common, being the default font for the linux console, xterm, and urxvt) @@ -70,13 +72,22 @@ * and Dvorak, by request and/or the ability to remap keys * by dotfiles.) * - Mouse (once pseudo-raycasting is implemented for looking afar) + * + * XTerm is the recommended X Terminal Emulator (the primary one used in testing), + * but the raw TTY Console set up in UTF8 locale will work just as well, + * maybe even better if memory is an issue. At first glance, A Vt241 or Vt3*0 + * seem to meet all the requirements, but note: they predate unicode. * * Controls: - * - number keys or arrow keys move in xy - * - page up and page down move in z + * - number keys move in xy + * - arrow keys move in x or y + * - < and > move in z + * - page up or page down, followed by a direction, move in xyz + * - home starts flying + * - end stops flying * - spacebar or 5 idle * - ! shows or hides sense trouble - * - . picks up items + * - . pick up items * - \ initiates the command console * more tbd * @@ -105,6 +116,7 @@ * enginesplash(name of game,game version,story revision) * * FIXCURSES + * * promptload() * engineloop() * @@ -152,8 +164,6 @@ * GPLv2 or later, All Wrongs Reserved */ - - /**standard libraries**/ #ifndef _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED @@ -244,7 +254,7 @@ addnwstr(&wch,1); #define FLOPPYDISK 1474560 #define BGCOLORS 8 #define FGCOLORS 8 -char16_t TILDEWIDE = setwidetilde() +char16_t TILDEWIDE #define BLINKY "\033[5m_\033[25m" char* TERM @@ -300,8 +310,10 @@ char* TERM #define sshort int16_t #define umint uint32_t #define smint int32_t -#define ulong uint64_t -#define slong int64_t +#define ulong unsigned long +#define slong signed long +#define ullong uint64_t +#define sllong int64_t /* the 3D version of Iwannafly started off as a general RT-RPG library that * then became narrowed to a specific game. this version was originally @@ -313,7 +325,7 @@ char* TERM */ //anonomous pointers, could be anything. they're anonomous. -void cachedrum = malloc(1024 * sizeof(char)) +void* cachedrum = malloc(1024 * sizeof(char)) uchar cachenext = 0 ushort cachealloc (amount) @@ -431,6 +443,14 @@ char* text * stored in a tsv */ +struct filelinetyp { +(self) *prev +(self) *next +ushort lineno +char* text +} +// used by the line editor + struct eventstringtyp { (self) *prev (self) *next @@ -599,12 +619,12 @@ roomtyp* ROOM int(latlontyp)* ROOMGENCALL[ROOF + 1][EQUATOR/2 + 1][EQUATOR] shadowmask SHADOWKNOWS shadowmask SHINEALIGHT -ulong TURN +ullong TURN nibbles TIMER schar ALARM = -1 turntyp DATE uchar ROOMTURN -ulong KILLS +ullong KILLS char* SAVEPATH followtype *FOLLOW_ptr //pursuers, i.e. paid assasins, ninjas, the reaper... eventtyp *EVNT_ptr //FOO_ptr refers to the doubly linked list's head. the tail is FOO_ptr→prev @@ -2826,15 +2846,18 @@ switch (tmp.rem) : { } engineloop () { -if (NEW) { - checkglobal(NEW_FLAG,true) - NEW = false +TILDEWIDE = setwidetilde() +forever { + if (NEW) { + checkglobal(NEW_FLAG,true) + NEW = false + } + checkevents() //check event triggers + player_act() //player's turn + follow_iter() //iterate through follower entities + ent_iter() //iterate through local entities + encounter(1D6,1d100) //generate up to 1D6 of monster number 1d100, iff encounter != NULL } -checkevents() //check event triggers -player_act() //player's turn -follow_iter() //iterate through follower entities -ent_iter() //iterate through local entities -encounter(1D6,1d100) //generate up to 1D6 of monster number 1d100 } /*pseudocode*/ _iter () { @@ -2927,8 +2950,8 @@ fflush(stdout); sleep(4); FIXCURSES do_intro_movie(); -promptload(argc,argv); -engineloop(argc,argv); +promptload(); +engineloop(); } /*blackbox*/exitengine() @@ -2996,4 +3019,12 @@ output = calloc(stringlen(buffer),sizeof(char)) strcpy(output,buffer) FIXCURSES return output -} \ No newline at end of file +} + +/*pseudocode*/resizetest +/*IF window is too small THEN PRINT + * "The terminal is too small." + * "Please increase the number of " ("rows"|"columns"|"rows and columns") + * "to avoid segmentation violations." + * "Press any key to continue"BLINKY + */