github.com/hbdrawn/golang@v0.0.0-20141214014649-6b835209aba2/src/cmd/9a/a.h (about)

     1  // cmd/9a/a.h from Vita Nuova.
     2  //
     3  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     4  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     5  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     6  //	Portions Copyright © 2000-2008 Vita Nuova Holdings Limited (www.vitanuova.com)
     7  //	Portions Copyright © 2004,2006 Bruce Ellis
     8  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
     9  //	Revisions Copyright © 2000-2008 Lucent Technologies Inc. and others
    10  //	Portions Copyright © 2009 The Go Authors.  All rights reserved.
    11  //
    12  // Permission is hereby granted, free of charge, to any person obtaining a copy
    13  // of this software and associated documentation files (the "Software"), to deal
    14  // in the Software without restriction, including without limitation the rights
    15  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    16  // copies of the Software, and to permit persons to whom the Software is
    17  // furnished to do so, subject to the following conditions:
    18  //
    19  // The above copyright notice and this permission notice shall be included in
    20  // all copies or substantial portions of the Software.
    21  //
    22  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    23  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    24  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    25  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    26  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    27  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    28  // THE SOFTWARE.
    29  
    30  #include <bio.h>
    31  #include <link.h>
    32  #include "../9l/9.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	Io	Io;
    47  
    48  #define	MAXALIGN	7
    49  #define	FPCHIP		1
    50  #define	NSYMB		8192
    51  #define	BUFSIZ		8192
    52  #define	HISTSZ		20
    53  #define	NINCLUDE	10
    54  #define	NHUNK		10000
    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  	vlong	value;
    69  	ushort	type;
    70  	char	*name;
    71  	char*	labelname;
    72  	char	sym;
    73  };
    74  #define	S	((Sym*)0)
    75  
    76  EXTERN struct
    77  {
    78  	char*	p;
    79  	int	c;
    80  } fi;
    81  
    82  struct	Io
    83  {
    84  	Io*	link;
    85  	char	b[BUFSIZ];
    86  	char*	p;
    87  	short	c;
    88  	short	f;
    89  };
    90  #define	I	((Io*)0)
    91  
    92  enum
    93  {
    94  	CLAST,
    95  	CMACARG,
    96  	CMACRO,
    97  	CPREPROC,
    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	nosched;
   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	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  Sym*	labellookup(Sym*);
   140  void	settext(LSym*);
   141  void	syminit(Sym*);
   142  int32	yylex(void);
   143  int	getc(void);
   144  int	getnsc(void);
   145  void	unget(int);
   146  int	escchar(int);
   147  void	cinit(void);
   148  void	pinit(char*);
   149  void	cclean(void);
   150  void	outcode(int, Addr*, int, Addr*);
   151  void	outgcode(int, Addr*, int, Addr*, Addr*);
   152  int	filbuf(void);
   153  Sym*	getsym(void);
   154  void	domacro(void);
   155  void	macund(void);
   156  void	macdef(void);
   157  void	macexpand(Sym*, char*);
   158  void	macinc(void);
   159  void	macprag(void);
   160  void	maclin(void);
   161  void	macif(int);
   162  void	macend(void);
   163  void	dodefine(char*);
   164  void	prfile(int32);
   165  void	linehist(char*, int);
   166  void	gethunk(void);
   167  void	yyerror(char*, ...);
   168  int	yyparse(void);
   169  void	setinclude(char*);
   170  int	assemble(char*);