1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * Copyright (C) 1998-2004 Gerwin Klein <lsf@jflex.de> *
4 * All rights reserved. *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License. See the file *
8 * COPYRIGHT for more information. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License along *
16 * with this program; if not, write to the Free Software Foundation, Inc., *
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 * Collects all global JFlex options. Can be set from command line parser,
29 * @author Gerwin Klein
30 * @version JFlex 1.4.1, $Revision: 2.10 $, $Date: 2004/11/06 23:03:31 $
32 public class Options
{
34 /** If true, additional verbose debug information is produced
35 * This is a compile time option */
36 public final static boolean DEBUG
= false;
38 /** code generation method: maximum packing */
39 final public static int PACK
= 0;
40 /** code generation method: traditional */
41 final public static int TABLE
= 1;
42 /** code generation method: switch statement */
43 final public static int SWITCH
= 2;
46 /** output directory */
47 private static File directory
;
48 /** strict JLex compatibility */
49 public static boolean jlex
;
50 /** don't run minimization algorithm if this is true */
51 public static boolean no_minimize
;
52 /** don't write backup files if this is true */
53 public static boolean no_backup
;
54 /** use charAt function for accessing the zzBuffer */
55 public static boolean char_at
;
57 /** use charAt function for accessing the zzBuffer and [] for zzBufferArray */
58 public static boolean sliceAndCharAt
;
60 /** default code generation method */
61 public static int gen_method
;
62 /** If false, only error/warning output will be generated */
63 public static boolean verbose
;
64 /** If true, progress dots will be printed */
65 public static boolean progress
;
66 /** If true, jflex will print time statistics about the generation process */
67 public static boolean time
;
68 /** If true, jflex will write graphviz .dot files for generated automata */
69 public static boolean dot
;
70 /** If true, you will be flooded with information (e.g. dfa tables). */
71 public static boolean dump
;
73 static { setDefaults(); }
77 * @return the output directory
79 public static File
getDir() {
84 * Set output directory
86 * @param dirName the name of the directory to write output files to
88 public static void setDir(String dirName
) {
89 setDir(new File(dirName
));
94 * Set output directory
96 * @param d the directory to write output files to
98 public static void setDir(File d
) {
100 Out
.error("Error: \""+d
+"\" is not a directory.");
101 throw new GeneratorException();
104 if ( !d
.isDirectory() && !d
.mkdirs() ) {
105 Out
.error("Error: couldn't create directory \""+d
+"\"");
106 throw new GeneratorException();
113 * Sets all options back to default values.
115 public static void setDefaults() {
120 gen_method
= Options
.PACK
;
128 public static void setSkeleton(File skel
) {
129 Skeleton
.readSkelFile(skel
);