github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/src/cmd/5a/a.h (about) 1 // Inferno utils/5a/a.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/5a/a.h 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 #include <bio.h> 32 #include <link.h> 33 #include "../5l/5.out.h" 34 35 #ifndef EXTERN 36 #define EXTERN extern 37 #endif 38 39 #undef getc 40 #undef ungetc 41 #undef BUFSIZ 42 43 #define getc ccgetc 44 #define ungetc ccungetc 45 46 typedef struct Sym Sym; 47 typedef struct Io Io; 48 49 #define MAXALIGN 7 50 #define FPCHIP 1 51 #define NSYMB 8192 52 #define BUFSIZ 8192 53 #define HISTSZ 20 54 #ifndef EOF 55 #define EOF (-1) 56 #endif 57 #define IGN (-2) 58 #define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff) 59 #define NHASH 503 60 #define STRINGSZ 200 61 #define NMACRO 10 62 63 struct Sym 64 { 65 Sym* link; 66 char* macro; 67 int32 value; 68 ushort type; 69 char *name; 70 char* labelname; 71 char sym; 72 }; 73 #define S ((Sym*)0) 74 75 EXTERN struct 76 { 77 char* p; 78 int c; 79 } fi; 80 81 struct Io 82 { 83 Io* link; 84 char b[BUFSIZ]; 85 char* p; 86 short c; 87 short f; 88 }; 89 #define I ((Io*)0) 90 91 enum 92 { 93 CLAST, 94 CMACARG, 95 CMACRO, 96 CPREPROC, 97 98 Always = 14, 99 }; 100 101 EXTERN int debug[256]; 102 EXTERN Sym* hash[NHASH]; 103 EXTERN char** Dlist; 104 EXTERN int nDlist; 105 EXTERN int newflag; 106 EXTERN char* hunk; 107 EXTERN char** include; 108 EXTERN Io* iofree; 109 EXTERN Io* ionext; 110 EXTERN Io* iostack; 111 EXTERN int32 lineno; 112 EXTERN int nerrors; 113 EXTERN int32 nhunk; 114 EXTERN int ninclude; 115 EXTERN int32 nsymb; 116 EXTERN Addr nullgen; 117 EXTERN char* outfile; 118 EXTERN int pass; 119 EXTERN int32 pc; 120 EXTERN int peekc; 121 EXTERN int32 stmtline; 122 EXTERN int sym; 123 EXTERN char* symb; 124 EXTERN int thechar; 125 EXTERN char* thestring; 126 EXTERN int32 thunk; 127 EXTERN Biobuf obuf; 128 EXTERN Link* ctxt; 129 EXTERN Biobuf bstdout; 130 131 void* alloc(int32); 132 void* allocn(void*, int32, int32); 133 void ensuresymb(int32); 134 void errorexit(void); 135 void pushio(void); 136 void newio(void); 137 void newfile(char*, int); 138 Sym* slookup(char*); 139 Sym* lookup(void); 140 Sym* labellookup(Sym*); 141 void settext(LSym*); 142 void syminit(Sym*); 143 int32 yylex(void); 144 int getc(void); 145 int getnsc(void); 146 void unget(int); 147 int escchar(int); 148 void cinit(void); 149 void pinit(char*); 150 void cclean(void); 151 int isreg(Addr*); 152 void outcode(int, int, Addr*, int, Addr*); 153 int filbuf(void); 154 Sym* getsym(void); 155 void domacro(void); 156 void macund(void); 157 void macdef(void); 158 void macexpand(Sym*, char*); 159 void macinc(void); 160 void maclin(void); 161 void macprag(void); 162 void macif(int); 163 void macend(void); 164 void dodefine(char*); 165 void prfile(int32); 166 void linehist(char*, int); 167 void gethunk(void); 168 void yyerror(char*, ...); 169 int yyparse(void); 170 void setinclude(char*); 171 int assemble(char*); 172 void listinit(void);