github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/cmd/8a/a.h (about)

     1  // Inferno utils/8a/a.h
     2  // http://code.google.com/p/inferno-os/source/browse/utils/8a/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 "../8l/8.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	Ref	Ref;
    48  typedef	struct	Io	Io;
    49  typedef	struct	Addr2	Addr2;
    50  
    51  #define	MAXALIGN	7
    52  #define	FPCHIP		1
    53  #define	NSYMB		500
    54  #define	BUFSIZ		8192
    55  #define	HISTSZ		20
    56  #ifndef	EOF
    57  #define	EOF		(-1)
    58  #endif
    59  #define	IGN		(-2)
    60  #define	GETC()		((--fi.c < 0)? filbuf(): *fi.p++ & 0xff)
    61  #define	NHASH		503
    62  #define	STRINGSZ	200
    63  #define	NMACRO		10
    64  
    65  struct	Sym
    66  {
    67  	Sym*	link;
    68  	Ref*	ref;
    69  	char*	macro;
    70  	int32	value;
    71  	ushort	type;
    72  	char	*name;
    73  	char*	labelname;
    74  	char	sym;
    75  };
    76  #define	S	((Sym*)0)
    77  
    78  struct	Ref
    79  {
    80  	int	class;
    81  };
    82  
    83  EXTERN struct
    84  {
    85  	char*	p;
    86  	int	c;
    87  } fi;
    88  
    89  struct	Io
    90  {
    91  	Io*	link;
    92  	char	b[BUFSIZ];
    93  	char*	p;
    94  	short	c;
    95  	short	f;
    96  };
    97  #define	I	((Io*)0)
    98  
    99  struct	Addr2
   100  {
   101  	Addr	from;
   102  	Addr	to;
   103  };
   104  
   105  enum
   106  {
   107  	CLAST,
   108  	CMACARG,
   109  	CMACRO,
   110  	CPREPROC,
   111  };
   112  
   113  EXTERN	int	debug[256];
   114  EXTERN	Sym*	hash[NHASH];
   115  EXTERN	char**	Dlist;
   116  EXTERN	int	nDlist;
   117  EXTERN	int	newflag;
   118  EXTERN	char*	hunk;
   119  EXTERN	char**	include;
   120  EXTERN	Io*	iofree;
   121  EXTERN	Io*	ionext;
   122  EXTERN	Io*	iostack;
   123  EXTERN	int32	lineno;
   124  EXTERN	int	nerrors;
   125  EXTERN	int32	nhunk;
   126  EXTERN	int	ninclude;
   127  EXTERN	int32	nsymb;
   128  EXTERN	Addr	nullgen;
   129  EXTERN	char*	outfile;
   130  EXTERN	int	pass;
   131  EXTERN	int32	pc;
   132  EXTERN	int	peekc;
   133  EXTERN	int32	stmtline;
   134  EXTERN	int	sym;
   135  EXTERN	char*	symb;
   136  EXTERN	int	thechar;
   137  EXTERN	char*	thestring;
   138  EXTERN	int32	thunk;
   139  EXTERN	Biobuf	obuf;
   140  EXTERN	Link*	ctxt;
   141  EXTERN	Biobuf	bstdout;
   142  
   143  void*	alloc(int32);
   144  void*	allocn(void*, int32, int32);
   145  void	ensuresymb(int32);
   146  void	errorexit(void);
   147  void	pushio(void);
   148  void	newio(void);
   149  void	newfile(char*, int);
   150  Sym*	slookup(char*);
   151  Sym*	lookup(void);
   152  Sym*	labellookup(Sym*);
   153  void	settext(LSym*);
   154  void	syminit(Sym*);
   155  int32	yylex(void);
   156  int	getc(void);
   157  int	getnsc(void);
   158  void	unget(int);
   159  int	escchar(int);
   160  void	cinit(void);
   161  void	checkscale(int);
   162  void	pinit(char*);
   163  void	cclean(void);
   164  int	isreg(Addr*);
   165  void	outcode(int, Addr2*);
   166  void	outhist(void);
   167  int	filbuf(void);
   168  Sym*	getsym(void);
   169  void	domacro(void);
   170  void	macund(void);
   171  void	macdef(void);
   172  void	macexpand(Sym*, char*);
   173  void	macinc(void);
   174  void	macprag(void);
   175  void	maclin(void);
   176  void	macif(int);
   177  void	macend(void);
   178  void	dodefine(char*);
   179  void	prfile(int32);
   180  void	linehist(char*, int);
   181  void	gethunk(void);
   182  void	yyerror(char*, ...);
   183  int	yyparse(void);
   184  void	setinclude(char*);
   185  int	assemble(char*);