From 67553bb86c5a55f7db32be783bdb2abdbd616b02 Mon Sep 17 00:00:00 2001
From: GeneralGuy4872
Date: Fri, 27 Sep 2019 21:06:10 -0500
Subject: [PATCH] work on parsers, dependencies
---
README.md | 23 +++--
manual/plaintext/midibasic | 16 ++--
src/extensionlanguage/extensionlang.lex | 13 ++-
src/extensionlanguage/extensionlang.y | 24 ++---
src/extensionlanguage/precedanceprelim | 3 +-
src/iwannaflycurses.messy | 90 ++++++++++---------
src/midibasic/midibasic.lex | 115 +++++++++++++-----------
src/midibasic/midibasic.y | 77 ++++++++++++++++
8 files changed, 227 insertions(+), 134 deletions(-)
create mode 100644 src/midibasic/midibasic.y
diff --git a/README.md b/README.md
index d4bc565..32e8ec5 100644
--- a/README.md
+++ b/README.md
@@ -48,25 +48,23 @@ Depends (libraries by header):
- \
- \
- \
-
- \
- \
- \
- \
-- \
-- \
-- \
-- \
-- \
-- \
-
+- \
probably
+- \
probably
+- \
maybe?
+- \
maybe?
+- \
probably
+- \
probably
+- \<\CODE> maybe?
- \
- \
- \
-
- \
-- \
-- \
+- \
maybe?
+- \
maybe?
Recommends:
- xterm
, unicode, color
@@ -83,8 +81,9 @@ Doc Depends:
- man
- info
-Doc Meta-depends:
+Doc Build Deps:
- mandb
+- makeinfo
- install-info
- cp
diff --git a/manual/plaintext/midibasic b/manual/plaintext/midibasic
index cab652b..8d28930 100644
--- a/manual/plaintext/midibasic
+++ b/manual/plaintext/midibasic
@@ -1,17 +1,19 @@
+slightly depricated
+
/*
syntax:
-SPEED : number of pulses per second. there are 24 pulses in a quarter note.
+SPEED : number of pulses per second. there are 24 pulses in a quarter note.
-VOLUME : set how loud a channel is
+VOLUME : set how loud a channel is
-SPEED++ , VOLUME++ , DETUNE++ : increase a paramater
+SPEED++ , VOLUME++ , DETUNE++ : increase a paramater
-SPEED-- , VOLUME-- , DETUNE-- : decrease a paramater
+SPEED-- , VOLUME-- , DETUNE-- : decrease a paramater
-MUTE : set volume to zero
+MUTE : set volume to zero
-FORTE : set volume to maximum
+FORTE : set volume to maximum
KEY : change the key. default key is C major
@@ -43,4 +45,4 @@ LOOP
REPEAT : loop a portion of the song indefinately.
RAW : a raw packet
-*/
\ No newline at end of file
+*/
diff --git a/src/extensionlanguage/extensionlang.lex b/src/extensionlanguage/extensionlang.lex
index 9330ca2..3c84796 100644
--- a/src/extensionlanguage/extensionlang.lex
+++ b/src/extensionlanguage/extensionlang.lex
@@ -3,8 +3,7 @@ BOOLEAN ("T"|[Tt]("RUE"|"rue")|[Nn]("IL"|"il")|[Ff]("ALSE"|"alse"))
NAME [A-Za-z_\xC2-\xF4][A-Za-z0-9_\x80-\xBF\xC2-\xF4]*
VAR $([A-SU-Za-z]|[A-Za-z_\xC2-\xF4][A-Za-z0-9_\x80-\xBF\xC2-\xF4]+)
PTRVAR [\*&]+([A-SU-Za-z]|[A-Za-z_\xC2-\xF4][A-Za-z0-9_\x80-\xBF\xC2-\xF4]+)
-NUMBER [0-9]+
-SIGNED -[0-9]+
+NUMBER -?[0-9]+
FLOAT -?([0-9]+)?\.[0-9]+
NANTOK (-?[Ii]("NFINITY"|"nfinity")|[Nn][Aa][Nn])
HEX ("0x")[0-9a-fA-F]+
@@ -102,13 +101,12 @@ FI [Ff][Ii]
{NAME} yyval.string = strdup(yytext);return(NAME);
{VAR} yyval.string = strdup(&(yytext[1]));return(VAR);
{PTRVAR} yyval.string = strdup(yytext);return(VAR);
-{NUMBER} yyval.number = strtoul(yytext,NULL,10);return(NUMBER);
-{SIGNED} yyval.number = atoi(yytext);return(SIGNED);
+{NUMBER} yyval.number = atoi(yytext);return(NUMBER);
{FLOAT} yyval.dval = atof(yytext);return(FLOAT);
{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(yytext,"T") || strcmp(toupper(yytext),"TRUE"));return(BOOLEAN);
+{HEX} yyval.deadbeef = strtoul(yytext,NULL,16);return(RAW);
+{OCTAL} yyval.deadbeef = strtoul(yytext,NULL,8);return(RAW);
+{BOOLEAN} yyval.boolean = !(strcmp(yytext,"T") || strcmp(toupper(yytext),"TRUE"));return(BOOLEAN);
{ERRVAL} yyval.number = -(!(strcmp(toupper(yytext),"ERR"))));return(ERRVAL);
{NULLTOK} return(NULLTOK);
"+" return '+';
@@ -136,6 +134,7 @@ FI [Ff][Ii]
{APPROX} return(APPROX);
{BITNOR} return(BITNOR);
"~" return '~';
+"¬" return "~";
{LOGAND} return(LOGAND);
"&" return '&';
{LOGOR} return(LOGOR);
diff --git a/src/extensionlanguage/extensionlang.y b/src/extensionlanguage/extensionlang.y
index d743e6c..07fc940 100644
--- a/src/extensionlanguage/extensionlang.y
+++ b/src/extensionlanguage/extensionlang.y
@@ -1,7 +1,9 @@
%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 BOOLEAN RAW NUMBER SIGNED ERRVAL
+%token NUMBER ERRVAL
+%token RAW
+%token BOOLEAN
%token NAME VAR TEXT UTF8 TYPENAME
-%token FLOAT NANTOK
+%token FLOAT NANTOK
%top {
#include stuff here
@@ -10,9 +12,12 @@
%union
{
- intptr_t number;
+ bool boolean;
+ int number;
char* string;
double dval;
+ intptr_t deadbeef;
+ void* ptr;
}
%%
@@ -52,7 +57,7 @@ variable
: 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 '[' intergaliteral ']' {$$ = runtime__arraysub($1,$3)}
| variable '[' literalparenth ']' {$$ = runtime__arraysub($1,$3)}
| variable '[' anything ']' {$$ = runtime__arraysub_noncon($1,$3)}
;
@@ -109,16 +114,11 @@ intergal
;
intergaliteral
- : SIGNED
+ : NUMBER
+ | BOOLEAN
+ | RAW
| ERRVAL
| NULLTOK {$$ = NULL}
- | unsigned
- ;
-
-unsigned
- : BOOLEAN
- | RAW
- | NUMBER
;
real
diff --git a/src/extensionlanguage/precedanceprelim b/src/extensionlanguage/precedanceprelim
index bc32a38..f3efbdb 100644
--- a/src/extensionlanguage/precedanceprelim
+++ b/src/extensionlanguage/precedanceprelim
@@ -11,7 +11,8 @@
→ multiplication, bitwise and
← modulo
← tetriation, expotentiation
+→ factorial
← negative, not, bitwise not, prefix ++, --
X functions, parenthases
-(note: pointers and derefs are either a cast or part of the variable token itself)
\ No newline at end of file
+(note: pointers and derefs are either a cast or part of the variable token itself)
diff --git a/src/iwannaflycurses.messy b/src/iwannaflycurses.messy
index a7459a0..d4aef60 100644
--- a/src/iwannaflycurses.messy
+++ b/src/iwannaflycurses.messy
@@ -39,38 +39,38 @@
*
* a game compiled for the engine should obey the following conventions:
* - it should provide the bulk of it's functions in a shared library in a private
- * application directory
+ * application directory
* - it should provide special use functions, such as events, as seperate shared objects,
- * to be dynamically loaded at runtime.
+ * to be dynamically loaded at runtime.
* - it should provide special use constants likewise
- * blocks of text, however, should be regular nfo or txt
+ * blocks of text, however, should be regular nfo or txt
* - it should store any dynamic constants in the savefile, as r, hex, tsv, csv, ini, txt, nfo
* - it should provide at least the following applications (in $PATH) :
- * - the game itself
- * - a seperate program for generating a new savefile
+ * - the game itself
+ * - a seperate program for generating a new savefile
* - should use (int argc, char *argv[]) to provide bypassing of dotfile,
* path to a non-default dotfile, overrides of race, class, alignment prefs,
* and other flags as desired. parsed by a different parser from the dotfile.
- * - a savefile editor
+ * - a savefile editor
*
* enviromental requirements:
* - 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)
+ * 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)
* - ANSI SGR escape codes and 16 colors outside of NCurses
* The engine will recognise the term enviroment and can sent xterm-style OSC strings if they are supported as well
* - NCurses with support for A_BOLD, A_ITALIC, A_UNDERLINE, A_DIM, A_BLINK, A_REVERSE, A_INVIS, 8 colors, and 64 color pairs
* - Full Keyboard
- * (most keyboard layouts with all ASCII characters *should*
- * work, but only QWERTY (US-ANSI) was used in design because
- * I don't have access to any others, so at best controls may
- * be strange on them.
- * want to eventually guaruntee support for other keymappings;
- * not just for other QWERTY layouts, but also for QWERTZ, AZERTY,
- * and Dvorak, by request and/or the ability to remap keys
- * by dotfiles.)
+ * (most keyboard layouts with all ASCII characters *should*
+ * work, but only QWERTY (US-ANSI) was used in design because
+ * I don't have access to any others, so at best controls may
+ * be strange on them.
+ * want to eventually guaruntee support for other keymappings;
+ * not just for other QWERTY layouts, but also for QWERTZ, AZERTY,
+ * 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),
@@ -102,11 +102,11 @@
* This program is divided into 3 layers:
*
* the API layer is the part that provides functions to help with events.
- * this is the only part you should need to know to compile your own
- * games that can get fairly complex. these alse include the internal
- * utilitys for character encoding conversion, input buffering, room
- * generation and pathfinding algorithems, dice, warping, dying, error,
- * and the internal implementation of cat.
+ * this is the only part you should need to know to compile your own
+ * games that can get fairly complex. these alse include the internal
+ * utilitys for character encoding conversion, input buffering, room
+ * generation and pathfinding algorithems, dice, warping, dying, error,
+ * and the internal implementation of cat.
*
* while the API functions have a simple enough calling convention,
* there is no garuntee that the code underneath is not hundreds of lines long.
@@ -121,16 +121,16 @@
* engineloop()
*
* the middle layer, or the guts, is where the engine actually happens, and
- * it isn't pretty. if you want to change how the game works,
- * it's going to get messy. this is where the functions for
- * the RPG system itself, loading and saving, turns, shadows,
- * 3D rendering, and room changing are placed. these should not
- * usually called directly by events, only by other builtin
+ * it isn't pretty. if you want to change how the game works,
+ * it's going to get messy. this is where the functions for
+ * the RPG system itself, loading and saving, turns, shadows,
+ * 3D rendering, and room changing are placed. these should not
+ * usually called directly by events, only by other builtin
* functions; some are only called by main.
*
* the backend consists of shims between generalized internal representations of
- * a thing, and the actual way that a library or driver expects it to be
- * formatted. the following are/will be considered part of this layer:
+ * a thing, and the actual way that a library or driver expects it to be
+ * formatted. the following are/will be considered part of this layer:
* - anything underneath a call to a parser
* - what goes on inside of the midi threads
* - the code underneath the savefile handling calls
@@ -138,7 +138,7 @@
* The API should always be backwards-compatable with all versions, from beta to doomsday.
* The Guts may have breaking changes between MAJOR versions, but not otherwise.
* The Backend depends on things beyond my control, and should be considered non-dependable.
- * special cases should be noted, that the savefile format and language version have
+ * special cases should be noted, that the savefile format and language version have
* their own versioning system. this still may be broken if the flex-yacc or
* compression libraries of the build enviroment are changed from expectations,
* but is a good start.
@@ -191,6 +191,7 @@
//#include
//#include
//#include
+//#include
/**compression libraries**/
#include
@@ -242,8 +243,8 @@ addnwstr(&wch,1);
* using narrow characters with printw or addch
* using wide characters with these functions
* setting attributes with attrset, attron, attroff, and chgat
- * uses A_DIM, A_BOLD, A_ITALIC, A_UNDERLINE, A_REVERSE, A_BLINK, A_INVIS,
- * and 64 color pairs made from 8 colors
+ * uses A_DIM, A_BOLD, A_ITALIC, A_UNDERLINE, A_REVERSE, A_BLINK, A_INVIS,
+ * and 64 color pairs made from 8 colors
* using the above custom functions to put wide characters on
* the screen using addstr, addnstr, addwstr, addnwstr to print strings
* pausing curses and dumping an entire file with printf
@@ -251,7 +252,8 @@ addnwstr(&wch,1);
/*ENVIROMENTALS*/
#define BUFFER_MAX 512
-#define FLOPPYDISK 1474560
+#define FLOPPYSIZE 1474560
+#define DRUMSIZE 16384
#define BGCOLORS 8
#define FGCOLORS 8
char16_t TILDEWIDE
@@ -326,15 +328,15 @@ char* TERM
//anonomous pointers, could be anything. they're anonomous.
struct drum {
- char data[FLOPPYDISK]
- smint top
+ char data[DRUMSIZE]
+ sshort top
}
void* drumalloc (ptr,amount)
struct drum ptr
size_t amount
{
-if ((ptr→top + amount) ≤ (FLOPPYDISK + 1)) {
+if ((ptr→top + amount) ≤ (DRUMSIZE)) {
void* output = ptr→data[ptr→top]
ptr→top += amount
return output
@@ -1736,14 +1738,14 @@ bool sleepproof : 1
bool poisonproof : 1
struct sensetyp:
-trouble
-invis
-infra
-blind
-good
-evil
-law
-chaos
+bool trouble : 1
+bool invis : 1
+bool infra : 1
+bool blind : 1
+bool good : 1
+bool evil : 1
+bool law : 1
+bool chaos : 1
struct effectyp:
the8stats eight
diff --git a/src/midibasic/midibasic.lex b/src/midibasic/midibasic.lex
index d4414c7..a1b9e28 100644
--- a/src/midibasic/midibasic.lex
+++ b/src/midibasic/midibasic.lex
@@ -1,63 +1,76 @@
-NOTE [A-G][0-9][#%b]?
-KEYSIG ([#]{1,9}|[b]{1,9}|[A-G][#%b]?)?
-
-NUMBER [0-9]+
-HEX ("0x"|"$")[0-9a-fA-F]+
-OCTAL @[0-7]+
-
-INDENT ^[ \t]+
-SPACE [ \t]
-
-SPEEDTOK "SPEED"
-KEYTOK "KEY"
-DETUNETOK "DETUNE"
-NOTETOK "NOTE"
-CUTTOK "CUT"
-INSTTOK "INSTRUMENT"
-VOLTOK "VOLUME"
-MUTETOK "MUTE"
-FORTETOK "FORTE"
-ONTOK "ON"
-OFFTOK "OFF"
-SUSTOK "SUSTAIN"
-WAITTOK "WAIT"
-ENDTOK "END"
-LOOPTOK "LOOP"
-REPEATTOK "REPEAT"
-RAWTOK "RAW"
+NOTE [A-G][0-9]
+CHORD ([Mm]|"maj"|"min"|"sus"|"dim"|"aug"|"!7")
+
+NUMBER [0-9]+
+HEX ("0x"|"$")[0-9a-fA-F]+
+OCTAL @[0-7]+
+
+INDENT ^[\t\x1C- ]+
+SPACE [\t\x1C- ]
+NEWLINE [\n\r\f\v]+
+
+LOUD ("LOUD"|"FORTE")
+SUSTAIN ("SUSTAIN"|"DAMPER")
+WAIT ("WAIT"|"REST")
+DOUBLESHARP ("*"|"x"|"##")
%{
#include
#include
#include "y.tab.h"
+short accum;
%}
+
+%s KEYCOND CORDCOND
%%
{INDENT};
{SPACE};
-"\n" return '\n';
+{NEWLINE} return '\n';
+{NEWLINE} yyval.number = accum;accum = 0;BEGIN(0);return(KEYBREAK);
-{NOTE} yyval.string = strdup(yytext);return(NOTE);
-{KEY} yyval.string = strdup(yytext);return(KEY);
+{NOTE} yyval.twovals.quot = yytext[0];yyval.twovals.rem = atoi(yytext);return(NOTE);
+{NOTE} yyval.twovals.quot = yytext[0];yyval.twovals.rem = atoi(yytext);accum = 0;BEGIN(0);return(NOTE);
{NUMBER} yyval.number = atoi(yytext);return(NUMBER);
-{HEX} yyval.number = strtoul(yytext,NULL,16);return(HEX);
-{OCTAL} yyval.number = strtoul(yytext,NULL,8);return(OCTAL);
-
-SPEEDTOK "SPEED" return(SPEEDTOK);
-KEYTOK "KEY" return(KEYTOK);
-DETUNETOK "DETUNE" return(DETUNETOK);
-NOTETOK "NOTE" return(NOTETOK);
-CUTTOK "CUT" return(CUTTOK);
-INSTTOK "INSTRUMENT" return(INSTTOK);
-VOLTOK "VOLUME" return(VOLTOK);
-MUTETOK "MUTE" return(MUTETOK);
-FORTETOK "FORTE" return(FORTETOK);
-ONTOK "ON" return(ONTOK);
-OFFTOK "OFF" return(OFFTOK);
-SUSTOK "SUSTAIN" return(SUSTOK);
-WAITTOK "WAIT" return(WAITTOK);
-ENDTOK "END" return(ENDTOK);
-LOOPTOK "LOOP" return(LOOPTOK);
-REPEATTOK "REPEAT" return(REPEATTOK);
-RAWTOK "RAW" return(RAWTOK);
-%%
\ No newline at end of file
+{HEX} yyval.number = strtoul(&(yytext[1]),NULL,16);return(NUMBER);
+{OCTAL} yyval.number = strtoul(yytext,NULL,8);return(NUMBER);
+
+"SPEED" return(SPEEDTOK);
+"KEY" BEGIN(KEYCOND);return(KEYTOK);
+"DETUNE" return(DETUNETOK);
+"NOTE" return(NOTETOK);
+"CUT" return(CUTTOK);
+"INSTRUMENT" return(INSTTOK);
+"BANK" return(BANKTOK);
+"VOLUME" return(VOLTOK);
+"MUTE" return(MUTETOK);
+{LOUD} return(LOUDTOK);
+"ON" return(ONTOK);
+"OFF" return(OFFTOK);
+{SUSTAIN} return(SUSTOK);
+"PORTAMENTO" return(PORTTOK);
+"SOSTENUTO" return(SOSTTOK);
+"SOFT" return(SOFTTOK);
+{WAIT} return(WAITTOK);
+"END" return(ENDTOK);
+"[:" return(LOOPSTART);
+":]" return(LOOPEND);
+"RAW" return(RAWTOK);
+
+"#" accum++;
+"b" accum--;
+"#" yyval.number = 1;return(SIGN);
+{DOUBLESHARP} yyval.number = 2;return(SIGN);
+"%" yyval.number = 0;return(SIGN);
+"b" yyval.number = -1;return(SIGN);
+"bb" yyval.number = -2;return(SIGN);
+
+"++" return(INCR);
+"--" retunr(DECR);
+"(" return '(';
+")" return ')';
+"," return ',';
+"\"" BEGIN(CORDCOND);
+{CHORD} yyval.string = strcpy(yytext);return(CHORDTOK);
+"\"" BEGIN(0);
+%%
diff --git a/src/midibasic/midibasic.y b/src/midibasic/midibasic.y
new file mode 100644
index 0000000..0e58f6d
--- /dev/null
+++ b/src/midibasic/midibasic.y
@@ -0,0 +1,77 @@
+%token SPEEDTOK KEYTOK DETUNETOK NOTETOK CUTTOK INSTTOK BANKTOK VOLTOK MUTETOK LOUDTOK ONTOK OFFTOK SUSTOK PORTTOK SOSTTOK SOFTTOK WAITTOK ENDTOK LOOPSTART LOOPEND INCR DECR
+%token NOTE
+%token CHORDTOK
+%token NOTE NUMBER SIGN KEYBREAK
+
+%top{
+struct chord {
+ struct cord next
+ char data
+ }
+
+%union{
+ div_t twovals
+ int number
+ char* string
+}
+
+%%
+instruction
+ : SPEEDTOK NUMBER '\n'
+ | SPEEDTOK INCR NUMBER '\n'
+ | SPEEDTOK DECR NUMBER '\n'
+ | VOLTOK NUMBER NUMBER '\n'
+ | VOLTOK INCR NUMBER NUMBER '\n'
+ | VOLTOK DECR NUMBER NUMBER '\n'
+ | MUTETOK NUMBER '\n'
+ | LOUDTOK NUMBER '\n'
+ | KEYTOK NUMBER KEYBREAK
+ | KEYTOK NUMBER notevalue '\n'
+ | INSTTOK NUMBER NUMBER '\n'
+ | BANKTOK NUMBER NUMBER '\n'
+ | SUSTOK NUMBER '\n'
+ | PORTTOK NUMBER '\n'
+ | SOSTTOK NUMBER '\n'
+ | SOFTTOK NUMBER '\n'
+ | DETUNETOK ONTOK NUMBER NUMBER '\n'
+ | DETUNETOK INCR NUMBER NUMBER '\n'
+ | DETUNETOK DECR NUMBER NUMBER '\n'
+ | DETUNETOK OFFTOK NUMBER '\n'
+ | NOTETOK ONTOK NUMBER value NUMBER '\n'
+ | NOTETOK OFFTOK NUMBER value NUMBER '\n'
+ | NOTETOK ONTOK NUMBER chord NUMBER '\n'
+ | NOTETOK OFFTOK NUMBER chord NUMBER '\n'
+ | CUTTOK NUMBER '\n'
+ | WAITTOK NUMBER '\n'
+ ;
+
+value
+ : NOTE
+ | NOTE SIGN
+ | notevalue
+ | notevalue
+ ;
+
+chordlist
+ : notevalue ',' notevalue
+ | chord ',' notevalue
+ | notevalue CHORDTOK
+ ;
+
+chord
+ : '(' chordlist ')'
+ ;
+
+movement
+ : instruction
+ | movement instruction
+ ;
+
+loop
+ : LOOPSTART movement LOOPEND
+ ;
+
+song
+ : movement ENDTOK
+ | movement loop
+ ;