/* PARSE.H Globals for Loglan yyparse driver Copyright (C) 1982-1992 by The Loglan Institute, Inc. Created 82.1.27 Gyro This file contains the declarations for PARSE.C. The macro "global" should be #defined to one of the following before including this file: "" for compilers (like BDS C) that merge externals "extern" for compilers (like Lattice, pcc) that don't (requires parse-ext.c) Jul 1987. Altered by RAM to make it compatible with Aztec C on the Macintosh while retaining Lattice compatibility. Changes are required to allow for pointers being long instead of integer and to include parse.h in ext.val instead of the reverse. Oct 1991 The new Aztec update uses 32 bit ints. All ints redefined as short */ #pragma once #define MACDOS //#define MAC //#define DOS #ifdef MACDOS #include #endif #ifdef DOS #include #endif #include #include "ctype.h" #include #include #include /* RAM Jul 87 Some extra definitions here. WORD_ALIGN is moved from elsewhere, and TRUE and FALSE need definition in Aztec C. The other y.tab.h etc. files are not needed, or are included with yc.tab in parse.c Boolean is made integer, and the YYMAXDEPTH is moved here.*/ #define WORD_ALIGN #ifdef MACDOS #define Boolean short #define TRUE 1 #define FALSE 0 #endif #define Asize 30000 #define FULL 18 #define MACHINE 16 /*Parse menu item*/ #define GPandLX 15 /*Parse menu item*/ #define GROUP 14 /*Button item*/ #define SHORT 17 /*Parse menu item*/ #define LEXEMES 19 /*Parse menu item*/ #define END 0 /* oh well */ #define YYMAXDEPTH 150 /*for YACC stack*/ #define MAXLEX 90 /*maximum number of lexemes*/ #define NUL '\0' #define repeat while (1) #define pinfile 0 /*File numbers for Mac version*/ #define poutfile 1 #define tabfile 2 #define savefile 3 #define CR '\r' #define BS '\b' #define SP ' ' #define FF '\f' #define DEL 0x7F #define BEL 0x7 #define NL '\n' #define scr_puts puts /*The following defines are for deindexing indexed lexemes.*/ #define A ZO+1 #define KA ZO+2 #define NO ZO+3 #define PA ZO+4 #define ZE ZO+5 #define GA ZO+6 #define GUU ZO+7 #define CONOUT stdout typedef FILE **STREAM; /* RAM Jul 87. Some additional definitions or rearrangements here to declare toupper, to lower and error, as well as YYSTYPE */ #define TREE union tree #define YYSTYPE TREE * /*For YYParse*/ #define BIGLIN 1000 /* max length of a long line */ #define CONTMAX 10 /* max number of nested utterances */ /* RAM Mar88 moved from yyparse for error recovery*/ /**************** Globals for parse tree stuff ****************/ typedef struct node { /* node in parse tree */ char type; /* always NODETYPE */ char nlength; /* number of children */ char *ngrameme; /* grammatical constituent */ union tree *nkids[1]; /* actually, length can vary */ }NODE; typedef struct leaf { /* leaf of parse tree */ char type; /* always LEAFTYPE */ char lsource; /* WSTART, WCONT, or WINVISIBLE */ short lexeme; /*lexeme for this leaf*/ char lword[1]; /* actually, NUL-term string of varying length */ }LEAF; #define NODETYPE 1 #define LEAFTYPE 2 #define WSTART 1 /* beginning of real word in specimen */ #define WCONT 2 /* now used for flagging names for ||s */ #define WINVISIBLE 3 /* word inserted by preparser or parser */ union tree { NODE n; LEAF l; }; #define TNULL ((TREE *) 0) #define ctree(foo) ((TREE *) foo) #define cleaf(foo) ((LEAF *) foo) #define cnode(foo) ((NODE *) foo) /***************** Globals for lexer *****************/ #define STRINGMAX 100 /* maximum words in a specimen */ #define WORDMAX 40 /* maximum chars in a word */ #define LWMAX 7 /* maximum chars in a little word (lextable entry) */ #define LEXTABMAX 300 /* maximum entries in lex table */ typedef struct lexent { /* Little-Word-to-lexeme-code translation table */ char *lexword; /* LW in question */ short lexval; /* value from YC.TAB */ }Lexent; #define PPMARKMAX 32 /*we need a lot;these are only recycled*/ /* between scans */ #define ppprevword ppmark[0] /* where we were last time */ /* RAM Jul 87 In the Mac at least, ENDLIST has to be a long. This shouldn't interfere with its use in MS/DOS? */ // Prototypes void AInit (void); /* Initialize the space */ void alert(short n,short m); void arydel (char *ary, short len,short eltsize, short dello, short delhi); void attach(TREE *ash,TREE *elm,TREE *yew, short ikid); void detach(TREE *elm, short ikid); void DnCase (char *s); void DspString (TREE **slist, Boolean reasonable); /* display trees */ void flagname(TREE *trm); void Init(void); void InsGuu2(void); void InsM3M2(void); void InsM7(void); void InsM8M4(void); void InsM10M1M6M5M9M11(void); void InsZe2(void); void ISkipMsc(void); void ISkipSpc(void); void JoinLIU(void); void JoinSOI(void); void Lex(void); void LAddLex (char *wd, short lex); /* add a word to string */ void LexAddWd (char *wd); void LexBreakCPD (char *wd, Boolean *brkmap); void LexDelWd(short iword); void LexLao(void); void LexLie(void); void LexOfCPD (char *parts[],short lexeme[],short length); void LexSue(void); void LexWrite (void); void message(short n,short m, unsigned char *txt); void nfputc (char c); void nfputs (unsigned char *str, short style); void ngets (char *str,short len); void Parse(void); void Pause(void); void PPDelete(void); void PPGoto (short mark); void PPJoin (char *grameme,short left,short right); void PPJoinNext (char *grameme); void PPStart(void); void PreParse(void); void TreeDsp (TREE *oak,Boolean nounary); void Tree_Dsp (TREE *oak,short depth,Boolean nounary); /* internal to above */ void TreeInit(void); void TreeList (TREE *oak); void Tree_List (TREE *oak,short depth,short n); void TreeString (TREE *oak,short n); void upcase (char *str); void WriteRslt(short n); /* write/display resulting parse */ void WriteString (TREE **slist,short n); /* write parse trees as strings */ void yyerror (char *msg); #ifndef MAC void TextSize(int); #endif Boolean ArgSign(void); Boolean CpdP (char *sc); Boolean hasvoc(TREE *spruce); Boolean IGetField (char *dest); Boolean IGetTkn (char *dest,char *ictemp); Boolean IGetToken (char *dest); Boolean IMatch (char *s); /* does input match string ? */ Boolean IsBreak (char c); Boolean IsCons (char c); Boolean IsUnary (TREE *oak); Boolean IsVowel (char c); Boolean PPMarkOk (short mark); Boolean match (char *s1,char *s2); Boolean MatchList (char *wd, char *patlist,...); Boolean vocfind(TREE *trmnode); Boolean yyparse(void); Boolean PredSign(void); short ARoom(void); Boolean CpdP (char *sc); short Fixlex(short lex); short freefix(short start,short tlex); short IsLeaf (TREE *oak); short IsNode (TREE *birch); short LexLookup (char *wd); short LexWord (char *wd); short PPFindList (int list,...); short PPLexeme (short idx); short PPNext(void); short PPPrev(void); short PPWhere(void); short PPSkipList (int list,...); short yylex(void); char *AAlloc (unsigned short size); char *JoinLex(char *parts[],short end,short start); LEAF *Leaf (char *wd,short lex, char source); LEAF *LeafI (short lex,char *wd); NODE *NewNode (TREE *kid1,TREE *kid2); NODE *Node (char *grameme,short length, TREE **kids); NODE *NodeA (char *grameme,short length,LEAF *kidlist); /* make an n-child node from arguments */ NODE *NodeCopy (TREE *n); NODE *NodeY (char *grameme, short length, TREE **yypv); NODE *NodeY1 (char *grameme, TREE **yypv); NODE *NodeY2 (char *grameme, TREE **yypv); NODE *NodeY3 (char *grameme, TREE **yypv); TREE *DelGUs (TREE *oak); /* delete "invisible" punctuators */ TREE *FixVoc(TREE *elm); TREE *TreeFlatten (TREE *oak); // Globals for MacLIP #ifdef global #define extern #endif extern short addend; extern short badparse; /* Flag for error parse */ extern short curVol; /* current volume For MAC version*/ extern short error(); extern short fileref[4]; /*Ref #s for input,output,table,save,inst files*/ extern short icont; /* Counter for nested parses*/ extern short mode; /* To set values for parsing mode */ extern short ptype; /* Parse type desired*/ extern short textf; /* all-at-once text parsing flag*/ extern short itextf; /* interactive text parsing flag*/ /**************** Globals for allocator ****************/ extern char *Aend; extern char *Acap; extern char *Aspace; /**************** Globals for top level ****************/ extern Boolean consp; /* console (interactive) mode */ extern Boolean wallp; /* output text */ extern char oline[BIGLIN]; /* output line */ extern char iline[BIGLIN]; /* input line */ extern char *ic; /* current char */ extern char *oc; /*current output char*/ extern char label[10]; /* label of this entry */ extern void *yyval; extern void *yylval; extern void *yyold; extern LEAF *leaves[STRINGMAX]; /* list of leaves formed from specimen */ extern short lexemes[STRINGMAX]; /* list of lexemes in specimen */ extern char *lexnames[MAXLEX]; /* list of names of lexemes */ extern short curword; /* next word to be returned by yylex() */ extern short nwords; /* number of words in specimen */ extern Lexent lextable[LEXTABMAX]; extern short lextabsiz; /* number of entries used */ /**************** Globals for preparser interface ****************/ extern short ppiword; /* current word */ extern short ppmark[PPMARKMAX]; /* mark pool */ extern short ppnmarks; /* RAM Jul 87. Again the I/O is redefined to make it standard C */ extern FILE *ibuf; /* input file buffer */ extern FILE *obuf; /* output file buffer */ extern FILE *sbuf; /* text out buffer*/ extern FILE *tbuf; /* temporary buffer*/ extern FILE *rbuf; /* instruction buffer*/ extern TREE *fullprs[CONTMAX]; /* complete, original parse trees */ extern TREE *actualprs[CONTMAX];/* "actual parse" (flattened) */ extern TREE *humactprs[CONTMAX];/* humanized actual parses */ extern short nconts; /* number of nestings */ extern short yystate; /*yyparse variables made for*/ extern short yydebug; /*error messages*/