github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/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 "../5l/5.out.h"
    33  
    34  #ifndef	EXTERN
    35  #define	EXTERN	extern
    36  #endif
    37  
    38  #undef	getc
    39  #undef	ungetc
    40  #undef	BUFSIZ
    41  
    42  #define	getc	ccgetc
    43  #define	ungetc	ccungetc
    44  
    45  typedef	struct	Sym	Sym;
    46  typedef	struct	Gen	Gen;
    47  typedef	struct	Io	Io;
    48  typedef	struct	Hist	Hist;
    49  
    50  #define	MAXALIGN	7
    51  #define	FPCHIP		1
    52  #define	NSYMB		8192
    53  #define	BUFSIZ		8192
    54  #define	HISTSZ		20
    55  #ifndef	EOF
    56  #define	EOF		(-1)
    57  #endif
    58  #define	IGN		(-2)
    59  #define	GETC()		((--fi.c < 0)? filbuf(): *fi.p++ & 0xff)
    60  #define	NHASH		503
    61  #define	STRINGSZ	200
    62  #define	NMACRO		10
    63  
    64  struct	Sym
    65  {
    66  	Sym*	link;
    67  	char*	macro;
    68  	int32	value;
    69  	ushort	type;
    70  	char	*name;
    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  EXTERN	struct
    92  {
    93  	Sym*	sym;
    94  	short	type;
    95  } h[NSYM];
    96  
    97  struct	Gen
    98  {
    99  	Sym*	sym;
   100  	int32	offset;
   101  	short	type;
   102  	short	reg;
   103  	short	name;
   104  	double	dval;
   105  	char	sval[8];
   106  };
   107  
   108  struct	Hist
   109  {
   110  	Hist*	link;
   111  	char*	name;
   112  	int32	line;
   113  	int32	offset;
   114  };
   115  #define	H	((Hist*)0)
   116  
   117  enum
   118  {
   119  	CLAST,
   120  	CMACARG,
   121  	CMACRO,
   122  	CPREPROC,
   123  
   124  	Always	= 14,
   125  };
   126  
   127  EXTERN	char	debug[256];
   128  EXTERN	Sym*	hash[NHASH];
   129  EXTERN	char**	Dlist;
   130  EXTERN	int	nDlist;
   131  EXTERN	Hist*	ehist;
   132  EXTERN	int	newflag;
   133  EXTERN	Hist*	hist;
   134  EXTERN	char*	hunk;
   135  EXTERN	char**	include;
   136  EXTERN	Io*	iofree;
   137  EXTERN	Io*	ionext;
   138  EXTERN	Io*	iostack;
   139  EXTERN	int32	lineno;
   140  EXTERN	int	nerrors;
   141  EXTERN	int32	nhunk;
   142  EXTERN	int	ninclude;
   143  EXTERN	int32	nsymb;
   144  EXTERN	Gen	nullgen;
   145  EXTERN	char*	outfile;
   146  EXTERN	int	pass;
   147  EXTERN	char*	pathname;
   148  EXTERN	int32	pc;
   149  EXTERN	int	peekc;
   150  EXTERN	int32	stmtline;
   151  EXTERN	int	sym;
   152  EXTERN	char*	symb;
   153  EXTERN	int	thechar;
   154  EXTERN	char*	thestring;
   155  EXTERN	int32	thunk;
   156  EXTERN	Biobuf	obuf;
   157  
   158  void*	alloc(int32);
   159  void*	allocn(void*, int32, int32);
   160  void	ensuresymb(int32);
   161  void	errorexit(void);
   162  void	pushio(void);
   163  void	newio(void);
   164  void	newfile(char*, int);
   165  Sym*	slookup(char*);
   166  Sym*	lookup(void);
   167  void	syminit(Sym*);
   168  int32	yylex(void);
   169  int	getc(void);
   170  int	getnsc(void);
   171  void	unget(int);
   172  int	escchar(int);
   173  void	cinit(void);
   174  void	pinit(char*);
   175  void	cclean(void);
   176  int	isreg(Gen*);
   177  void	outcode(int, int, Gen*, int, Gen*);
   178  void	zname(char*, int, int);
   179  void	zaddr(Gen*, int);
   180  void	ieeedtod(Ieee*, double);
   181  int	filbuf(void);
   182  Sym*	getsym(void);
   183  void	domacro(void);
   184  void	macund(void);
   185  void	macdef(void);
   186  void	macexpand(Sym*, char*);
   187  void	macinc(void);
   188  void	maclin(void);
   189  void	macprag(void);
   190  void	macif(int);
   191  void	macend(void);
   192  void	outhist(void);
   193  void	dodefine(char*);
   194  void	prfile(int32);
   195  void	linehist(char*, int);
   196  void	gethunk(void);
   197  void	yyerror(char*, ...);
   198  int	yyparse(void);
   199  void	setinclude(char*);
   200  int	assemble(char*);