This file is indexed.

/usr/share/gap/lib/compiler.g is in gap-libs 4r6p5-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
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
#############################################################################
##
#W  compiler.g                   GAP library                     Frank Celler
##
##
#Y  Copyright (C)  1997,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file contains the frontend function for the compiler.
##


#############################################################################
##
#F  RatPairString( <string> ) . . . . . . . . . . . . . string -> 2 rationals
##
RatPairString := function( string )
    local   p,  x,  y;

    # find ","
    p := Position( string, ',' );
    if p = false  then
        x := Rat(string);
        y := x;
    elif p = 1  then
        x := 1;
        y := Rat(string{[2..Length(string)]});
    elif p = Length(string)  then
        x := Rat(string{[1..p-1]});
        y := 1;
    else
        x := Rat(string{[1..p-1]});
        y := Rat(string{[p+1..Length(string)]});
    fi;
    if x = 0  then x := 1;  fi;
    if y = 0  then y := 1;  fi;
    return [ x, y ];

end;


#############################################################################
##
#F  ParseArguments( <def>, <args>, <pos> )  . . . . parse sequence of options
##
##  <args>  is a  argument  list and <pos> the   position to start at.  <def>
##  describes the arguments, it is a record, whose record names correspond to
##  paramters, the values describe the possible paramters:
##
##  "switch"		toggle the switch or set to the optional paramter
##  "switch/true"       default is `true'
##  "switch/false"      default is `false'
##
##  "string"            set to the mandatory paramter
##  "string/default"    default value
##
##  "integer"           set to the mandatory paramter
##  "integer/default"   default value
##
##  "geometry"          set to the two mandatory paramter width/height
##  "geometry/wxh"	default value
##
##  "alias/name"        define an alias
##  
##  Example:
##
##  gap> a;
##  rec(
##    name := "string/test",
##    nice := "switch/false",
##    depth := "integer/10",
##    ndepth := "integer" )
##  gap> ParseArguments( a, [], 1 );
##  rec(
##    name := "test",
##    nice := false,
##    depth := 10 )
##  gap> ParseArguments( a, ["ndepth",20], 1 );
##  rec(
##    name := "test",
##    nice := false,
##    depth := 10,
##    ndepth := 20 )
##
ParseArguments := function( def, args, pos )
    local   IsMatch,  SplitString,  keys,  type,  val,  key,  tmp,  
            defaultGeometry,  next,  match;
    
    # match a substring
    IsMatch := function( a, b )
        local   c;
        a := LowercaseString(a);
        b := LowercaseString(b);
        c := [ 1 .. Minimum( Length(a), Length(b) ) ];
        return a{c} = b{c};
    end;

    # substring after <sep>
    SplitString := function( str, sep )
        local   p;
        p := Position( str, sep );
        if p = fail  then
            return [ str, "" ];
        else
            return [ str{[1..p-1]}, str{[p+1..Length(str)]} ];
        fi;
    end;

    # parse the default description
    keys := RecNames(def);
    type := rec();
    val  := rec();
    for key  in keys  do

        # a switch
        if IsMatch( "switch", def.(key) )  then
            type.(key) := "switch";
            val.(key)  := not IsMatch("false",SplitString(def.(key),'/')[2]);

        # a string
        elif IsMatch( "string", def.(key) )  then
            type.(key) := "string";
            val.(key)  := SplitString( def.(key), '/' )[2];

        # a geometry
        elif IsMatch( "geometry", def.(key) )  then
            type.(key) := "geometry";
            tmp := SplitString( SplitString( def.(key), '/' )[2], 'x' );
            val.(key) := List( tmp, Int );
            if not IsBound(defaultGeometry)  then
                defaultGeometry := key;
            fi;

        # an integer
        elif IsMatch( "integer", def.(key) )  then
            type.(key) := "integer";
            tmp := SplitString( def.(key), '/' )[2];
            if 0 < Length(tmp)  then tmp := Int(tmp);  else tmp := fail;  fi;
            if tmp <> fail  then val.(key) := tmp;  fi;

        # an alias
        elif IsMatch( "alias", def.(key) )  then
            type.(key) := "alias";
            val.(key)  := SplitString( def.(key), '/' )[2];

        # unknown type
        else
            Error( "type '", def.(key), "' is unknown" );
        fi;

    od;

    # parse the arguments starting at position <pos>
    while pos <= Length(args)  do
        next := args[pos];

        # an integer could be a geometry parameter
        if IsInt(next) and pos < Length(args) and IsInt(args[pos+1])  then
            if IsBound(defaultGeometry)  then
                if next <= 0  then
                    Error( "width must be non-negative, not ", next );
                fi;
                if args[pos+1] <= 0  then
                    Error("height must be non-negative, not ", args[pos+1]);
                fi;
                val.(defaultGeometry) := [ next, args[pos+1] ];
                pos := pos+2;
            else
                Error( "'geometry' may not be specified" );
            fi;

        # just one integer
        elif IsInt(next)  then
            tmp := Concatenation( "unknown parameter '", String(next),
                                  "', known parameters are: " );
            for key  in [ 1 .. Length(keys) ]  do
                if 1 < key  then Append( tmp, ", " );  fi;
                Append( tmp, keys[key] );
            od;
            Error( tmp );

        # check the other keys
        else
            match := false;
            for key  in keys  do
                if not match and IsMatch( key, next )  then
                    match := true;

                    # check for an alias
                    if type.(key) = "alias"  then
                        key := val.(key);
                    fi;

                    # a switch takes an optional boolean argument
                    if type.(key) = "switch"  then
                        if pos < Length(args) and IsBool(args[pos+1])  then
                            val.(key) := args[pos+1];
                            pos := pos+2;
                        else
                            val.(key) := not val.(key);
                            pos := pos+1;
                        fi;

                    # a string
                    elif type.(key) = "string"  then
                        if pos=Length(args) or not IsString(args[pos+1]) then
                            Error( key, " requires a string argument" );
                        fi;
                        val.(key) := args[pos+1];
                        pos := pos+2;

                    # an integer
                    elif type.(key) = "integer"  then
                        if pos=Length(args) or not IsInt(args[pos+1]) then
                            Error( key, " requires an integer argument" );
                        fi;
                        val.(key) := args[pos+1];
                        pos := pos+2;

                    # a geometry
                    elif type.(key) = "geometry"  then
                        if pos+1 = Length(args)  then
                            Error( key, " requires a width and height" );
                        fi;
                        if not IsInt(args[pos+1]) or args[pos+1] <= 0  then
                            Error( "width must be non-negative, not ",
                                   args[pos+1] );
                        fi;
                        if not IsInt(args[pos+2]) or args[pos+2] <= 0  then
                            Error( "height must be non-negative, not ",
                                   args[pos+2] );
                        fi;
                        val.(key) := [ args[pos+1], args[pos+2] ];
                        pos := pos+3;
                    fi;
                fi;
            od;

            # we didn't found a match
            if not match  then
                tmp := Concatenation( "unknown parameter '", next,
                                      "', known parameters are: " );
                for key  in [ 1 .. Length(keys) ]  do
                    if 1 < key  then Append( tmp, ", " );  fi;
                    Append( tmp, keys[key] );
                od;
                Error( tmp );
            fi;
        fi;
    od;
        
    # that's it, remove alias entries
    for key  in keys  do
        if type.(key) = "alias"  then
            Unbind(val.(key));
        fi;
    od;
    return val;

end;


#############################################################################
##
#F  CompileFunc( <output>, <function>, <module_name>, ... )
##
##  <output> must be a filename,
##  <function> the function to compile,
##  <module_name> the name used in the compiled module
##
##  optional parameters are:
##  "Magic1"
##  "Magic2"
##  "FastIntArith"
##  "FastPlainLists"
##  "CheckTypes"
##  "CheckListElements"
##  "CheckPosObjElements"
##
CompileFunc := function( arg )
    local   output,  func,  name,  arguments;

    output := arg[1];
    func   := arg[2];
    name   := arg[3];

    arguments := rec(
        magic1              := "integer/0",
        magic2              := "string",
        fastintarith        := "switch/true",
        fastplainlists      := "switch/true",
        checktypes          := "switch/true",
        checklistelements   := "switch/true",
        checkposobjelements := "switch/true" );

    arguments := ParseArguments( arguments, arg, 4 );

    return COMPILE_FUNC(
        output, func, name,
        arguments.magic1, arguments.magic2, arguments.fastintarith,
        arguments.fastplainlists, arguments.checktypes,
        arguments.checklistelements, arguments.checkposobjelements );

end;


#############################################################################
##

#E  compiler.g  . . . . . . . . . . . . . . . . . . . . . . . . . . ends here