2017-04-22 18:39:52 +00:00
|
|
|
/*************************************
|
|
|
|
* C02 Input File Parsing Routines *
|
|
|
|
*************************************/
|
|
|
|
|
2017-05-01 01:17:50 +00:00
|
|
|
#define TF(x) (x) ? TRUE : FALSE;
|
|
|
|
|
2017-06-27 00:16:23 +00:00
|
|
|
enum stypes {CONSTANT, VARIABLE, ARRAY, FUNCTION}; //Symbol Types
|
|
|
|
enum etypes {ETDEF, ETMAC}; //Definition Types
|
2017-04-22 18:39:52 +00:00
|
|
|
|
|
|
|
char word[LINELEN]; //Word parsed from source file
|
2017-06-27 00:16:23 +00:00
|
|
|
char uword[LINELEN]; //Word converted too uppercase
|
2017-04-22 18:39:52 +00:00
|
|
|
char nxtwrd[LINELEN]; //Next Word (from DEFINE lookup)
|
|
|
|
int nxtptr; //Pointer to next character in nxtwrd
|
|
|
|
char value[LINELEN]; //Term parsed from equation
|
|
|
|
int valtyp; //Value Type
|
|
|
|
char oper; //Arithmetic or Bitwise Operator
|
2017-06-27 00:16:23 +00:00
|
|
|
int cnstnt; //Value of Parsed Constant
|
2017-04-22 18:39:52 +00:00
|
|
|
|
|
|
|
char defnam[MAXDEF+1][VARLEN+1]; //Definition Name Table
|
2017-06-27 00:16:23 +00:00
|
|
|
int defval[MAXDEF+1]; //Definition Value Table
|
2017-04-22 18:39:52 +00:00
|
|
|
int defcnt; //Number of Definitions Defined
|
2017-06-27 00:16:23 +00:00
|
|
|
int defidx; //Index into Definition Tables
|
2017-04-22 18:39:52 +00:00
|
|
|
|
|
|
|
int match(char c); //Does Next Character match c
|
|
|
|
int inbtwn(char mn, char mx); //Is Next Character in Range ()mn - mx)
|
|
|
|
int isprnt(); //Is Next Character Printable
|
|
|
|
int isalpa(); //Is Next Character Alphabetic
|
|
|
|
int isanum(); //Is Next Character AlphaNumeric
|
|
|
|
int isdec(); //Is Next Character a Decimal Digit
|
|
|
|
int ishexd(); //Is Next Character a Hexadecimal Digit
|
|
|
|
int isbin(); //Is Next Character a Binary Digit
|
|
|
|
int isnl(); //Is Next Character a NewLine
|
|
|
|
int isnpre(); //Is Next Character a Numeric Prfix
|
|
|
|
int isspc(); //Is Next Character a Space
|
|
|
|
int isapos(); //Is Next Character an Apostrophe
|
|
|
|
int isvpre(); //Is Next Character a Value Prefix
|
|
|
|
int isoper(); //Is Next Character an Operator
|
|
|
|
int ispopr(); //Is Next Character a Post-Operator
|
|
|
|
|
2018-01-28 18:38:17 +00:00
|
|
|
int invasc; //Invert ASCII Flag
|
|
|
|
char invchr(char c); //Invert Character Case
|
|
|
|
|
2017-04-22 18:39:52 +00:00
|
|
|
int wordis(char *s); //Does word match s
|
|
|
|
|
|
|
|
char getnxt(); //Return Next Character and Advance
|
|
|
|
int look(char c); //Look for Character
|
|
|
|
void expect(char c); //Look for Character and Exit if not found
|
|
|
|
|
|
|
|
void skpchr(); //Advance to Next Character
|
|
|
|
void skpeol(); //Skip to End of Line
|
|
|
|
void skpspc(); //Advance to Next Printable Character
|
|
|
|
void skpcmt(); //Skip to End of Comment
|
|
|
|
|
|
|
|
void getwrd(); //Get Next Word
|
|
|
|
|
|
|
|
int prsdec(); //Get Decimal Number
|
|
|
|
|
2017-06-27 00:16:23 +00:00
|
|
|
void prscon(); //Parse a Constant
|
2017-04-22 18:39:52 +00:00
|
|
|
void prsopr(); //Parse Arithmetic Operator
|
2017-06-27 00:16:23 +00:00
|
|
|
void prsvar(int alwreg); //Parse Variable
|
|
|
|
|