|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.net.ftp.shell.CommandLexer
class CommandLexer
FTP command script lexical analyzer.
See the package summary for details about syntax and lexicon.
Copyright ©2007 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by
by the United States Department of State as a terrorist, or terrorist
government or agency, to use and distribute this source code provided
that the original copyright notice remains present and unaltered.
CommandParser
Field Summary | |
---|---|
(package private) int |
m_lineNo
Source line number of the last token read. |
(package private) static java.lang.String |
REV
Revision information. |
Constructor Summary | |
---|---|
CommandLexer(java.io.Reader in,
java.io.PrintWriter out)
Constructor. |
Method Summary | |
---|---|
(package private) java.lang.String |
readToken()
Read the next input token from the source script. |
(package private) void |
setSourceName(java.lang.String name)
Establish the name of this source stream (the command script). |
(package private) void |
splitWordTokens(boolean flag)
Establish whether or not token words in the current source input line are to be split or not. |
(package private) void |
unReadToken(java.lang.String tok)
Push back the last token read from the input source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
int m_lineNo
Constructor Detail |
---|
CommandLexer(java.io.Reader in, java.io.PrintWriter out)
in
- Command script input stream.out
- Error/warning message output stream.Method Detail |
---|
void setSourceName(java.lang.String name)
name
- Name of the input stream. This is usually a filename, but it can be any
kind of identification for the source stream.void splitWordTokens(boolean flag)
Note: This is something of a kludge, adding dirt to an otherwise fairly clean lexer implementation.
flag
- True if subsequent token words are to be split into individual tokens,
false otherwise.java.lang.String readToken() throws java.io.IOException
m_lineNo
to reflect the source line number of
the returned token.
Tokens are composed of simple keywords (e.g., get), or quoted literals (e.g., "*.txt", 'get.*'). Tokens may contain embedded variable sequences (e.g., "${name}"). Tokens may be delimited by whitespace (spaces, tabs, and newlines), or are expressions enclosed within parentheses ('(').
Tokens cannot be longer than 2,000 characters.
Blank lines are ignored. Comments start with # and end at the end of the line (newline), and are ignored.
Source lines can be split and continued on subsequent lines by preceding the newline with a '`' (accent) escape character. Leading spaces on the next line are ignored.
Examples
*.txt -> *.txt /bin/foo.ext -> /bin/foo.ext $file.$ext -> $file.$ext ($file.$ext) -> ( $file . $ext ) a#bc #xyz -> a#bc nl 'abc'.'def' -> "abc" .'def' ('abc'.'def') -> "abc" . "def" x+y/z*2 -> 'x+y/z*2' (x+y/z*2) -> ( x + y / z * 2 ) (a/b)+c/d -> ( a / b ) +c/d &($s+1) -> & ( $s + 1 ) "&($s+1)" -> "&($s+1)" drt@foo.com -> drt@foo.com (drt@foo.com) -> ( drt @foo . com ) -123+45 +$foo -> - 123 + 45 + $foo don`'t -> don`'t 'foo`$bar`$' -> 'foo`$bar`$' c: cd c: -> c : cd c:
CommandTokens.TOK__NL
if an end-of-line (newline) was
read, or null if the end of the source stream was reached.
java.io.IOException
void unReadToken(java.lang.String tok)
readToken()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |