bsh

Class Parser

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)
}

Field Summary

Token
jj_nt
protected bsh.JJTParserState
jjtree
boolean
lookingAhead
Token
token
ParserTokenManager
token_source

Fields inherited from interface bsh.ParserConstants

ABSTRACT, ANDASSIGN, ANDASSIGNX, ASSIGN, BANG, BIT_AND, BIT_ANDX, BIT_OR, BIT_ORX, BOOLEAN, BOOL_AND, BOOL_ANDX, BOOL_OR, BOOL_ORX, BREAK, BYTE, CASE, CATCH, CHAR, CHARACTER_LITERAL, CLASS, COLON, COMMA, CONST, CONTINUE, DECIMAL_LITERAL, DECR, DEFAULT, DIGIT, DO, DOT, DOUBLE, ELSE, ENUM, EOF, EQ, EXPONENT, EXTENDS, FALSE, FINAL, FINALLY, FLOAT, FLOATING_POINT_LITERAL, FOR, FORMAL_COMMENT, GE, GEX, GOTO, GT, GTX, HASH_BANG_COMMENT, HEX_LITERAL, HOOK, IDENTIFIER, IF, IMPLEMENTS, 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, PACKAGE, 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, STRICTFP, STRING_LITERAL, SWITCH, SYNCHRONIZED, THROW, THROWS, TILDE, TRANSIENT, TRUE, TRY, VOID, VOLATILE, WHILE, XOR, XORASSIGN, _DEFAULT, tokenImage

Fields inherited from interface bsh.ParserTreeConstants

JJTALLOCATIONEXPRESSION, JJTAMBIGUOUSNAME, JJTARGUMENTS, JJTARRAYDIMENSIONS, JJTARRAYINITIALIZER, JJTASSIGNMENT, JJTBINARYEXPRESSION, JJTBLOCK, JJTCASTEXPRESSION, JJTCLASSDECLARATION, JJTENHANCEDFORSTATEMENT, JJTFORMALCOMMENT, JJTFORMALPARAMETER, JJTFORMALPARAMETERS, JJTFORSTATEMENT, JJTIFSTATEMENT, JJTIMPORTDECLARATION, JJTLITERAL, JJTMETHODDECLARATION, JJTMETHODINVOCATION, JJTPACKAGEDECLARATION, JJTPRIMARYEXPRESSION, JJTPRIMARYSUFFIX, JJTPRIMITIVETYPE, JJTRETURNSTATEMENT, JJTRETURNTYPE, JJTSTATEMENTEXPRESSIONLIST, JJTSWITCHLABEL, JJTSWITCHSTATEMENT, JJTTERNARYEXPRESSION, JJTTHROWSTATEMENT, JJTTRYSTATEMENT, JJTTYPE, JJTTYPEDVARIABLEDECLARATION, JJTUNARYEXPRESSION, JJTVARIABLEDECLARATOR, JJTVOID, JJTWHILESTATEMENT, jjtNodeName

Constructor Summary

Parser(ParserTokenManager tm)
Parser(java.io.InputStream stream)
Parser(java.io.Reader stream)

Method Summary

void
AdditiveExpression()
void
AllocationExpression()
void
AmbiguousName()
void
AndExpression()
void
ArgumentList()
void
Arguments()
void
ArrayDimensions()
void
ArrayInitializer()
void
Assignment()
int
AssignmentOperator()
void
Block()
void
BlockStatement()
boolean
BooleanLiteral()
void
BreakStatement()
void
CastExpression()
void
CastLookahead()
void
ClassDeclaration()
void
ConditionalAndExpression()
void
ConditionalExpression()
void
ConditionalOrExpression()
void
ContinueStatement()
void
DoStatement()
void
EmptyStatement()
void
EnhancedForStatement()
void
EqualityExpression()
void
ExclusiveOrExpression()
void
Expression()
void
ForInit()
void
ForStatement()
void
ForUpdate()
void
FormalComment()
void
FormalParameter()
void
FormalParameters()
void
IfStatement()
void
ImportDeclaration()
void
InclusiveOrExpression()
void
InstanceOfExpression()
void
LabeledStatement()
boolean
Line()
void
Literal()
void
MethodDeclaration()
void
MethodInvocation()
Modifiers
Modifiers(int context, boolean lookahead)
THE JAVA LANGUAGE GRAMMAR STARTS HERE *
void
MultiplicativeExpression()
int
NameList()
void
NullLiteral()
void
PackageDeclaration()
void
PostfixExpression()
void
PreDecrementExpression()
void
PreIncrementExpression()
void
PrimaryExpression()
void
PrimaryPrefix()
void
PrimarySuffix()
void
PrimitiveType()
void
ReInit(ParserTokenManager tm)
void
ReInit(java.io.InputStream stream)
void
ReInit(java.io.Reader stream)
void
RelationalExpression()
void
ReturnStatement()
void
ReturnType()
void
ShiftExpression()
void
Statement()
void
StatementExpression()
void
StatementExpressionList()
void
SwitchLabel()
void
SwitchStatement()
void
SynchronizedStatement()
void
ThrowStatement()
void
TryStatement()
void
Type()
void
TypedVariableDeclaration()
Declared a typed variable.
void
UnaryExpression()
void
UnaryExpressionNotPlusMinus()
void
VariableDeclarator()
void
VariableInitializer()
void
VoidLiteral()
void
WhileStatement()
void
disable_tracing()
void
enable_tracing()
ParseException
generateParseException()
Token
getNextToken()
Token
getToken(int index)
static void
main(String[] args)
bsh.SimpleNode
popNode()
void
setRetainComments(boolean b)

Field Details

jj_nt

public Token jj_nt

jjtree

protected bsh.JJTParserState jjtree

lookingAhead

public boolean lookingAhead

token

public Token token

token_source

public ParserTokenManager token_source

Constructor Details

Parser

public Parser(ParserTokenManager tm)

Parser

public Parser(java.io.InputStream stream)

Parser

public Parser(java.io.Reader stream)

Method Details

AdditiveExpression

public final void AdditiveExpression()
            throws ParseException

AllocationExpression

public final void AllocationExpression()
            throws ParseException

AmbiguousName

public final void AmbiguousName()
            throws ParseException

AndExpression

public final void AndExpression()
            throws ParseException

ArgumentList

public final void ArgumentList()
            throws ParseException

Arguments

public final void Arguments()
            throws ParseException

ArrayDimensions

public final void ArrayDimensions()
            throws ParseException

ArrayInitializer

public final void ArrayInitializer()
            throws ParseException

Assignment

public final void Assignment()
            throws ParseException

AssignmentOperator

public final int AssignmentOperator()
            throws ParseException

Block

public final void Block()
            throws ParseException

BlockStatement

public final void BlockStatement()
            throws ParseException

BooleanLiteral

public final boolean BooleanLiteral()
            throws ParseException

BreakStatement

public final void BreakStatement()
            throws ParseException

CastExpression

public final void CastExpression()
            throws ParseException

CastLookahead

public final void CastLookahead()
            throws ParseException

ClassDeclaration

public final void ClassDeclaration()
            throws ParseException

ConditionalAndExpression

public final void ConditionalAndExpression()
            throws ParseException

ConditionalExpression

public final void ConditionalExpression()
            throws ParseException

ConditionalOrExpression

public final void ConditionalOrExpression()
            throws ParseException

ContinueStatement

public final void ContinueStatement()
            throws ParseException

DoStatement

public final void DoStatement()
            throws ParseException

EmptyStatement

public final void EmptyStatement()
            throws ParseException

EnhancedForStatement

public final void EnhancedForStatement()
            throws ParseException

EqualityExpression

public final void EqualityExpression()
            throws ParseException

ExclusiveOrExpression

public final void ExclusiveOrExpression()
            throws ParseException

Expression

public final void Expression()
            throws ParseException

ForInit

public final void ForInit()
            throws ParseException

ForStatement

public final void ForStatement()
            throws ParseException

ForUpdate

public final void ForUpdate()
            throws ParseException

FormalComment

public final void FormalComment()
            throws ParseException

FormalParameter

public final void FormalParameter()
            throws ParseException

FormalParameters

public final void FormalParameters()
            throws ParseException

IfStatement

public final void IfStatement()
            throws ParseException

ImportDeclaration

public final void ImportDeclaration()
            throws ParseException

InclusiveOrExpression

public final void InclusiveOrExpression()
            throws ParseException

InstanceOfExpression

public final void InstanceOfExpression()
            throws ParseException

LabeledStatement

public final void LabeledStatement()
            throws ParseException

Line

public final boolean Line()
            throws ParseException

Literal

public final void Literal()
            throws ParseException

MethodDeclaration

public final void MethodDeclaration()
            throws ParseException

MethodInvocation

public final void MethodInvocation()
            throws ParseException

Modifiers

public final Modifiers Modifiers(int context,
                                 boolean lookahead)
            throws ParseException
THE JAVA LANGUAGE GRAMMAR STARTS HERE *

MultiplicativeExpression

public final void MultiplicativeExpression()
            throws ParseException

NameList

public final int NameList()
            throws ParseException

NullLiteral

public final void NullLiteral()
            throws ParseException

PackageDeclaration

public final void PackageDeclaration()
            throws ParseException

PostfixExpression

public final void PostfixExpression()
            throws ParseException

PreDecrementExpression

public final void PreDecrementExpression()
            throws ParseException

PreIncrementExpression

public final void PreIncrementExpression()
            throws ParseException

PrimaryExpression

public final void PrimaryExpression()
            throws ParseException

PrimaryPrefix

public final void PrimaryPrefix()
            throws ParseException

PrimarySuffix

public final void PrimarySuffix()
            throws ParseException

PrimitiveType

public final void PrimitiveType()
            throws ParseException

ReInit

public void ReInit(ParserTokenManager tm)

ReInit

public void ReInit(java.io.InputStream stream)

ReInit

public void ReInit(java.io.Reader stream)

RelationalExpression

public final void RelationalExpression()
            throws ParseException

ReturnStatement

public final void ReturnStatement()
            throws ParseException

ReturnType

public final void ReturnType()
            throws ParseException

ShiftExpression

public final void ShiftExpression()
            throws ParseException

Statement

public final void Statement()
            throws ParseException

StatementExpression

public final void StatementExpression()
            throws ParseException

StatementExpressionList

public final void StatementExpressionList()
            throws ParseException

SwitchLabel

public final void SwitchLabel()
            throws ParseException

SwitchStatement

public final void SwitchStatement()
            throws ParseException

SynchronizedStatement

public final void SynchronizedStatement()
            throws ParseException

ThrowStatement

public final void ThrowStatement()
            throws ParseException

TryStatement

public final void TryStatement()
            throws ParseException

Type

public final void Type()
            throws 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.

UnaryExpression

public final void UnaryExpression()
            throws ParseException

UnaryExpressionNotPlusMinus

public final void UnaryExpressionNotPlusMinus()
            throws ParseException

VariableDeclarator

public final void VariableDeclarator()
            throws ParseException

VariableInitializer

public final void VariableInitializer()
            throws ParseException

VoidLiteral

public final void VoidLiteral()
            throws ParseException

WhileStatement

public final void WhileStatement()
            throws ParseException

disable_tracing

public final void disable_tracing()

enable_tracing

public final void enable_tracing()

generateParseException

public ParseException generateParseException()

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

main

public static void main(String[] args)
            throws IOException,
                   ParseException

popNode

public bsh.SimpleNode popNode()

setRetainComments

public void setRetainComments(boolean b)

B) 2000-2005 pat@pat.net :-)