|
From: <cr...@us...> - 2009-01-11 06:29:00
|
Revision: 4847
http://jnode.svn.sourceforge.net/jnode/?rev=4847&view=rev
Author: crawley
Date: 2009-01-11 06:28:56 +0000 (Sun, 11 Jan 2009)
Log Message:
-----------
Rename the 'token' field of the CommandToken type to 'text'.
Fix a couple of Bjorne bugs that prevented backtick redirection from working.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java
trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java
trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java
trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java
trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
trunk/shell/src/shell/org/jnode/shell/CommandLine.java
trunk/shell/src/shell/org/jnode/shell/CommandShell.java
trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java
trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java
trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java
trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java
trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java
trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java
trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java
trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java
Modified: trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -98,15 +98,15 @@
@Override
protected String doAccept(Token value) throws CommandSyntaxException {
- int index = value.token.indexOf(':');
+ int index = value.text.indexOf(':');
if (index == -1) {
throw new CommandSyntaxException("missing ':'");
} else if (index == 0) {
throw new CommandSyntaxException("no hostname before ':'");
- } else if (index == value.token.length() - 1) {
+ } else if (index == value.text.length() - 1) {
throw new CommandSyntaxException("no directory after ':'");
} else {
- return value.token;
+ return value.text;
}
}
}
Modified: trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -40,7 +40,7 @@
@Override
protected IBMPartitionTypes doAccept(Token value) throws CommandSyntaxException {
try {
- int code = Integer.parseInt(value.token, 16);
+ int code = Integer.parseInt(value.text, 16);
return IBMPartitionTypes.valueOf(code);
} catch (NumberFormatException ex) {
throw new CommandSyntaxException("not a valid hexadecimal number");
Modified: trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java
===================================================================
--- trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -26,10 +26,10 @@
@Override
protected IPv4Address doAccept(Token value) throws CommandSyntaxException {
- if (value.token.equals("default")) {
+ if (value.text.equals("default")) {
return new IPv4Address(new byte[]{0, 0, 0, 0}, 0);
}
- final StringTokenizer tok = new StringTokenizer(value.token, ".");
+ final StringTokenizer tok = new StringTokenizer(value.text, ".");
if (tok.countTokens() != 4) {
throw new CommandSyntaxException("wrong number of components for an IPv4 address");
}
Modified: trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java
===================================================================
--- trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -25,7 +25,7 @@
@Override
protected IPv4Address doAccept(Token value) throws CommandSyntaxException {
try {
- return new IPv4Address(value.token);
+ return new IPv4Address(value.text);
} catch (IllegalArgumentException ex) {
throw new CommandSyntaxException("invalid hostname or IPv4 address");
}
Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -47,7 +47,7 @@
}
public void complete(CompletionInfo completion, CommandShell shell) {
- argument.complete(completion, token == null ? "" : token.token);
+ argument.complete(completion, token == null ? "" : token.text);
if (token != null) {
completion.setCompletionStart(token.start);
}
Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -200,21 +200,21 @@
if (!hasNext()) {
throw new NoSuchElementException();
}
- return argumentTokens[pos++].token;
+ return argumentTokens[pos++].text;
}
public String peek() throws NoSuchElementException {
if (!hasNext()) {
throw new NoSuchElementException();
}
- return argumentTokens[pos].token;
+ return argumentTokens[pos].text;
}
public String last() throws NoSuchElementException {
if (pos <= 0) {
throw new NoSuchElementException();
}
- return argumentTokens[pos - 1].token;
+ return argumentTokens[pos - 1].text;
}
public void remove() {
@@ -307,7 +307,7 @@
* @return the command name
*/
public String getCommandName() {
- return commandToken == null ? null : commandToken.token;
+ return commandToken == null ? null : commandToken.text;
}
/**
@@ -331,7 +331,7 @@
}
String[] arguments = new String[len];
for (int i = 0; i < len; i++) {
- arguments[i] = argumentTokens[i].token;
+ arguments[i] = argumentTokens[i].text;
}
return arguments;
}
@@ -352,10 +352,10 @@
* @return the entire command line
*/
public String toString() {
- StringBuilder sb = new StringBuilder(escape(commandToken.token));
+ StringBuilder sb = new StringBuilder(escape(commandToken.text));
for (Token arg : argumentTokens) {
sb.append(' ');
- sb.append(escape(arg.token));
+ sb.append(escape(arg.text));
}
return sb.toString();
}
@@ -388,7 +388,7 @@
* should have been processed so that the value of the field represents
* a command name or argument.
*/
- public final String token;
+ public final String text;
/**
* This field represents the type of the token. The meaning is
@@ -414,7 +414,7 @@
public final int end;
public Token(String value, int type, int start, int end) {
- this.token = value;
+ this.text = value;
this.tokenType = type;
this.start = start;
this.end = end;
@@ -430,7 +430,7 @@
int result = 1;
result = prime * result + end;
result = prime * result + start;
- result = prime * result + ((token == null) ? 0 : token.hashCode());
+ result = prime * result + ((text == null) ? 0 : text.hashCode());
result = prime * result + tokenType;
return result;
}
@@ -448,10 +448,10 @@
return false;
if (start != other.start)
return false;
- if (token == null) {
- if (other.token != null)
+ if (text == null) {
+ if (other.text != null)
return false;
- } else if (!token.equals(other.token))
+ } else if (!text.equals(other.text))
return false;
if (tokenType != other.tokenType)
return false;
@@ -459,7 +459,7 @@
}
public String toString() {
- return "Token{'" + token + "'," + start + "," + end + "," + tokenType + "}";
+ return "Token{'" + text + "'," + start + "," + end + "," + tokenType + "}";
}
}
@@ -570,7 +570,7 @@
* line arguments.
*/
public CommandInfo parseCommandLine(CommandShell shell) throws ShellException {
- String cmd = (commandToken == null) ? "" : commandToken.token.trim();
+ String cmd = (commandToken == null) ? "" : commandToken.text.trim();
if (cmd.equals("")) {
throw new ShellFailureException("no command name");
}
@@ -601,7 +601,7 @@
}
public void complete(CompletionInfo completion, CommandShell shell) throws CompletionException {
- String cmd = (commandToken == null) ? "" : commandToken.token.trim();
+ String cmd = (commandToken == null) ? "" : commandToken.text.trim();
if (!cmd.equals("") && (argumentTokens.length > 0 || argumentAnticipated)) {
CommandInfo cmdClass;
try {
@@ -649,7 +649,7 @@
}
public CommandInfo getCommandInfo(CommandShell shell) {
- String cmd = (commandToken == null) ? "" : commandToken.token.trim();
+ String cmd = (commandToken == null) ? "" : commandToken.text.trim();
if (cmd.equals("")) {
return null;
}
Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -487,7 +487,7 @@
}
if (context.token != null) {
errPW.println(" " + context.exception.getMessage() + ": " +
- context.token.token);
+ context.token.text);
} else {
errPW.println(" " + context.exception.getMessage() + ": " +
context.syntax.format());
Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -147,7 +147,7 @@
CommandLine.Token commandToken = tokenizer.next();
if (commandToken.tokenType == SPECIAL) {
throw new ShellSyntaxException("Misplaced '" +
- commandToken.token + "': expected a command name");
+ commandToken.text + "': expected a command name");
}
CommandLine.Token from = null;
@@ -157,7 +157,7 @@
while (tokenizer.hasNext()) {
CommandLine.Token token = tokenizer.next();
if (token.tokenType == SPECIAL) {
- if (token.token.equals("<")) {
+ if (token.text.equals("<")) {
from = parseFileName(tokenizer, "<");
if (from == null && !completing) {
throw new ShellSyntaxException("no filename after '<'");
@@ -167,7 +167,7 @@
new FileArgument("?", Argument.MANDATORY, null), from);
}
continue;
- } else if (token.token.equals(">")) {
+ } else if (token.text.equals(">")) {
to = parseFileName(tokenizer, ">");
if (to == null && !completing) {
throw new ShellSyntaxException("no filename after '>'");
@@ -177,7 +177,7 @@
new FileArgument("?", Argument.MANDATORY, null), to);
}
continue;
- } else if (token.token.equals("|")) {
+ } else if (token.text.equals("|")) {
pipeTo = true;
break;
} else {
@@ -219,7 +219,7 @@
if (token.tokenType == SPECIAL) {
throw new ShellSyntaxException("misplaced '" + token + "'");
}
- if (token.token.isEmpty()) {
+ if (token.text.isEmpty()) {
throw new ShellSyntaxException("empty '" + special + "' file name");
}
return token;
@@ -233,19 +233,19 @@
try {
try {
if (desc.fromFileName != null) {
- in = new CommandInput(new FileInputStream(desc.fromFileName.token));
+ in = new CommandInput(new FileInputStream(desc.fromFileName.text));
}
} catch (IOException ex) {
throw new ShellInvocationException("cannot open '" +
- desc.fromFileName.token + "': " + ex.getMessage());
+ desc.fromFileName.text + "': " + ex.getMessage());
}
try {
if (desc.toFileName != null) {
- out = new CommandOutput(new FileOutputStream(desc.toFileName.token));
+ out = new CommandOutput(new FileOutputStream(desc.toFileName.text));
}
} catch (IOException ex) {
throw new ShellInvocationException("cannot open '" +
- desc.toFileName.token + "': " + ex.getMessage());
+ desc.toFileName.text + "': " + ex.getMessage());
}
desc.commandLine.setStreams(new CommandIO[] {in, out, err, CommandLine.DEFAULT_STDERR});
try {
@@ -289,17 +289,17 @@
try {
// redirect from
if (desc.fromFileName != null) {
- in = new CommandInput(new FileInputStream(desc.fromFileName.token));
+ in = new CommandInput(new FileInputStream(desc.fromFileName.text));
desc.openedStreams.add(in);
}
} catch (IOException ex) {
throw new ShellInvocationException("cannot open '" +
- desc.fromFileName.token + "': " + ex.getMessage());
+ desc.fromFileName.text + "': " + ex.getMessage());
}
try {
// redirect to
if (desc.toFileName != null) {
- out = new CommandOutput(new FileOutputStream(desc.toFileName.token));
+ out = new CommandOutput(new FileOutputStream(desc.toFileName.text));
desc.openedStreams.add(out);
}
} catch (IOException ex) {
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -43,6 +43,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.log4j.Logger;
import org.jnode.shell.CommandLine;
import org.jnode.shell.CommandThread;
import org.jnode.shell.PathnamePattern;
@@ -241,7 +242,10 @@
if (expanded == word) {
splitAndAppend(token, wordTokens);
} else {
- splitAndAppend(token.remake(expanded), wordTokens);
+ BjorneToken newToken = token.remake(expanded);
+ if (newToken != null) {
+ splitAndAppend(newToken, wordTokens);
+ }
}
}
return makeCommandLine(wordTokens);
@@ -397,9 +401,9 @@
private String runBacktickCommand(String commandLine) throws ShellException {
ByteArrayOutputStream capture = new ByteArrayOutputStream();
- interpreter.interpret(interpreter.getShell(), commandLine, capture,
- false);
+ interpreter.interpret(interpreter.getShell(), commandLine, capture, false);
String output = capture.toString();
+ // Trim trailing newlines
int i;
for (i = output.length(); i > 0 && output.charAt(i - 1) == '\n'; i--) { /**/
}
@@ -415,19 +419,13 @@
}
/**
- * Perform '$' expansions. Any quotes and escapes should be preserved.
+ * Perform '$' expansion and backtick substitution. Any quotes and escapes should be preserved (?!?!?)
*
* @param text the characters to be expanded
* @return the result of the expansion.
* @throws ShellException
*/
public CharSequence expand(CharSequence text) throws ShellException {
- if (text instanceof String && ((String) text).indexOf('$') == -1) {
- return text;
- }
- if (text instanceof StringBuffer && ((StringBuffer) text).indexOf("$") == -1) {
- return text;
- }
CharIterator ci = new CharIterator(text);
StringBuffer sb = new StringBuffer(text.length());
char quote = 0;
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneToken.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -21,7 +21,6 @@
package org.jnode.shell.bjorne;
import org.jnode.shell.CommandLine;
-import org.jnode.shell.ShellException;
public class BjorneToken extends CommandLine.Token {
@@ -131,7 +130,11 @@
}
public BjorneToken remake(CharSequence newText) {
- return new BjorneToken(this.tokenType, newText.toString(), this.start, this.end);
+ if (newText.length() == 0) {
+ return null;
+ } else {
+ return new BjorneToken(this.tokenType, newText.toString(), this.start, this.end);
+ }
}
private void validate() {
@@ -140,28 +143,20 @@
case TOK_IO_NUMBER:
case TOK_NAME:
case TOK_ASSIGNMENT:
- if (token.length() == 0) {
+ if (text == null || text.length() == 0) {
throw new IllegalArgumentException("null or empty text");
}
break;
default:
- if (token.length() > 0) {
+ if (text != null && text.length() > 0) {
throw new IllegalArgumentException("non-empty text");
}
}
}
- public String getInterpolatedText(BjorneContext context) throws ShellException {
- switch (tokenType) {
- case TOK_WORD:
- default:
- return toString();
- }
- }
-
public String getText() {
- return token;
+ return text;
}
public int getTokenType() {
@@ -169,7 +164,7 @@
}
public boolean isName() {
- return token != null && isName(token);
+ return text != null && isName(text);
}
public static boolean isName(String str) {
@@ -255,13 +250,13 @@
public String toString() {
switch (tokenType) {
case TOK_WORD:
- return "WORD{" + token + "}";
+ return "WORD{" + text + "}";
case TOK_NAME:
- return "NAME{" + token + "}";
+ return "NAME{" + text + "}";
case TOK_ASSIGNMENT:
- return "ASSIGNMENT{" + token + "}";
+ return "ASSIGNMENT{" + text + "}";
case TOK_IO_NUMBER:
- return "IO_NUMBER{" + token + "}";
+ return "IO_NUMBER{" + text + "}";
case TOK_SEMI:
case TOK_AMP:
case TOK_BAR:
Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/bjorne/CaseCommandNode.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -58,10 +58,10 @@
public int execute(BjorneContext context) throws ShellException {
int rc = -1;
- CharSequence expandedWord = context.expand(word.token);
+ CharSequence expandedWord = context.expand(word.text);
for (CaseItemNode caseItem : caseItems) {
for (BjorneToken pattern : caseItem.getPattern()) {
- CharSequence pat = context.expand(pattern.token);
+ CharSequence pat = context.expand(pattern.text);
if (context.patternMatch(expandedWord, pat)) {
throw new ShellException("not implemented yet");
}
Modified: trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -126,7 +126,7 @@
@Override
protected VirtualKey doAccept(Token value) throws CommandSyntaxException {
- String str = value.token;
+ String str = value.text;
String[] parts = str.split("\\+");
int modifiers = 0;
for (int i = 0; i < parts.length - 1; i++) {
@@ -157,7 +157,7 @@
@Override
protected Character doAccept(Token value) throws CommandSyntaxException {
- String str = value.token;
+ String str = value.text;
String upper = str.toUpperCase();
for (int i = 0; i < ASCII_NAMES.length; i++) {
if (ASCII_NAMES[i].equals(upper)) {
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -51,10 +51,10 @@
@Override
public String doAccept(Token value) throws CommandSyntaxException {
- if (value.token.length() == 0) {
+ if (value.text.length() == 0) {
throw new CommandSyntaxException("empty alias name");
}
- return value.token;
+ return value.text;
}
public void complete(CompletionInfo completion, String partial) {
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -41,7 +41,7 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- return token.token;
+ return token.text;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -43,8 +43,8 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- if (validCountries.contains(token.token)) {
- return token.token;
+ if (validCountries.contains(token.text)) {
+ return token.text;
} else {
throw new CommandSyntaxException("invalid country code");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -58,7 +58,7 @@
protected Device doAccept(Token token) throws CommandSyntaxException {
try {
final DeviceManager devMgr = getDeviceManager();
- final Device device = devMgr.getDevice(token.token);
+ final Device device = devMgr.getDevice(token.text);
if (apiClass == null || device.implementsAPI(apiClass)) {
return device;
} else {
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -63,7 +63,7 @@
@Override
protected E doAccept(Token token) throws CommandSyntaxException {
try {
- return E.valueOf(clazz, token.token);
+ return E.valueOf(clazz, token.text);
} catch (IllegalArgumentException ex) {
throw new CommandSyntaxException("not a valid <" + argumentKind() + ">");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -47,8 +47,8 @@
@Override
protected File doAccept(Token token) throws CommandSyntaxException {
- if (token.token.length() > 0) {
- File file = new File(token.token);
+ if (token.text.length() > 0) {
+ File file = new File(token.text);
if (isExisting() && !file.exists()) {
throw new CommandSyntaxException("this file or directory does not exist");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -50,7 +50,7 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- return token.token;
+ return token.text;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -58,11 +58,11 @@
@Override
protected Integer doAccept(Token token) throws CommandSyntaxException {
try {
- int tmp = Integer.parseInt(token.token);
+ int tmp = Integer.parseInt(token.text);
if (tmp < min || tmp > max) {
throw new CommandSyntaxException("number is out of range");
}
- return new Integer(token.token);
+ return new Integer(token.text);
} catch (NumberFormatException ex) {
throw new CommandSyntaxException("invalid number");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -47,7 +47,7 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- return token.token;
+ return token.text;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -43,8 +43,8 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- if (validLanguages.contains(token.token)) {
- return token.token;
+ if (validLanguages.contains(token.text)) {
+ return token.text;
} else {
throw new CommandSyntaxException("invalid language code");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -29,7 +29,7 @@
*/
@Override
protected Logger doAccept(Token value) throws CommandSyntaxException {
- return Logger.getLogger(value.token);
+ return Logger.getLogger(value.text);
}
/**
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -59,11 +59,11 @@
@Override
protected Long doAccept(Token token) throws CommandSyntaxException {
try {
- long tmp = Long.parseLong(token.token);
+ long tmp = Long.parseLong(token.text);
if (tmp < min || tmp > max) {
throw new CommandSyntaxException("number is out of range");
}
- return new Long(token.token);
+ return new Long(token.text);
} catch (NumberFormatException ex) {
throw new CommandSyntaxException("invalid number");
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -78,7 +78,7 @@
*/
@Override
protected V doAccept(Token token) throws CommandSyntaxException {
- String t = caseInsensitive ? token.token.toLowerCase() : token.token;
+ String t = caseInsensitive ? token.text.toLowerCase() : token.text;
V value = valueMap.get(t);
if (value == null) {
throw new CommandSyntaxException("not an acceptable <" + argumentKind() + ">");
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -157,7 +157,7 @@
if (DEBUG) {
log.debug("Trying kind = " + syntax.getKind() + ", syntax = " + syntax.format());
if (source.hasNext()) {
- log.debug("source -> " + source.peek().token);
+ log.debug("source -> " + source.peek().text);
} else {
log.debug("source at end");
}
@@ -169,17 +169,17 @@
token = source.hasNext() ? source.next() : null;
if (completion == null || source.hasNext()) {
- backtrack = token == null || !token.token.equals(symbol);
+ backtrack = token == null || !token.text.equals(symbol);
} else {
if (token == null) {
completion.addCompletion(symbol);
backtrack = true;
} else if (source.whitespaceAfterLast()) {
- if (!token.token.equals(symbol)) {
+ if (!token.text.equals(symbol)) {
backtrack = true;
}
} else {
- if (symbol.startsWith(token.token)) {
+ if (symbol.startsWith(token.text)) {
completion.addCompletion(symbol);
completion.setCompletionStart(token.start);
}
@@ -202,7 +202,7 @@
}
}
} else {
- arg.complete(completion, token.token);
+ arg.complete(completion, token.text);
completion.setCompletionStart(token.start);
backtrack = true;
}
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -54,7 +54,7 @@
@Override
protected Boolean doAccept(Token token) throws CommandSyntaxException {
- String value = token.token;
+ String value = token.text;
int len = value.length();
if (len < 2 || value.charAt(0) != '-') {
throw new CommandSyntaxException("not a flag set");
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -26,7 +26,7 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- return token.token;
+ return token.text;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -47,7 +47,7 @@
@Override
protected Long doAccept(Token token) throws CommandSyntaxException {
- String str = token.token;
+ String str = token.text;
ScaleFactor factor = scaleFactor(str);
if (factor != null) {
str = str.substring(0, str.length() - factor.getUnit().length());
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -44,7 +44,7 @@
@Override
protected String doAccept(Token token) throws CommandSyntaxException {
- return token.token;
+ return token.text;
}
@Override
Modified: trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -55,7 +55,7 @@
@Override
protected URL doAccept(Token value) throws CommandSyntaxException {
try {
- return new URL(value.token);
+ return new URL(value.text);
} catch (MalformedURLException ex) {
throw new CommandSyntaxException(ex.getMessage());
}
Modified: trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/test/org/jnode/test/shell/syntax/CommandLineTest.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -53,16 +53,16 @@
SymbolSource<Token> ts = c1.tokenIterator();
assertEquals(true, ts.hasNext());
- assertEquals("1", ts.next().token);
+ assertEquals("1", ts.next().text);
assertEquals(true, ts.hasNext());
- assertEquals("2", ts.next().token);
+ assertEquals("2", ts.next().text);
assertEquals(true, ts.hasNext());
- assertEquals("3", ts.next().token);
+ assertEquals("3", ts.next().text);
assertEquals(false, ts.hasNext());
CommandLine c2 = new CommandLine("foo", args);
assertEquals("foo", c2.getCommandName());
- assertEquals("foo", c2.getCommandToken().token);
+ assertEquals("foo", c2.getCommandToken().text);
}
@SuppressWarnings("deprecation")
Modified: trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java 2009-01-10 13:42:03 UTC (rev 4846)
+++ trunk/shell/src/test/org/jnode/test/shell/syntax/DefaultTokenizerTest.java 2009-01-11 06:28:56 UTC (rev 4847)
@@ -60,15 +60,15 @@
assertEquals(true, t.hasNext());
assertEquals(false, t.whitespaceAfterLast());
CommandLine.Token s = t.next();
- assertEquals("a", s.token);
+ assertEquals("a", s.text);
assertEquals(0, s.start);
assertEquals(1, s.end);
s = t.next();
- assertEquals("b", s.token);
+ assertEquals("b", s.text);
assertEquals(2, s.start);
assertEquals(3, s.end);
s = t.next();
- assertEquals("c", s.token);
+ assertEquals("c", s.text);
assertEquals(4, s.start);
assertEquals(5, s.end);
assertEquals(false, t.hasNext());
@@ -82,7 +82,7 @@
t.seek(0);
assertEquals(true, t.hasNext());
s = t.next();
- assertEquals("a", s.token);
+ assertEquals("a", s.text);
assertEquals(0, s.start);
assertEquals(1, s.end);
assertEquals(1, t.tell());
@@ -105,11 +105,11 @@
assertEquals(true, t.hasNext());
assertEquals(false, t.whitespaceAfterLast());
CommandLine.Token s = t.next();
- assertEquals("a", s.token);
+ assertEquals("a", s.text);
assertEquals(0, s.start);
assertEquals(3, s.end);
s = t.next();
- assertEquals("b c", s.token);
+ assertEquals("b c", s.text);
assertEquals(4, s.start);
assertEquals(9, s.end);
assertEquals(false, t.hasNext());
@@ -120,11 +120,11 @@
assertEquals(true, t.hasNext());
assertEquals(false, t.whitespaceAfterLast());
CommandLine.Token s = t.next();
- assertEquals("'a", s.token);
+ assertEquals("'a", s.text);
assertEquals(0, s.start);
assertEquals(3, s.end);
s = t.next();
- assertEquals("b c\"", s.token);
+ assertEquals("b c\"", s.text);
assertEquals(5, s.start);
assertEquals(11, s.end);
assertEquals(false, t.hasNext());
@@ -135,7 +135,7 @@
assertEquals(true, t.hasNext());
assertEquals(true, t.whitespaceAfterLast());
CommandLine.Token s = t.next();
- assertEquals("\\\n\r\t\b", s.token);
+ assertEquals("\\\n\r\t\b", s.text);
assertEquals(0, s.start);
assertEquals(10, s.end);
assertEquals(false, t.hasNext());
@@ -147,21 +147,21 @@
MyDefaultInterpreter.REDIRECTS_FLAG);
assertEquals(true, t.hasNext());
assertEquals(false, t.whitespaceAfterLast());
- assertEquals("a", t.next().token);
- assertEquals("<", t.next().token);
+ assertEquals("a", t.next().text);
+ assertEquals("<", t.next().text);
assertEquals(MyDefaultInterpreter.SPECIAL, t.last().tokenType);
- assertEquals(">", t.next().token);
+ assertEquals(">", t.next().text);
assertEquals(MyDefaultInterpreter.SPECIAL, t.last().tokenType);
- assertEquals("b", t.next().token);
- assertEquals("c", t.next().token);
- assertEquals("|", t.next().token);
+ assertEquals("b", t.next().text);
+ assertEquals("c", t.next().text);
+ assertEquals("|", t.next().text);
assertEquals(MyDefaultInterpreter.SPECIAL, t.last().tokenType);
- assertEquals("d", t.next().token);
- assertEquals("<", t.next().token);
+ assertEquals("d", t.next().text);
+ assertEquals("<", t.next().text);
assertEquals(MyDefaultInterpreter.STRING | MyDefaultInterpreter.CLOSED, t.last().tokenType);
- assertEquals("<", t.next().token);
+ assertEquals("<", t.next().text);
assertEquals(MyDefaultInterpreter.LITERAL, t.last().tokenType);
- assertEquals("<", t.next().token);
+ assertEquals("<", t.next().text);
assertEquals(MyDefaultInterpreter.STRING | MyDefaultInterpreter.CLOSED, t.last().tokenType);
assertEquals(false, t.hasNext());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|