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, JJTENHANCEDFORSTATEMENT, JJTFORMALCOMMENT, JJTFORMALPARAMETER, JJTFORMALPARAMETERS, JJTFORSTATEMENT, JJTIFSTATEMENT, JJTIMPORTDECLARATION, 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, ABSTRACT, 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, NATIVE, 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, SYNCHRONIZED, THROW, THROWS, TILDE, tokenImage, TRANSIENT, TRUE, TRY, VOID, VOLATILE, 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 Token token
jj_nt
public 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,
ParseException
java.io.IOException
ParseException
Line
public final boolean Line()
throws ParseException
ParseException
Modifiers
public final bsh.Modifiers Modifiers(int context,
boolean lookahead)
throws ParseException
- THE JAVA LANGUAGE GRAMMAR STARTS HERE *
ParseException
MethodDeclaration
public final void MethodDeclaration()
throws ParseException
ParseException
MethodDeclarationLookahead
public final void MethodDeclarationLookahead()
throws ParseException
- It's tempting to collapse this to one like like so:
[ LOOKAHEAD( { methodHasReturnType() } ) ReturnType() ]
FormalParameters() "{"
However this doesn't work because nested lookaheads are not evaluated
during lookahead!
http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq.htm#tth_sEc4.9
ParseException
ImportDeclaration
public final void ImportDeclaration()
throws ParseException
ParseException
VariableDeclarator
public final void VariableDeclarator()
throws ParseException
ParseException
VariableInitializer
public final void VariableInitializer()
throws ParseException
ParseException
ArrayInitializer
public final void ArrayInitializer()
throws ParseException
ParseException
FormalParameters
public final void FormalParameters()
throws ParseException
ParseException
FormalParameter
public final void FormalParameter()
throws ParseException
ParseException
Type
public final void Type()
throws ParseException
ParseException
ReturnType
public final void ReturnType()
throws ParseException
ParseException
PrimitiveType
public final void PrimitiveType()
throws ParseException
ParseException
AmbiguousName
public final void AmbiguousName()
throws ParseException
ParseException
NameList
public final int NameList()
throws ParseException
ParseException
Expression
public final void Expression()
throws ParseException
ParseException
Assignment
public final void Assignment()
throws ParseException
ParseException
AssignmentOperator
public final int AssignmentOperator()
throws ParseException
ParseException
ConditionalExpression
public final void ConditionalExpression()
throws ParseException
ParseException
ConditionalOrExpression
public final void ConditionalOrExpression()
throws ParseException
ParseException
ConditionalAndExpression
public final void ConditionalAndExpression()
throws ParseException
ParseException
InclusiveOrExpression
public final void InclusiveOrExpression()
throws ParseException
ParseException
ExclusiveOrExpression
public final void ExclusiveOrExpression()
throws ParseException
ParseException
AndExpression
public final void AndExpression()
throws ParseException
ParseException
EqualityExpression
public final void EqualityExpression()
throws ParseException
ParseException
InstanceOfExpression
public final void InstanceOfExpression()
throws ParseException
ParseException
RelationalExpression
public final void RelationalExpression()
throws ParseException
ParseException
ShiftExpression
public final void ShiftExpression()
throws ParseException
ParseException
AdditiveExpression
public final void AdditiveExpression()
throws ParseException
ParseException
MultiplicativeExpression
public final void MultiplicativeExpression()
throws ParseException
ParseException
UnaryExpression
public final void UnaryExpression()
throws ParseException
ParseException
PreIncrementExpression
public final void PreIncrementExpression()
throws ParseException
ParseException
PreDecrementExpression
public final void PreDecrementExpression()
throws ParseException
ParseException
UnaryExpressionNotPlusMinus
public final void UnaryExpressionNotPlusMinus()
throws ParseException
ParseException
CastLookahead
public final void CastLookahead()
throws ParseException
ParseException
PostfixExpression
public final void PostfixExpression()
throws ParseException
ParseException
CastExpression
public final void CastExpression()
throws ParseException
ParseException
PrimaryExpression
public final void PrimaryExpression()
throws ParseException
ParseException
MethodInvocation
public final void MethodInvocation()
throws ParseException
ParseException
PrimaryPrefix
public final void PrimaryPrefix()
throws ParseException
ParseException
PrimarySuffix
public final void PrimarySuffix()
throws ParseException
ParseException
Literal
public final void Literal()
throws ParseException
ParseException
BooleanLiteral
public final boolean BooleanLiteral()
throws ParseException
ParseException
NullLiteral
public final void NullLiteral()
throws ParseException
ParseException
VoidLiteral
public final void VoidLiteral()
throws ParseException
ParseException
Arguments
public final void Arguments()
throws ParseException
ParseException
ArgumentList
public final void ArgumentList()
throws ParseException
ParseException
AllocationExpression
public final void AllocationExpression()
throws ParseException
ParseException
ArrayDimensions
public final void ArrayDimensions()
throws ParseException
ParseException
Statement
public final void Statement()
throws ParseException
ParseException
LabeledStatement
public final void LabeledStatement()
throws ParseException
ParseException
Block
public final void Block()
throws ParseException
ParseException
BlockStatement
public final void BlockStatement()
throws ParseException
ParseException
FormalComment
public final void FormalComment()
throws ParseException
ParseException
EmptyStatement
public final void EmptyStatement()
throws ParseException
ParseException
StatementExpression
public final void StatementExpression()
throws ParseException
ParseException
SwitchStatement
public final void SwitchStatement()
throws ParseException
ParseException
SwitchLabel
public final void SwitchLabel()
throws ParseException
ParseException
IfStatement
public final void IfStatement()
throws ParseException
ParseException
WhileStatement
public final void WhileStatement()
throws ParseException
ParseException
DoStatement
public final void DoStatement()
throws ParseException
ParseException
ForStatement
public final void ForStatement()
throws ParseException
ParseException
EnhancedForStatement
public final void EnhancedForStatement()
throws ParseException
ParseException
ForInit
public final void ForInit()
throws ParseException
ParseException
TypedVariableDeclaration
public final void TypedVariableDeclaration()
throws 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.
ParseException
StatementExpressionList
public final void StatementExpressionList()
throws ParseException
ParseException
ForUpdate
public final void ForUpdate()
throws ParseException
ParseException
BreakStatement
public final void BreakStatement()
throws ParseException
ParseException
ContinueStatement
public final void ContinueStatement()
throws ParseException
ParseException
ReturnStatement
public final void ReturnStatement()
throws ParseException
ParseException
SynchronizedStatement
public final void SynchronizedStatement()
throws ParseException
ParseException
ThrowStatement
public final void ThrowStatement()
throws ParseException
ParseException
TryStatement
public final void TryStatement()
throws ParseException
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 Token getNextToken()
getToken
public final Token getToken(int index)
generateParseException
public ParseException generateParseException()
enable_tracing
public final void enable_tracing()
disable_tracing
public final void disable_tracing()
© 2000 pat@pat.net :-)