public class Lexical
extends java.lang.Object
Syntax
.Modifier and Type | Field and Description |
---|---|
static int |
andSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
charLiteral
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
close
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
colon
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
comma
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
consSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
curlclose
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
curlopen
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
dot
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
elseSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
eofSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
eq
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
falseSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
ge
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
gt
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
hdSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
ifSy
Integer codes for the various lexical symbols;
also see
Symbol . |
protected java.io.InputStream |
inp |
static int |
inSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
lambdaSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
le
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
letSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
lt
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
minus
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
ne
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
nilSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
notSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
nullSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
numeral
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
numeralR
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
open
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
orSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
over
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
plus
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
recSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
sqclose
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
sqopen
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
stringLiteral
Integer codes for the various lexical symbols;
also see
Symbol . |
static java.lang.String[] |
Symbol
String representations of the various lexical symbols.
|
static int |
thenSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
times
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
tlSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
triv
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
trueSy
Integer codes for the various lexical symbols;
also see
Symbol . |
static int |
word
Integer codes for the various lexical symbols;
also see
Symbol . |
Constructor and Description |
---|
Lexical(java.io.InputStream inp)
Construct a Lexical analyser of a source InputStream, 'inp'.
|
Modifier and Type | Method and Description |
---|---|
boolean |
eoi()
Is this Lexical at its 'end of input', or not?
|
void |
error(java.lang.String msg)
Print an error message, msg, and stop.
|
static Lexical |
forFile(java.io.File file)
Return a Lexical analyser of a source File, 'file'.
|
static Lexical |
forFile(java.lang.String fn)
Return a Lexical analyser of a source File named 'fn'.
|
static Lexical |
forString(java.lang.String str)
Return a Lexical analyser of a source String, 'str'.
|
protected void |
getch()
Note, getch() changes the state variables,
including 'ch', as a side-effect.
|
void |
insymbol()
Get the next
symbol , from the InputStream 'inp'. |
static java.lang.String |
int2sy(int n)
Return the n-th Lexical Symbol as a String, if possible.
|
boolean |
lines1stSy()
Is the current input symbol, the first one on the line?
|
static void |
main(java.lang.String[] argv)
main() allows Lexical to be tested, a little, in isolation,
for example
|
java.lang.String |
skipRest()
Skip , and return, up to
a "few" remaining input lines and characters. |
java.lang.String |
skipRest(int maxLines,
int maxChars)
Skip, and return, the rest of the input up to the limits 'maxLines'
lines and 'maxChars' characters.
|
int |
sy()
Return the kind of the current input symbol.
|
java.lang.String |
syInfo()
Return a String representation of the current
symbol ,
e.g., for debugging or tracing purposes. |
double |
theAcc()
Return the supposed precision of the real-valued numeral, if any.
|
double |
theDbl()
Return the current real-valued numeral, if any.
|
int |
theInt()
Return the current integer numeral, if any.
|
java.lang.String |
theWord()
Return the current word (identifier or keyword), if any.
|
protected final java.io.InputStream inp
public static final int word
Symbol
.public static final int numeral
Symbol
.public static final int numeralR
Symbol
.public static final int charLiteral
Symbol
.public static final int stringLiteral
Symbol
.public static final int triv
Symbol
.public static final int nilSy
Symbol
.public static final int trueSy
Symbol
.public static final int falseSy
Symbol
.public static final int open
Symbol
.public static final int close
Symbol
.public static final int sqopen
Symbol
.public static final int sqclose
Symbol
.public static final int curlopen
Symbol
.public static final int curlclose
Symbol
.public static final int letSy
Symbol
.public static final int recSy
Symbol
.public static final int inSy
Symbol
.public static final int comma
Symbol
.public static final int colon
Symbol
.public static final int ifSy
Symbol
.public static final int thenSy
Symbol
.public static final int elseSy
Symbol
.public static final int lambdaSy
Symbol
.public static final int dot
Symbol
.public static final int consSy
Symbol
.public static final int orSy
Symbol
.public static final int andSy
Symbol
.public static final int eq
Symbol
.public static final int ne
Symbol
.public static final int lt
Symbol
.public static final int le
Symbol
.public static final int gt
Symbol
.public static final int ge
Symbol
.public static final int plus
Symbol
.public static final int minus
Symbol
.public static final int times
Symbol
.public static final int over
Symbol
.public static final int nullSy
Symbol
.public static final int hdSy
Symbol
.public static final int tlSy
Symbol
.public static final int notSy
Symbol
.public static final int eofSy
Symbol
.public static final java.lang.String[] Symbol
public Lexical(java.io.InputStream inp)
forString(java.lang.String)
and forFile(File)
.public static java.lang.String int2sy(int n)
public static Lexical forString(java.lang.String str)
public static Lexical forFile(java.io.File file)
forFile(String)
.public static Lexical forFile(java.lang.String fn)
forFile(File)
.public int sy()
public java.lang.String syInfo()
symbol
,
e.g., for debugging or tracing purposes.public boolean lines1stSy()
public boolean eoi()
public java.lang.String theWord()
public int theInt()
public double theDbl()
public double theAcc()
public void insymbol()
symbol
, from the InputStream 'inp'.protected void getch()
public java.lang.String skipRest()
Skip
, and return, up to
a "few" remaining input lines and characters.public java.lang.String skipRest(int maxLines, int maxChars)
public void error(java.lang.String msg)
public static void main(java.lang.String[] argv)