This file is indexed.

/usr/lib/falcon/parser/genparser/rules.fal is in libfalcon-engine1 0.9.6.9-git20120606-2.

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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/*
   FALCON - Generic Parser

   FILE: Rules.fal

   Generic customizable grammar parser.
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: Tue, 17 Aug 2010 15:49:48 +0200

   -------------------------------------------------------------------
   (C) Copyright 2010: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/

import Regex from regex 

/*# Base rule.

   An abstract class.
*/
class Rule( nextState, action )
   nextState = nextState
   action = action
   matchLen = 0
   lookAhead = false
   
   function match( text, pos )
      return -1
   end

   function apply( context )
      if self.action: self.action(context)
      return self.matchLen
   end
end

/*#
   @brief Class representing a token rule.

   Token rules are simply fixed length rules
   matching the input text.

   @param token the string matching a fixed token
   @param action the action (function) that should be done when
          hitting the token. The function will be called with
          the token as last parameter.
*/
class TokenRule( token, nextState, action ) from Rule( nextState, action )
   token = token
   separators = " \r\n\t,.!?;:*+-/|^'\"\\#<>()[]"
   
   function match( text, pos )
      t = self.token
      if (pfind = text.find( t, pos ) ) >= 0
         if (pfind == 0 or self.isSep( text[(pfind-1)] )) and \
                  (pfind + t.len() == text.len() or self.isSep( text[(pfind + t.len())] ))
            return pfind
         end
      end
      
      return -1
   end

   function apply( ctx )
      if self.action: self.action( ctx, self.token )
      self.matchLen = self.lookAhead ? 0 : self.token.len()
      return self.matchLen
   end

   function isSep( item )
      return item in self.separators
   end

end


/*#
   Class representing a language token, with look ahead.
*/
class TokenRuleLA( token, nextState, action ) from TokenRule( token, nextState, action )
   lookAhead = true   
end

/*#
   @brief Class representing a tag rule.

   Token rules are simply fixed length rules
   matching the input text.

   @param token the string matching a fixed token
   @param action the action (function) that should be done when
          hitting the token. The function will be called with
          the token as last parameter.
*/
class TagRule( tag, nextState, action ) from Rule( nextState, action )
   token = tag

   function match( text, pos )
      t = self.token
      if (pfind = text.find( t, pos ) ) >= 0
         return pfind
      end

      return -1
   end

   function apply( ctx )
      if self.action: self.action( ctx, self.token )
      self.matchLen = self.token.len()
      return self.matchLen
   end

end


/*#
   @brief Eats blanks
*/
class BlanksRule() from Rule( "#stay" )
   matchLen = 0

   function match( text, pos )
      ipos = pos
      l = text.len()
      while pos < l
         c = text[*pos]
         if (c != 0x20 and c != 0x8 and c != 0x0D and c != 0x0A)
            self.matchLen = pos - ipos
            if self.matchLen > 0: return ipos
         end
         ++pos
      end
      
      return -1
   end

end

/*#
   @brief Regular expression enabled ruler matcher.
   @param token the string matching a fixed token
   @param action the action (function) that should be done when
          hitting the token.

   The function will be called with the token as last parameter.
*/
class ReRule( re, nextState, action ) from Rule( nextState, action )
   anchored = re.startsWith("^")
   token = re
   re = regex.Regex(re)
   grabs = nil
   eol = false
   
   function match( text, pos )
      // can't match "^" past the begin of the line
      if self.anchored and pos > 0: return -1
      re = self.re
      // We need our grabs
      if (rng = re.find( text, pos ))
         g = []
         n = 0
         recapcount = re.capturedCount()
         while n < recapcount
            g += text[re.captured(n)]
            ++n
         end
         self.grabs = g
         return rng[0]
      end

      return -1
   end

   function apply( context )
      g = self.grabs
      if self.action: (.[ self.action context ] + g)()
      self.matchLen = g[0].len()
      // allows eating EOL
      if self.eol: return self.matchLen + 1
      return self.matchLen
   end
end

/*#
   @brief Regular expression enabled ruler matcher -- consuming end of line.
   @param token the string matching a fixed token
   @param action the action (function) that should be done when
          hitting the token.

   The function will be called with the token as last parameter.
*/
class ReRuleEOL( re, nextState, action ) from ReRule( re, nextState, action )
   eol = true
end

/*#
   @brief Regular expression matcher with look ahead
   @param token the string matching a fixed token
   @param action the action (function) that should be done when
          hitting the token.

   The function will be called with the token as last parameter.

   This rule won't indicate how many characters have been matched,
   causing an application of the rule and a state change but not
   discarding the matched characters.
*/
class ReRuleLA( re, nextState, action ) from ReRule( re, nextState, action )
   lookAhead = true
   
   function apply( context )
      g = self.grabs
      if self.action: (.[ self.action context ] + g)()
      return 0
   end
end


/*#
   @brief Empty line rule matcher.

*/
class EmptyLineRule( nextState, action ) from Rule( nextState, action )
   matchLen = 0
   
   function match( text, pos )
      if text.len() == 0: return 0
      return -1
   end
end

/*#
   @brief Matches a single character.

*/
class CharRule( nextState, action ) from Rule( nextState, action )
   grabbedChar = " "
   matchLen = 1

   function match( text, pos )
      if text.len() > pos
         self.grabbedChar = text[pos]
         return pos
      end
      return -1
   end

   function apply( ctx )
      if self.action: self.action( ctx, self.grabbedChar )
      return 1
   end
end

/*# Empty rule meant to immediately do an action and change state without consuming input. */
class DummyRule( nextState, action ) from Rule( nextState, action )
   function match( text, pos )
      return pos
   end
end

/*# Rule matching the end of line */
class EOLRule( nextState, action ) from Rule( nextState, action )
   function match( text, pos )
      return text.len()
   end
end

/*# Rule matching the end of line, with look ahead.
   This prevents exiting from the loop checking this line when EOLRuleLA is matched
*/
class EOLRuleLA( nextState, action ) from EOLRule( nextState, action )
   lookAhead = true
end

/*#
   Rule combining one or more sub-rules.
   @param rules An array of rules that may be matched.
   @param nextState The state where to go if a sub-rule is matched.
   @param actionPre An action to run as action(context, winningRule) @b before winning rule action is performed.
   @param actionPost An action to run as action(context, winningRule) @b after winning rule action is performed.

   If @b nextState is nil, then the winning rule state transition is applied, otherwise
   @b nextstate overrides winning rule state setting.

   If @b nextState contains a "*" character, it is replaced with the state from the rule. So, you can have
   "#pop;*" to first pop the current state and then apply the state transition from the winner rule.
*/
class ProxyRule( rules, nextState, actionPre, actionPost) from Rule( nextState, actionPre )
   rules = rules
   actionPost = actionPost
   winningRule = nil
   hasState = nextState ? true : false
   incState = "*" in nextState
   origState = nextState

   
   function match( text, pos )
      self.winningRule = nil
      n = 0
      l = self.rules.len()
      res = -1
      matchPos = text.len()
      while n < l
         res = self.rules[n].match( text, pos )
         if res == 0
            // we have the winner
            self.winningRule = self.rules[n]
            return res
         elif res > -1 and res < matchPos
            matchPos = res
            self.winningRule = self.rules
         end
         ++n
      end

      return res
   end


   function apply( ctx )
      if self.winningRule
         if self.action: self.action( ctx, self.winningRule )
         retval = self.winningRule.apply(ctx)
         if self.actionPost: self.actionPost( ctx, self.winningRule )

         if self.hasState
            if self.incState
               self.nextState = self.origState.replace( "*", self.winningRule.nextState )
            end
            // else, let the state it has.
         else
            self.nextState = self.winningRule.nextState
         end
         
         self.matchLen = retval
         return retval
      end

      self.matchLen = 0
      return 0
   end
end