3 TREELANG Compiler common definitions (treelang.h)
5 Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 In other words, you are welcome to use, share and improve this program.
23 You are forbidden to forbid anyone else to use, share and improve
24 what you give them. Help stamp out software-hoarding!
26 ---------------------------------------------------------------------------
28 Written by Tim Josling 1999, 2000, 2001, based in part on other
29 parts of the GCC compiler.
33 /* Parse structure type. */
35 { /* These values less likely to be there by chance unlike 0/1,
36 make checks more meaningful */
38 production_category
= 222
41 /* Input file name and FILE. */
42 extern unsigned char* in_fname
;
46 extern int errorcount
; /* In toplev.c. */
51 enum category_enum category
; /* Token or production. */
52 unsigned int type
; /* Token type. */
53 /* Prior to this point, production must match token. */
56 unsigned int length
; /* The value. */
62 enum category_enum category
; /* Token or Production. */
63 unsigned int type
; /* Production type - a fake token name. */
64 /* Prior to this point, production must match token. */
65 struct token
* main_token
; /* Main token for error msgs; variable name token. */
67 unsigned int info
[2]; /* Extra information. */
68 #define NESTING_LEVEL(a) a->info[0] /* Level used for variable definitions. */
69 #define NUMERIC_TYPE(a) a->info[1] /* Numeric type used in type definitions and expressions. */
73 void *sub
[SUB_COUNT
]; /* Sub productions or tokens. */
75 #define SYMBOL_TABLE_NAME(a) (a->sub[0]) /* Name token. */
77 #define EXPRESSION_TYPE(a) (a->sub[1]) /* Type identifier. */
79 #define OP1(a) (a->sub[2]) /* Exp operand1. */
80 #define PARAMETERS(a) (a->sub[2]) /* Function parameters. */
81 #define VARIABLE(a) (a->sub[2]) /* Parameter variable ptr. */
82 #define VAR_INIT(a) (a->sub[2]) /* Variable init. */
84 #define OP2(a) (a->sub[3]) /* Exp operand2. */
85 #define FIRST_PARMS(a) (a->sub[3]) /* Function parameters linked via struct tree_parameter_list. */
87 #define OP3(a) (a->sub[4]) /* Exp operand3. */
88 #define STORAGE_CLASS_TOKEN(a) (a->sub[4]) /* Storage class token. */
90 void *code
; /* Back end hook for this item. */
91 struct production
*next
; /* Next in chains of various types. */
94 #define STORAGE_CLASS(a) a->flag1 /* Values in treetree.h. */
100 unsigned int flag6
:1;
101 unsigned int flag7
:1;
105 /* For parser. Alternatively you can define it using %union (bison) or
107 #define YYSTYPE void *
109 void *my_malloc (size_t size
);
110 int insert_tree_name (struct production
*prod
);
111 struct production
*lookup_tree_name (struct production
*prod
);
112 struct production
*make_production (int type
, struct token
* main_tok
);
113 void mark_production_used (struct production
* pp
);
114 void mark_token_used (struct token
* tt
);
115 void treelang_debug (void);