📄 options.java
字号:
package util;
public class Options {
private static final String[] paramText = {
"-tscan", // trace Scanner
"-tparse", // trace Parser
"-tsymbol", // display Symboltabel
"-genxml", // create xml
"-nocodegen", // no Code generation
"-testscan", // test the Scanners
};
private static boolean
pscan = false, // no trace Scanner
pparse = false, // no trace Parser
psymbol = false, // no Symboltabel display
pgenxml = false, // no xml to create
pnocodegen = false, // Code generation
ptestscan = false; // no: test the Scanners
public static boolean getpscan () {
return pscan;
}
public static boolean getpparse () {
return pparse;
}
public static boolean getpsymbol () {
return psymbol;
}
public static boolean getpgenxml () {
return pgenxml;
}
public static boolean getpnocodegen () {
return pnocodegen;
}
public static boolean getptestscan () {
return ptestscan;
}
private static String[] errorText ={
"invoke: java JSub Options file name",
"-tscan // trace Scanner",
"-tparse // trace Parser",
"-tsymbol // Symbol tabel display",
"-genxml // create xml",
"-nocodegen // no Code generation",
"-testscan, // test the Scanners",
};
private static void errorMessageAndExit () {
for (int i = 0; i< errorText.length; i++)
System.err.println (errorText[i]);
System.exit (1);
}
private static String fileName = null;
public static String getFileName() {
return fileName;
}
public static void parseArgs (String args[])
{
if (args == null)
errorMessageAndExit ();
for (int i = 0; i < args.length; i++)
{
boolean found = false;
if (args[i].startsWith ("-"))
{
for (int j = 0; j < paramText.length; j++)
{
if (paramText[j].equals (args[i]))
{
switch (j) {
case 0: pscan = true; break; // trace Scanner
case 1: pparse = true; break; // trace Parser
case 2: psymbol = true; break; // display Symbol table
case 3: pgenxml = true; break; // create xml
case 4: pnocodegen = true; break; // Code generation
case 5: ptestscan = true; break; // run Scanner tests
}
found = true;
break;
}
}
if (!found)
errorMessageAndExit ();
} else
if (fileName == null)
fileName = args[i];
else
errorMessageAndExit ();
}
if (fileName == null)
errorMessageAndExit ();
}
public static String nToS (int num, int number) {
StringBuffer b = new StringBuffer ();
b.append (num);
while (b.length() < number)
b.insert (0, ' ');
return b.toString ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -