1 /****************************************************************************
2     Copyright (C) 1987-2015 by Jeffery P. Hansen
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 ****************************************************************************/
18 #ifndef __parser_h
19 #define __parser_h
20 #include <stdio.h>
21 
22 #define MAXREGS	1024
23 #define MAXOPRS 64
24 
25 #define NT_VALUE	0
26 #define NT_SYMBOL	1
27 #define NT_RELSYMBOL	2
28 
29 #define AM_IMMEDIATE	0
30 #define AM_DIRECT	1
31 #define AM_INDIRECT	2
32 #define AM_INDEXED	3
33 #define AM_IMMIND	4
34 
35 #define OI_DATA		0
36 #define OI_REGOP	1
37 #define OI_NUMOP	2
38 #define OI_RELNUMOP	3
39 
40 
41 struct lex_keywordentry {
42     char *Keyword;
43     int Value;
44 };
45 
46 typedef struct range {
47   int msb;
48   int lsb;
49 } Range;
50 
51 typedef struct number {
52   short ntype;
53   short offset;
54   union {
55     char *s;
56     int d;
57   } v;
58 } Number;
59 
60 
61 typedef union {
62   int I;			/* Used for integers */
63   char *S;			/* Used for strings */
64   void *P;			/* Used for pointers */
65   Range R;			/* Used for ranges */
66   Number N;			/* Used for numbers which can be symbolic */
67 } YYVALUE;
68 
69 #define YYSTYPE YYVALUE
70 
71 extern YYVALUE yylval;
72 
73 extern char ycFileName[];
74 extern int ycLineNumber;
75 
76 void Number_print(Number *N,FILE *f);
77 Number *Number_copy(Number*);
78 
79 void ycRegRecord(char*,int);
80 void ycBank(int,Range*,char*,Range*);
81 void ycField(char*,Range*,int);
82 void ycEnum(char*,int);
83 void ycBeginOprGroup(char*);
84 void ycEndOprGroup();
85 void ycBeginOperand();
86 void ycEndOperand();
87 void ycOLHS(int,int,int);
88 void ycORHS(int,int,Range*,int,Range*,int);
89 void ycBeginOp(char*);
90 void ycEndOp();
91 void ycAddOprGroup(char*);
92 void ycMap(struct number*,struct number*);
93 void ycBeginUCode(int);
94 void ycEndUCode();
95 void ycUNext();
96 void ycULabel(char*);
97 void ycUSpec(struct number *,struct number *);
98 void ycBeginMCode(int);
99 void ycEndMCode();
100 void ycMOp(char*);
101 void ycMNext();
102 void ycMLabel(char*);
103 void ycMOperand(int,struct number*,int);
104 void ycMSymbol(char*,int);
105 void ycBss(int);
106 void ycData(int);
107 void ycDataNum(int);
108 void ycDataLit(char*);
109 void ycDataStr(char*);
110 void ycBeginProc(char*);
111 void ycEndProc();
112 
113 int yyerror(char*,...);
114 int yyparse();
115 int yylex();
116 void yyrestart(FILE*);
117 
118 int ycKeyCmp(const char *S1,const char *S2);
119 
120 void BeginBA();
121 void BeginMA();
122 
123 #endif
124