This file is indexed.

/usr/include/dparser/gram.h is in mcrl2 201210.1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
  Copyright 2002-2004 John Plevyak, All Rights Reserved
*/

#ifndef _gram_H_
#define _gram_H_

#define EOF_SENTINAL		"\377"
#define NO_PROD			0xFFFFFFFF

struct Production;
struct Rule;
struct Elem;
struct Term;
struct State;
struct ScanState;
struct ScanStateTransition;
struct D_ParserTables;

typedef struct Elem Item;

typedef struct Code {
  char 	*code;
  int	line;
} Code;

typedef struct Goto {
  struct Elem	*elem;
  struct State	*state;
} Goto;
typedef Vec(Goto *) VecGoto;

typedef enum ActionKind { 
  ACTION_ACCEPT, ACTION_SHIFT, ACTION_REDUCE, ACTION_SHIFT_TRAILING
} ActionKind;
typedef struct Action {
  ActionKind		kind;
  struct Term		*term;
  struct Rule 		*rule;
  struct State 		*state;
  uint			index;
  char			*temp_string;
} Action;
typedef Vec(Action *) VecAction;

typedef struct Hint {
  uint		depth;
  struct State	*state;
  struct Rule	*rule;
} Hint;
typedef Vec(Hint *) VecHint;

typedef Vec(struct ScanStateTransition*) VecScanStateTransition;
typedef Vec(struct ScanState *) VecScanState;

typedef struct Scanner {
  VecScanState			states;
  VecScanStateTransition	transitions;
} Scanner;

typedef struct State {
  uint		index;
  uint64	hash;
  Vec(Item*)	items;
  Vec(Item*)	items_hash;
  VecGoto	gotos;
  VecAction	shift_actions;
  VecAction	reduce_actions;
  VecHint	right_epsilon_hints;
  VecHint	error_recovery_hints;
  Scanner	scanner;
  uint		accept:1;
  uint		scanner_code:1;
  uint		goto_on_token:1;
  uint		scan_kind:3;
  uint		trailing_context:1;
  uint8		*goto_valid;
  int		goto_table_offset;
  struct State	*same_shifts;
  struct State  *reduces_to;
  struct Rule   *reduces_with;
  struct Rule   *reduces_to_then_with;
} State;

#define ASSOC_LEFT   	0x0001
#define ASSOC_RIGHT   	0x0002
#define ASSOC_NARY   	0x0004
#define ASSOC_UNARY  	0x0008
#define ASSOC_BINARY 	0x0010

typedef enum AssocKind {
  ASSOC_NONE		= 0,
  ASSOC_NARY_LEFT 	= (ASSOC_NARY|ASSOC_LEFT),
  ASSOC_NARY_RIGHT 	= (ASSOC_NARY|ASSOC_RIGHT),
  ASSOC_UNARY_LEFT 	= (ASSOC_UNARY|ASSOC_LEFT),
  ASSOC_UNARY_RIGHT 	= (ASSOC_UNARY|ASSOC_RIGHT),
  ASSOC_BINARY_LEFT	= (ASSOC_BINARY|ASSOC_LEFT), 
  ASSOC_BINARY_RIGHT	= (ASSOC_BINARY|ASSOC_RIGHT),
  ASSOC_NO		= 0x0020
} AssocKind;
#define IS_RIGHT_ASSOC(_x)	((_x) & ASSOC_RIGHT)
#define IS_LEFT_ASSOC(_x)	((_x) & ASSOC_LEFT)
#define IS_NARY_ASSOC(_x)	((_x) & ASSOC_NARY)
#define IS_BINARY_ASSOC(_x)	((_x) & ASSOC_BINARY)
#define IS_UNARY_ASSOC(_x)	((_x) & ASSOC_UNARY)
#define IS_UNARY_BINARY_ASSOC(_x) (IS_BINARY_ASSOC(_x) || IS_UNARY_ASSOC(_x))
#define IS_BINARY_NARY_ASSOC(_x) (IS_BINARY_ASSOC(_x) || IS_NARY_ASSOC(_x))
/* not valid for NARY */
#define IS_EXPECT_RIGHT_ASSOC(_x) ((_x) && (_x) != ASSOC_UNARY_LEFT)
#define IS_EXPECT_LEFT_ASSOC(_x) ((_x) && _x != ASSOC_UNARY_RIGHT)
typedef struct Rule {
  uint			index;
  struct Production	*prod;
  int			op_priority;
  AssocKind		op_assoc;
  int			rule_priority;
  AssocKind		rule_assoc;
  Vec(struct Elem*)	elems;
  struct Elem		*end;
  Code			speculative_code;
  Code			final_code;
  Vec(Code*)		pass_code;
  int			action_index;
  struct Rule		*same_reduction;
} Rule;

typedef enum TermKind {
  TERM_STRING, TERM_REGEX, TERM_CODE, TERM_TOKEN
} TermKind;
typedef struct Term {
  TermKind		kind;
  uint			index;
  int			term_priority;
  char			*term_name;
  AssocKind		op_assoc;
  int			op_priority;
  char			*string;
  int			string_len;
  uint			scan_kind:3;
  uint			ignore_case:1;
  uint			trailing_context:1;
  struct Production	*regex_production;
} Term;

typedef Vec(Term *) TermVec;

typedef enum DeclarationKind {
  DECLARE_TOKENIZE, DECLARE_LONGEST_MATCH, DECLARE_ALL_MATCHES, 
  DECLARE_SET_OP_PRIORITY, DECLARE_STATES_FOR_ALL_NTERMS, 
  DECLARE_STATE_FOR, DECLARE_WHITESPACE, DECLARE_SAVE_PARSE_TREE, DECLARE_NUM
} DeclarationKind;
typedef struct Declaration {
  struct Elem *	elem;
  uint		kind;
  uint		index;
} Declaration;

typedef enum InternalKind {
  INTERNAL_NOT, INTERNAL_HIDDEN, INTERNAL_CONDITIONAL, INTERNAL_STAR, INTERNAL_PLUS
} InternalKind;

typedef struct Production {
  char			*name;
  uint			name_len;
  Vec(Rule *)		rules;
  uint			index;
  uint			regex:1;
  uint			in_regex:1;
  uint			internal:3;	/* production used for EBNF */
  uint			live:1;
  Rule			*nullable;	/* shortest rule for epsilon reduction */
  struct Production 	*declaration_group[DECLARE_NUM];
  struct Declaration 	*last_declaration[DECLARE_NUM];
  State			*state;	/* state for independent parsing of this productions*/
  struct Elem		*elem;	/* base elem for the item set of the above state */
  struct Term		*regex_term;	/* regex production terminal */
  char			*regex_term_name;
  struct Production	*next;
} Production;

typedef enum ElemKind {
  ELEM_NTERM, ELEM_TERM, ELEM_UNRESOLVED, ELEM_END
} ElemKind;
typedef struct Elem {
  ElemKind	kind;
  uint		index;
  Rule		*rule;
  union {
    Production	*nterm;
    Term	*term;
    void	*term_or_nterm;
    struct Unresolved {
      char	*string;
      uint	len;
    } unresolved;
  } e;
} Elem;

typedef struct Grammar {
  char			*pathname;
  Vec(Production *)	productions;
  Vec(Term *)		terminals;
  Vec(State *)		states;
  Vec(Action *)		actions;
  Code			scanner;
  Code			*code;
  int			ncode;
  Vec(Declaration *)	declarations;
  Vec(D_Pass *)		passes;
  Vec(char *)		all_pathnames;
  char			*default_white_space;
  /* grammar construction options */
  int			set_op_priority_from_rule;
  int			right_recursive_BNF;
  int			states_for_whitespace;
  int			states_for_all_nterms;
  int			tokenizer;
  int			longest_match;
  int			save_parse_tree;
  /* grammar writing options */
  char			grammar_ident[256];
  int			scanner_blocks;
  int			scanner_block_size;
  int			write_line_directives;
  int			write_header;
  int			token_type;
  int			write_cpp;
  char			write_extension[256];
  /* temporary variables for grammar construction */
  struct Production *	p;
  struct Rule *		r;
  struct Elem *		e;
  int			action_index;
  int			action_count;
  int			pass_index;
  int			rule_index;
  int			write_line;
  char			*write_pathname;
} Grammar;

/* automatically add %op_XXX to rightmost token of %XXX rule, default off */

Grammar *new_D_Grammar(char *pathname);
void free_D_Grammar(Grammar *g);
int build_grammar(Grammar *g);
int parse_grammar(Grammar *g, char *pathname, char *str);
void print_grammar(Grammar *g);
void print_rdebug_grammar(Grammar *g, char *pathname);
void print_states(Grammar *g);
void print_rule(Rule *r);
void print_term(Term *t);
Production *lookup_production(Grammar *g, char *name, int len);

/* for creating grammars */
#define last_elem(_r) ((_r)->elems.v[(_r)->elems.n-1])

Rule *new_rule(Grammar *g, Production *p);
Elem *new_elem_nterm(Production *p, Rule *r);
void new_declaration(Grammar *g, Elem *e, uint kind);
Production *new_production(Grammar *g, char *name);
Elem *new_string(Grammar *g, char *s, char *e, Rule *r);
Elem *new_utf8_char(Grammar *g, char *s, char *e, Rule *r);
Elem *new_ident(char *s, char *e, Rule *r);
void new_token(Grammar *g, char *s, char *e);
Elem *new_code(Grammar *g, char *s, char *e, Rule *r);
void add_global_code(Grammar *g, char *start, char *end, int line);
Production *new_internal_production(Grammar *g, Production *p);
Elem * dup_elem(Elem *e, Rule *r);
void add_declaration(Grammar *g, char *start, char *end, uint kind, uint line);
void add_pass(Grammar *g, char *start, char *end, uint kind, uint line);
void add_pass_code(Grammar *g, Rule *r, char *pass_start, char *pass_end,
		   char *code_start, char *code_end, uint line, uint pass_line);
D_Pass *find_pass(Grammar *g, char *start, char *end);
void conditional_EBNF(Grammar *g); /* applied to g->e,g->r,g->p */
void star_EBNF(Grammar *g); /* ditto */
void plus_EBNF(Grammar *g); /* ditto */
void rep_EBNF(Grammar *g, int minimum, int maximum);
void initialize_productions(Grammar *g);
void finalize_productions(Grammar *g);
int state_for_declaration(Grammar *g, int iproduction);

#endif