bsh
Class Parser
java.lang.Object
|
+--bsh.Parser
- All Implemented Interfaces:
- ParserConstants, ParserTreeConstants
- public class Parser
- extends java.lang.Object
- implements ParserTreeConstants, ParserConstants
This is the BeanShell parser. It is used internally by the Interpreter
class (which is probably what you are looking for). The parser knows
only how to parse the structure of the language, it does not understand
names, commands, etc.
You can use the Parser from the command line to do basic structural
validation of BeanShell files without actually executing them. e.g.
java bsh.Parser [ -p ] file [ file ] [ ... ]
The -p option causes the abstract syntax to be printed.
From code you'd use the Parser like this:
Parser parser = new Parser(in);
while( !(eof=parser.Line()) ) {
SimpleNode node = parser.popNode();
// use the node, etc. (See bsh.BSH* classes)
}
Fields inherited from interface bsh.ParserTreeConstants |
JJTALLOCATIONEXPRESSION, JJTAMBIGUOUSNAME, JJTARGUMENTS, JJTARRAYDIMENSIONS, JJTARRAYINITIALIZER, JJTASSIGNMENT, JJTBINARYEXPRESSION, JJTBLOCK, JJTCASTEXPRESSION, JJTFORMALCOMMENT, JJTFORMALPARAMETER, JJTFORMALPARAMETERS, JJTFORSTATEMENT, JJTIFSTATEMENT, JJTIMPORTDECLARATION, JJTLHSPRIMARYEXPRESSION, JJTLHSPRIMARYSUFFIX, JJTLITERAL, JJTMETHODDECLARATION, JJTMETHODINVOCATION, jjtNodeName, JJTPRIMARYEXPRESSION, JJTPRIMARYSUFFIX, JJTPRIMITIVETYPE, JJTRETURNSTATEMENT, JJTRETURNTYPE, JJTSTATEMENTEXPRESSIONLIST, JJTSWITCHLABEL, JJTSWITCHSTATEMENT, JJTTERNARYEXPRESSION, JJTTHROWSTATEMENT, JJTTRYSTATEMENT, JJTTYPE, JJTTYPEDVARIABLEDECLARATION, JJTUNARYEXPRESSION, JJTVARIABLEDECLARATOR, JJTVOID, JJTWHILESTATEMENT |
Fields inherited from interface bsh.ParserConstants |
_DEFAULT, ANDASSIGN, ANDASSIGNX, ASSIGN, BANG, BIT_AND, BIT_ANDX, BIT_OR, BIT_ORX, BOOL_AND, BOOL_ANDX, BOOL_OR, BOOL_ORX, BOOLEAN, BREAK, BYTE, CASE, CATCH, CHAR, CHARACTER_LITERAL, CLASS, COLON, COMMA, CONST, CONTINUE, DECIMAL_LITERAL, DECR, DEFAULT, DIGIT, DO, DOT, DOUBLE, ELSE, EOF, EQ, EXPONENT, FALSE, FINAL, FINALLY, FLOAT, FLOATING_POINT_LITERAL, FOR, FORMAL_COMMENT, GE, GEX, GOTO, GT, GTX, HASH_BANG_COMMENT, HEX_LITERAL, HOOK, IDENTIFIER, IF, IMPORT, INCR, INSTANCEOF, INT, INTEGER_LITERAL, INTERFACE, LBRACE, LBRACKET, LE, LETTER, LEX, LONG, LPAREN, LSHIFT, LSHIFTASSIGN, LSHIFTASSIGNX, LSHIFTX, LT, LTX, MINUS, MINUSASSIGN, MOD, MODASSIGN, MULTI_LINE_COMMENT, NE, NEW, NONPRINTABLE, NULL, OCTAL_LITERAL, ORASSIGN, ORASSIGNX, PLUS, PLUSASSIGN, PRIVATE, PROTECTED, PUBLIC, RBRACE, RBRACKET, RETURN, RPAREN, RSIGNEDSHIFT, RSIGNEDSHIFTASSIGN, RSIGNEDSHIFTASSIGNX, RSIGNEDSHIFTX, RUNSIGNEDSHIFT, RUNSIGNEDSHIFTASSIGN, RUNSIGNEDSHIFTASSIGNX, RUNSIGNEDSHIFTX, SEMICOLON, SHORT, SINGLE_LINE_COMMENT, SLASH, SLASHASSIGN, STAR, STARASSIGN, STATIC, STRING_LITERAL, SWITCH, THROW, TILDE, tokenImage, TRUE, TRY, VOID, WHILE, XOR, XORASSIGN |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jjtree
protected bsh.JJTParserState jjtree
token_source
public ParserTokenManager token_source
token
public bsh.Token token
jj_nt
public bsh.Token jj_nt
lookingAhead
public boolean lookingAhead
Parser
public Parser(java.io.InputStream stream)
Parser
public Parser(java.io.Reader stream)
Parser
public Parser(ParserTokenManager tm)
setRetainComments
public void setRetainComments(boolean b)
popNode
public bsh.SimpleNode popNode()
main
public static void main(java.lang.String[] args)
throws java.io.IOException,
bsh.ParseException
java.io.IOException
bsh.ParseException
Line
public final boolean Line()
throws bsh.ParseException
bsh.ParseException
MethodDeclaration
public final void MethodDeclaration()
throws bsh.ParseException
- THE JAVA LANGUAGE GRAMMAR STARTS HERE *
bsh.ParseException
MethodDeclarationLookahead
public final void MethodDeclarationLookahead()
throws bsh.ParseException
bsh.ParseException
MethodDeclarationTypeLookahead
public final void MethodDeclarationTypeLookahead()
throws bsh.ParseException
bsh.ParseException
ImportDeclaration
public final void ImportDeclaration()
throws bsh.ParseException
bsh.ParseException
VariableDeclarator
public final void VariableDeclarator()
throws bsh.ParseException
bsh.ParseException
VariableInitializer
public final void VariableInitializer()
throws bsh.ParseException
bsh.ParseException
ArrayInitializer
public final void ArrayInitializer()
throws bsh.ParseException
bsh.ParseException
FormalParameters
public final void FormalParameters()
throws bsh.ParseException
bsh.ParseException
FormalParameter
public final void FormalParameter()
throws bsh.ParseException
bsh.ParseException
Type
public final void Type()
throws bsh.ParseException
bsh.ParseException
ReturnType
public final void ReturnType()
throws bsh.ParseException
bsh.ParseException
PrimitiveType
public final void PrimitiveType()
throws bsh.ParseException
bsh.ParseException
AmbiguousName
public final void AmbiguousName()
throws bsh.ParseException
bsh.ParseException
Expression
public final void Expression()
throws bsh.ParseException
bsh.ParseException
Assignment
public final void Assignment()
throws bsh.ParseException
bsh.ParseException
AssignmentOperator
public final int AssignmentOperator()
throws bsh.ParseException
bsh.ParseException
ConditionalExpression
public final void ConditionalExpression()
throws bsh.ParseException
bsh.ParseException
ConditionalOrExpression
public final void ConditionalOrExpression()
throws bsh.ParseException
bsh.ParseException
ConditionalAndExpression
public final void ConditionalAndExpression()
throws bsh.ParseException
bsh.ParseException
InclusiveOrExpression
public final void InclusiveOrExpression()
throws bsh.ParseException
bsh.ParseException
ExclusiveOrExpression
public final void ExclusiveOrExpression()
throws bsh.ParseException
bsh.ParseException
AndExpression
public final void AndExpression()
throws bsh.ParseException
bsh.ParseException
EqualityExpression
public final void EqualityExpression()
throws bsh.ParseException
bsh.ParseException
InstanceOfExpression
public final void InstanceOfExpression()
throws bsh.ParseException
bsh.ParseException
RelationalExpression
public final void RelationalExpression()
throws bsh.ParseException
bsh.ParseException
ShiftExpression
public final void ShiftExpression()
throws bsh.ParseException
bsh.ParseException
AdditiveExpression
public final void AdditiveExpression()
throws bsh.ParseException
bsh.ParseException
MultiplicativeExpression
public final void MultiplicativeExpression()
throws bsh.ParseException
bsh.ParseException
UnaryExpression
public final void UnaryExpression()
throws bsh.ParseException
bsh.ParseException
PreIncrementExpression
public final void PreIncrementExpression()
throws bsh.ParseException
bsh.ParseException
PreDecrementExpression
public final void PreDecrementExpression()
throws bsh.ParseException
bsh.ParseException
UnaryExpressionNotPlusMinus
public final void UnaryExpressionNotPlusMinus()
throws bsh.ParseException
bsh.ParseException
CastLookahead
public final void CastLookahead()
throws bsh.ParseException
bsh.ParseException
PostfixExpression
public final void PostfixExpression()
throws bsh.ParseException
bsh.ParseException
CastExpression
public final void CastExpression()
throws bsh.ParseException
bsh.ParseException
PrimaryExpression
public final void PrimaryExpression()
throws bsh.ParseException
bsh.ParseException
MethodInvocation
public final void MethodInvocation()
throws bsh.ParseException
bsh.ParseException
PrimaryPrefix
public final void PrimaryPrefix()
throws bsh.ParseException
bsh.ParseException
PrimarySuffix
public final void PrimarySuffix()
throws bsh.ParseException
bsh.ParseException
LHSPrimaryPrefix
public final void LHSPrimaryPrefix()
throws bsh.ParseException
- The method invocation is here to force this to an object type in order
to simplify the suffix processing.
bsh.ParseException
LHSPrimaryExpression
public final void LHSPrimaryExpression()
throws bsh.ParseException
bsh.ParseException
LHSPrimarySuffix
public final void LHSPrimarySuffix()
throws bsh.ParseException
bsh.ParseException
Literal
public final void Literal()
throws bsh.ParseException
bsh.ParseException
BooleanLiteral
public final boolean BooleanLiteral()
throws bsh.ParseException
bsh.ParseException
NullLiteral
public final void NullLiteral()
throws bsh.ParseException
bsh.ParseException
VoidLiteral
public final void VoidLiteral()
throws bsh.ParseException
bsh.ParseException
Arguments
public final void Arguments()
throws bsh.ParseException
bsh.ParseException
ArgumentList
public final void ArgumentList()
throws bsh.ParseException
bsh.ParseException
AllocationExpression
public final void AllocationExpression()
throws bsh.ParseException
bsh.ParseException
ArrayDimensions
public final void ArrayDimensions()
throws bsh.ParseException
bsh.ParseException
Statement
public final void Statement()
throws bsh.ParseException
bsh.ParseException
LabeledStatement
public final void LabeledStatement()
throws bsh.ParseException
bsh.ParseException
Block
public final void Block()
throws bsh.ParseException
bsh.ParseException
BlockStatement
public final void BlockStatement()
throws bsh.ParseException
bsh.ParseException
FormalComment
public final void FormalComment()
throws bsh.ParseException
bsh.ParseException
EmptyStatement
public final void EmptyStatement()
throws bsh.ParseException
bsh.ParseException
StatementExpression
public final void StatementExpression()
throws bsh.ParseException
bsh.ParseException
SwitchStatement
public final void SwitchStatement()
throws bsh.ParseException
bsh.ParseException
SwitchLabel
public final void SwitchLabel()
throws bsh.ParseException
bsh.ParseException
IfStatement
public final void IfStatement()
throws bsh.ParseException
bsh.ParseException
WhileStatement
public final void WhileStatement()
throws bsh.ParseException
bsh.ParseException
DoStatement
public final void DoStatement()
throws bsh.ParseException
bsh.ParseException
ForStatement
public final void ForStatement()
throws bsh.ParseException
bsh.ParseException
ForInit
public final void ForInit()
throws bsh.ParseException
bsh.ParseException
TypedVariableDeclaration
public final void TypedVariableDeclaration()
throws bsh.ParseException
- Declared a typed variable.
Untyped variables are not declared per-se but are handled by the part
of the grammar that deals with assignments.
bsh.ParseException
StatementExpressionList
public final void StatementExpressionList()
throws bsh.ParseException
bsh.ParseException
ForUpdate
public final void ForUpdate()
throws bsh.ParseException
bsh.ParseException
BreakStatement
public final void BreakStatement()
throws bsh.ParseException
bsh.ParseException
ContinueStatement
public final void ContinueStatement()
throws bsh.ParseException
bsh.ParseException
ReturnStatement
public final void ReturnStatement()
throws bsh.ParseException
bsh.ParseException
ThrowStatement
public final void ThrowStatement()
throws bsh.ParseException
bsh.ParseException
TryStatement
public final void TryStatement()
throws bsh.ParseException
bsh.ParseException
ReInit
public void ReInit(java.io.InputStream stream)
ReInit
public void ReInit(java.io.Reader stream)
ReInit
public void ReInit(ParserTokenManager tm)
getNextToken
public final bsh.Token getNextToken()
getToken
public final bsh.Token getToken(int index)
generateParseException
public final bsh.ParseException generateParseException()
enable_tracing
public final void enable_tracing()
disable_tracing
public final void disable_tracing()
© 2000 pat@pat.net :-)