This file is indexed.

/usr/include/gecode/flatzinc/parser.hh is in libgecode-dev 3.7.1-3.

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
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2007
 *
 *  Last modified:
 *     $Date: 2010-07-28 16:43:32 +0200 (Wed, 28 Jul 2010) $ by $Author: tack $
 *     $Revision: 11293 $
 *
 *  This file is part of Gecode, the generic constraint
 *  development environment:
 *     http://www.gecode.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining
 *  a copy of this software and associated documentation files (the
 *  "Software"), to deal in the Software without restriction, including
 *  without limitation the rights to use, copy, modify, merge, publish,
 *  distribute, sublicense, and/or sell copies of the Software, and to
 *  permit persons to whom the Software is furnished to do so, subject to
 *  the following conditions:
 *
 *  The above copyright notice and this permission notice shall be
 *  included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef __FLATZINC_PARSER_HH__
#define __FLATZINC_PARSER_HH__

#include <gecode/flatzinc.hh>

// This is a workaround for a bug in flex that only shows up
// with the Microsoft C++ compiler
#if defined(_MSC_VER)
#define YY_NO_UNISTD_H
#ifdef __cplusplus
extern "C" int isatty(int);
#endif
#endif

// The Microsoft C++ compiler marks certain functions as deprecated,
// so let's take the alternative definitions
#if defined(_MSC_VER)
#define strdup _strdup
#define fileno _fileno
#endif

#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

#include <gecode/flatzinc/option.hh>
#include <gecode/flatzinc/varspec.hh>
#include <gecode/flatzinc/conexpr.hh>
#include <gecode/flatzinc/ast.hh>
#include <gecode/flatzinc/parser.tab.hh>
#include <gecode/flatzinc/symboltable.hh>

namespace Gecode { namespace FlatZinc {

  typedef std::pair<std::string,Option<std::vector<int>* > > intvartype;

  class VarSpec;
  typedef std::pair<std::string, VarSpec*> varspec;

  /// Strict weak ordering for output items
  class OutputOrder {
  public:
    /// Return if \a x is less than \a y, based on first component
    bool operator ()(const std::pair<std::string,AST::Node*>& x,
                     const std::pair<std::string,AST::Node*>& y) {
      return x.first < y.first;
    }
  };

  /// Types of symbols
  enum SymbolType {
    ST_INTVAR,        //< Integer variable
    ST_BOOLVAR,       //< Boolean variable
    ST_FLOATVAR,      //< Float variable
    ST_SETVAR,        //< Set variable
    ST_INTVARARRAY,   //< Integer variable array
    ST_BOOLVARARRAY,  //< Boolean variable array
    ST_SETVARARRAY,   //< Set variable array
    ST_FLOATVARARRAY, //< Float variable array
    ST_INTVALARRAY,   //< Integer array
    ST_BOOLVALARRAY,  //< Boolean array
    ST_SETVALARRAY,   //< Set array
    ST_INT,           //< Integer
    ST_BOOL,          //< Boolean
    ST_SET            //< Set
  };

  /// Entries in the symbol table
  class SymbolEntry {
  public:
    SymbolType t; //< Type of entry
    int i;        //< Value of entry or array start index
    /// Default constructor
    SymbolEntry(void) {}
    /// Constructor
    SymbolEntry(SymbolType t0, int i0) : t(t0), i(i0) {}

  };

  /// Construct integer variable entry
  forceinline SymbolEntry se_iv(int i) {
    return SymbolEntry(ST_INTVAR, i);
  }
  /// Construct Boolean variable entry
  forceinline SymbolEntry se_bv(int i) {
    return SymbolEntry(ST_BOOLVAR, i);
  }
  /// Construct float variable entry
  forceinline SymbolEntry se_fv(int i) {
    return SymbolEntry(ST_FLOATVAR, i);
  }
  /// Construct set variable entry
  forceinline SymbolEntry se_sv(int i) {
    return SymbolEntry(ST_SETVAR, i);
  }

  /// Construct integer variable array entry
  forceinline SymbolEntry se_iva(int i) {
    return SymbolEntry(ST_INTVARARRAY, i);
  }
  /// Construct Boolean variable array entry
  forceinline SymbolEntry se_bva(int i) {
    return SymbolEntry(ST_BOOLVARARRAY, i);
  }
  /// Construct float variable array entry
  forceinline SymbolEntry se_fva(int i) {
    return SymbolEntry(ST_FLOATVARARRAY, i);
  }
  /// Construct set variable array entry
  forceinline SymbolEntry se_sva(int i) {
    return SymbolEntry(ST_SETVARARRAY, i);
  }

  /// Construct integer entry
  forceinline SymbolEntry se_i(int i) {
    return SymbolEntry(ST_INT, i);
  }
  /// Construct Boolean entry
  forceinline SymbolEntry se_b(bool b) {
    return SymbolEntry(ST_BOOL, b);
  }
  /// Construct set entry
  forceinline SymbolEntry se_s(int i) {
    return SymbolEntry(ST_SET, i);
  }

  /// Construct integer array entry
  forceinline SymbolEntry se_ia(int i) {
    return SymbolEntry(ST_INTVALARRAY, i);
  }
  /// Construct Boolean array entry
  forceinline SymbolEntry se_ba(int i) {
    return SymbolEntry(ST_BOOLVALARRAY, i);
  }
  /// Construct set array entry
  forceinline SymbolEntry se_sa(int i) {
    return SymbolEntry(ST_SETVALARRAY, i);
  }

  /// %State of the %FlatZinc parser
  class ParserState {
  public:
    ParserState(const std::string& b, std::ostream& err0,
                Gecode::FlatZinc::FlatZincSpace* fg0)
    : buf(b.c_str()), pos(0), length(b.size()), fg(fg0),
      hadError(false), err(err0) {}

    ParserState(char* buf0, int length0, std::ostream& err0,
                Gecode::FlatZinc::FlatZincSpace* fg0)
    : buf(buf0), pos(0), length(length0), fg(fg0),
      hadError(false), err(err0) {}
  
    void* yyscanner;
    const char* buf;
    unsigned int pos, length;
    Gecode::FlatZinc::FlatZincSpace* fg;
    std::vector<std::pair<std::string,AST::Node*> > _output;

    SymbolTable<SymbolEntry> symbols;

    // SymbolTable<int> intvarTable;
    // SymbolTable<int> boolvarTable;
    // SymbolTable<int> floatvarTable;
    // SymbolTable<int> setvarTable;
    // SymbolTable<std::vector<int> > intvararrays;
    // SymbolTable<std::vector<int> > boolvararrays;
    // SymbolTable<std::vector<int> > floatvararrays;
    // SymbolTable<std::vector<int> > setvararrays;
    // SymbolTable<std::vector<int> > intvalarrays;
    // SymbolTable<std::vector<int> > boolvalarrays;
    // SymbolTable<int> intvals;
    // SymbolTable<bool> boolvals;
    // SymbolTable<AST::SetLit> setvals;
    // SymbolTable<std::vector<AST::SetLit> > setvalarrays;

    std::vector<varspec> intvars;
    std::vector<varspec> boolvars;
    std::vector<varspec> setvars;
    std::vector<int> arrays;
    std::vector<AST::SetLit> setvals;

    std::vector<ConExpr*> domainConstraints;

    bool hadError;
    std::ostream& err;
  
    int fillBuffer(char* lexBuf, unsigned int lexBufSize) {
      if (pos >= length)
        return 0;
      int num = std::min(length - pos, lexBufSize);
      memcpy(lexBuf,buf+pos,num);
      pos += num;
      return num;    
    }

    void output(std::string x, AST::Node* n) {
      _output.push_back(std::pair<std::string,AST::Node*>(x,n));
    }
    
    AST::Array* getOutput(void) {
      OutputOrder oo;
      std::sort(_output.begin(),_output.end(),oo);
      AST::Array* a = new AST::Array();
      for (unsigned int i=0; i<_output.size(); i++) {
        a->a.push_back(new AST::String(_output[i].first+" = "));
        if (_output[i].second->isArray()) {
          AST::Array* oa = _output[i].second->getArray();
          for (unsigned int j=0; j<oa->a.size(); j++) {
            a->a.push_back(oa->a[j]);
            oa->a[j] = NULL;
          }
          delete _output[i].second;
        } else {
          a->a.push_back(_output[i].second);
        }
        a->a.push_back(new AST::String(";\n"));
      }
      return a;
    }
  
  };

}}

#endif

// STATISTICS: flatzinc-any