Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
various fixes to programming language
Browse files Browse the repository at this point in the history
  • Loading branch information
GeneralGuy4872 committed Sep 29, 2019
1 parent 67553bb commit c11e66e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 20 deletions.
3 changes: 3 additions & 0 deletions manual/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ pre {
.basic {
background-color: mediumslateblue;
color: snow;
}
.oxturn {
transform: scale(-1, 1);
}
8 changes: 6 additions & 2 deletions src/extensionlanguage/extensionlang.lex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ENDQUOTE [^\\]"
ENDPRIME [^\\]'
TEXT [.]+
CHAR [\0-\x7F]
UTF8 ("\xC0\x80"|[\xC2-\xDF][\x80-\xBF]|[\x70-\x7F][\x80-\xBF][\x80-\xBF]|[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF]|[\xF8-\xFB][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF]|[\xFC\xFD][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF])
UTF8 ("\xC0\x80"|[\xC2-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF][\x80-\xBF]|[\xF0-\xF4][\x80-\xBF][\x80-\xBF][\x80-\xBF]|
ERRVAL ([Oo][Kk]("AY"|"ay")?|[Ee]("RR"|"rr"))

STRUCTPTR ("->"|"")
Expand All @@ -39,6 +39,7 @@ ASSIGN (":="|"←")
WHITESPACE [\a\t-\r\034- ]+
NULLTOK [Nn]("ULL"|"ull")

FLIP [Ff]("LIP"|"lip")
SWITCH [Ss]("WITCH"|witch")
CASE [Cc]("ASE"|"ase")
IF [Ii][Ff]
Expand Down Expand Up @@ -114,6 +115,8 @@ FI [Ff][Ii]
"-" return '-';
"*" return '*';
"/" return '/';
"D%" return 'D';
"d%" return 'd';
"%" return '%';
{BITLEFT} return(BITLEFT);
{LOGIFF} return(LOGIFF);
Expand Down Expand Up @@ -147,7 +150,8 @@ FI [Ff][Ii]
";" return ';';
"," return ',';
"\\" return '\\';
{SWITCH} return(SWITCH)
{FLIP} return(FLIP);
{SWITCH} return(SWITCH);
{CASE} return(CASE);
{IF} return(IF);
{THEN} return(THEN);
Expand Down
9 changes: 7 additions & 2 deletions src/extensionlanguage/extensionlang.y
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%token LSTRUCT STRUCTPTR BITLEFT LE BITRIGHT GE LOGAND LOGOR LOGNAND LOGNOR LOGIFF LOGXOR EQ EQUALS APPROX BITNOR NE ASSIGN NULLTOK HUP SWITCH CASE IF THEN ELSE WHILE UNTIL FOR FOREVER DO AFTER BREAK RETURN FI BEGIN END
%token LSTRUCT STRUCTPTR BITLEFT LE BITRIGHT GE LOGAND LOGOR LOGNAND LOGNOR LOGIFF LOGXOR EQ EQUALS APPROX BITNOR NE ASSIGN NULLTOK FLIP SWITCH CASE IF THEN ELSE WHILE UNTIL FOR FOREVER DO AFTER BREAK RETURN FI BEGIN END
%token <number> NUMBER ERRVAL
%token <deadbeef> RAW
%token <boolean> BOOLEAN
Expand All @@ -16,7 +16,7 @@
int number;
char* string;
double dval;
intptr_t deadbeef;
uintptr_t deadbeef;
void* ptr;
}

Expand Down Expand Up @@ -146,6 +146,9 @@ literalexpression
| '!' literalexpression {$$ = !($2)}
| literalexpression '!' {$$ = util__factorial($1)}
| literalexpression optsp '?' optsp literalexpression optsp ':' optsp literalexpression {$$ = $1 ? $5 : $9}
| literalexpression 'D' literalexpression {$$ = util__roll($1,$2,true)}
| literalexpression 'd' literalexpression {$$ = util__roll($1,$2,false)}
| FLIP {$$ = util__flip}
;
/* more later
* these are the reducibles
Expand Down Expand Up @@ -239,6 +242,8 @@ function
| '-' '-' variable {$$ = runtime__queue_decr_pre($3)}
| variable '+' '+' {$$ = runtime__queue_incr_post($1)}
| variable '-' '-' {$$ = runtime__queue_decr_post($1)}
| anything 'D' anything {$$ = runtime__roll($1,$2,true)}
| anything 'd' anything {$$ = runtime__roll($1,$2,false)}
;
/* section complete! */

Expand Down
49 changes: 33 additions & 16 deletions src/extensionlanguage/runtime.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
#include "../dummy.c"

struct runtime__args
union runtime__union {
bool boolean;
int number;
char* string;
double dval;
uintptr_t deadbeef;
void* ptr;
}

enum runtime__type {boolean,number,string,dval,deadbeef,ptr}

struct runtime__arg {
runtime__union data;
runtime__type type;
}

struct runtime__instruction {
struct runtime__instruction *prev
struct runtime__instruction *next

runtime__OPCODES type

void* left
void* right
void* foo
void* bar
runtime__arg left
runtime__arg right
runtime__arg foo
runtime__arg bar
}

struct runtime__list {
struct runtime__list *prev;
struct runtime__list *next;
intptr_t number;
char* string;
double dval;
YYSTYPE data
}

enum runtime__OPCODES {OPCODE_FETCH,OPCODE_ASSIGN,OPCODE_VALUE,OPCODE_EXPRESSION,
OPCODE_FUNCTION,OPCODE_IF,OPCODE_IF_ELSE,OPCODE_WHILE,OPCODE_UNTIL,OPCODE_FOREVER,
OPCODE_FOR,OPCODE_FORNOT,OPCODE_PRE_INCR,OPCODE_POST_INCR,OPCODE_PRE_DECR,
OPCODE_POST_DECR,OPCODE_ADD,OPCODE_SUB,OPCODE_MULT,OPCODE_DIV,OPCODE_MOD,OPCODE_LOGAND,
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,
enum runtime__OPCODES {OPCODE_FETCH,OPCODE_ASSIGN,OPCODE_VALUE,
OPCODE_CAST,OPCODE_DEREF,OPCODE_STRUCT,OPCODE_STRUCT_POINTER,
OPCODE_ARRAYSUB,OPCODE_EXPRESSION,OPCODE_FUNCTION,OPCODE_IF,OPCODE_IF_ELSE,
OPCODE_WHILE,OPCODE_UNTIL,OPCODE_FOREVER,OPCODE_FOR,OPCODE_FORNOT,
OPCODE_PRE_INCR,OPCODE_POST_INCR,OPCODE_PRE_DECR,OPCODE_POST_DECR,
OPCODE_ADD,OPCODE_SUB,OPCODE_MULT,OPCODE_DIV,OPCODE_MOD,OPCODE_LOGAND,
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,OPCODE_ROLL}
/*each opcode defines what to do to the arguments*/

1 change: 1 addition & 0 deletions src/iwannaflycurses.messy
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,7 @@ lightyp *lamp_ptr
*/

/* dat file format:
* BOM ESC ! @ IWannaFLyCurses DataFile NUL = Magic Cookie (no spaces)
* SOH name STX string ETX SEPERATOR = a text field
* SOH name DLE 16bit_length raw_data SEPERATOR = a numeric field
* SOH name ACK SEPERATOR = a boolean field that is true
Expand Down

0 comments on commit c11e66e

Please sign in to comment.