github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/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 sym; 71 }; 72 #define S ((Sym*)0) 73 74 EXTERN struct 75 { 76 char* p; 77 int c; 78 } fi; 79 80 struct Io 81 { 82 Io* link; 83 char b[BUFSIZ]; 84 char* p; 85 short c; 86 short f; 87 }; 88 #define I ((Io*)0) 89 90 enum 91 { 92 CLAST, 93 CMACARG, 94 CMACRO, 95 CPREPROC, 96 97 Always = 14, 98 }; 99 100 EXTERN int debug[256]; 101 EXTERN Sym* hash[NHASH]; 102 EXTERN char** Dlist; 103 EXTERN int nDlist; 104 EXTERN int newflag; 105 EXTERN char* hunk; 106 EXTERN char** include; 107 EXTERN Io* iofree; 108 EXTERN Io* ionext; 109 EXTERN Io* iostack; 110 EXTERN int32 lineno; 111 EXTERN int nerrors; 112 EXTERN int32 nhunk; 113 EXTERN int ninclude; 114 EXTERN int32 nsymb; 115 EXTERN Addr nullgen; 116 EXTERN char* outfile; 117 EXTERN int pass; 118 EXTERN int32 pc; 119 EXTERN int peekc; 120 EXTERN int32 stmtline; 121 EXTERN int sym; 122 EXTERN char* symb; 123 EXTERN int thechar; 124 EXTERN char* thestring; 125 EXTERN int32 thunk; 126 EXTERN Biobuf obuf; 127 EXTERN Link* ctxt; 128 EXTERN Biobuf bstdout; 129 130 void* alloc(int32); 131 void* allocn(void*, int32, int32); 132 void ensuresymb(int32); 133 void errorexit(void); 134 void pushio(void); 135 void newio(void); 136 void newfile(char*, int); 137 Sym* slookup(char*); 138 Sym* lookup(void); 139 void syminit(Sym*); 140 int32 yylex(void); 141 int getc(void); 142 int getnsc(void); 143 void unget(int); 144 int escchar(int); 145 void cinit(void); 146 void pinit(char*); 147 void cclean(void); 148 int isreg(Addr*); 149 void outcode(int, int, Addr*, int, Addr*); 150 int filbuf(void); 151 Sym* getsym(void); 152 void domacro(void); 153 void macund(void); 154 void macdef(void); 155 void macexpand(Sym*, char*); 156 void macinc(void); 157 void maclin(void); 158 void macprag(void); 159 void macif(int); 160 void macend(void); 161 void dodefine(char*); 162 void prfile(int32); 163 void linehist(char*, int); 164 void gethunk(void); 165 void yyerror(char*, ...); 166 int yyparse(void); 167 void setinclude(char*); 168 int assemble(char*); 169 void listinit(void);