# Class Parser

java.lang.Object
bsh.Parser

All Implemented Interfaces:
  `ParserConstants, ParserTreeConstants`

public class Parser extends 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: invalid input: '<'p ``

            Parser parser = new Parser(in);
            while( !(eof=parser.Line()) ) {
                    SimpleNode node = parser.popNode();
                    // use the node, etc. (See bsh.BSH* classes)
            }

## Field Summary

Fields
Modifier and Type
Field
Description
`Token`
`jj_nt`
`protected bsh.JJTParserState`
`jjtree`
`boolean`
`lookingAhead`
`Token`
`token`
`ParserTokenManager`
`token_source`

### Fields inherited from interface 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, 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, tokenImage, TRANSIENT, TRUE, TRY, VOID, VOLATILE, WHILE, XOR, XORASSIGN`

### Fields inherited from interface ParserTreeConstants

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

## Constructor Summary

Constructors
Constructor
Description
`Parser(ParserTokenManager tm)`
`Parser(InputStream stream)`
`Parser(Reader stream)`

## Method Summary

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

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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

## Constructor Details

### Parser

public Parser(InputStream stream)

### Parser

public Parser(Reader stream)

### Parser

public Parser(ParserTokenManager tm)

## Method Details

### setRetainComments

public void setRetainComments(boolean b)

### popNode

public bsh.SimpleNode popNode()

### main

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

Throws:
  `IOException`
  `ParseException`

### Line

public final boolean Line() throws ParseException

Throws:
  `ParseException`

### Modifiers

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

Throws:
  `ParseException`

### ClassDeclaration

public final void ClassDeclaration() throws ParseException

Throws:
  `ParseException`

### MethodDeclaration

public final void MethodDeclaration() throws ParseException

Throws:
  `ParseException`

### PackageDeclaration

public final void PackageDeclaration() throws ParseException

Throws:
  `ParseException`

### ImportDeclaration

public final void ImportDeclaration() throws ParseException

Throws:
  `ParseException`

### VariableDeclarator

public final void VariableDeclarator() throws ParseException

Throws:
  `ParseException`

### VariableInitializer

public final void VariableInitializer() throws ParseException

Throws:
  `ParseException`

### ArrayInitializer

public final void ArrayInitializer() throws ParseException

Throws:
  `ParseException`

### FormalParameters

public final void FormalParameters() throws ParseException

Throws:
  `ParseException`

### FormalParameter

public final void FormalParameter() throws ParseException

Throws:
  `ParseException`

### Type

public final void Type() throws ParseException

Throws:
  `ParseException`

### ReturnType

public final void ReturnType() throws ParseException

Throws:
  `ParseException`

### PrimitiveType

public final void PrimitiveType() throws ParseException

Throws:
  `ParseException`

### AmbiguousName

public final void AmbiguousName() throws ParseException

Throws:
  `ParseException`

### NameList

public final int NameList() throws ParseException

Throws:
  `ParseException`

### Expression

public final void Expression() throws ParseException

Throws:
  `ParseException`

### Assignment

public final void Assignment() throws ParseException

Throws:
  `ParseException`

### AssignmentOperator

public final int AssignmentOperator() throws ParseException

Throws:
  `ParseException`

### ConditionalExpression

public final void ConditionalExpression() throws ParseException

Throws:
  `ParseException`

### ConditionalOrExpression

public final void ConditionalOrExpression() throws ParseException

Throws:
  `ParseException`

### ConditionalAndExpression

public final void ConditionalAndExpression() throws ParseException

Throws:
  `ParseException`

### InclusiveOrExpression

public final void InclusiveOrExpression() throws ParseException

Throws:
  `ParseException`

### ExclusiveOrExpression

public final void ExclusiveOrExpression() throws ParseException

Throws:
  `ParseException`

### AndExpression

public final void AndExpression() throws ParseException

Throws:
  `ParseException`

### EqualityExpression

public final void EqualityExpression() throws ParseException

Throws:
  `ParseException`

### InstanceOfExpression

public final void InstanceOfExpression() throws ParseException

Throws:
  `ParseException`

### RelationalExpression

public final void RelationalExpression() throws ParseException

Throws:
  `ParseException`

### ShiftExpression

public final void ShiftExpression() throws ParseException

Throws:
  `ParseException`

### AdditiveExpression

public final void AdditiveExpression() throws ParseException

Throws:
  `ParseException`

### MultiplicativeExpression

public final void MultiplicativeExpression() throws ParseException

Throws:
  `ParseException`

### UnaryExpression

public final void UnaryExpression() throws ParseException

Throws:
  `ParseException`

### PreIncrementExpression

public final void PreIncrementExpression() throws ParseException

Throws:
  `ParseException`

### PreDecrementExpression

public final void PreDecrementExpression() throws ParseException

Throws:
  `ParseException`

### UnaryExpressionNotPlusMinus

public final void UnaryExpressionNotPlusMinus() throws ParseException

Throws:
  `ParseException`

### CastLookahead

public final void CastLookahead() throws ParseException

Throws:
  `ParseException`

### PostfixExpression

public final void PostfixExpression() throws ParseException

Throws:
  `ParseException`

### CastExpression

public final void CastExpression() throws ParseException

Throws:
  `ParseException`

### PrimaryExpression

public final void PrimaryExpression() throws ParseException

Throws:
  `ParseException`

### MethodInvocation

public final void MethodInvocation() throws ParseException

Throws:
  `ParseException`

### PrimaryPrefix

public final void PrimaryPrefix() throws ParseException

Throws:
  `ParseException`

### PrimarySuffix

public final void PrimarySuffix() throws ParseException

Throws:
  `ParseException`

### Literal

public final void Literal() throws ParseException

Throws:
  `ParseException`

### BooleanLiteral

public final boolean BooleanLiteral() throws ParseException

Throws:
  `ParseException`

### NullLiteral

public final void NullLiteral() throws ParseException

Throws:
  `ParseException`

### VoidLiteral

public final void VoidLiteral() throws ParseException

Throws:
  `ParseException`

### Arguments

public final void Arguments() throws ParseException

Throws:
  `ParseException`

### ArgumentList

public final void ArgumentList() throws ParseException

Throws:
  `ParseException`

### AllocationExpression

public final void AllocationExpression() throws ParseException

Throws:
  `ParseException`

### ArrayDimensions

public final void ArrayDimensions() throws ParseException

Throws:
  `ParseException`

### Statement

public final void Statement() throws ParseException

Throws:
  `ParseException`

### LabeledStatement

public final void LabeledStatement() throws ParseException

Throws:
  `ParseException`

### Block

public final void Block() throws ParseException

Throws:
  `ParseException`

### BlockStatement

public final void BlockStatement() throws ParseException

Throws:
  `ParseException`

### FormalComment

public final void FormalComment() throws ParseException

Throws:
  `ParseException`

### EmptyStatement

public final void EmptyStatement() throws ParseException

Throws:
  `ParseException`

### StatementExpression

public final void StatementExpression() throws ParseException

Throws:
  `ParseException`

### SwitchStatement

public final void SwitchStatement() throws ParseException

Throws:
  `ParseException`

### SwitchLabel

public final void SwitchLabel() throws ParseException

Throws:
  `ParseException`

### IfStatement

public final void IfStatement() throws ParseException

Throws:
  `ParseException`

### WhileStatement

public final void WhileStatement() throws ParseException

Throws:
  `ParseException`

### DoStatement

public final void DoStatement() throws ParseException

Throws:
  `ParseException`

### ForStatement

public final void ForStatement() throws ParseException

Throws:
  `ParseException`

### EnhancedForStatement

public final void EnhancedForStatement() throws ParseException

Throws:
  `ParseException`

### ForInit

public final void ForInit() throws ParseException

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.

Throws:
  `ParseException`

### StatementExpressionList

public final void StatementExpressionList() throws ParseException

Throws:
  `ParseException`

### ForUpdate

public final void ForUpdate() throws ParseException

Throws:
  `ParseException`

### BreakStatement

public final void BreakStatement() throws ParseException

Throws:
  `ParseException`

### ContinueStatement

public final void ContinueStatement() throws ParseException

Throws:
  `ParseException`

### ReturnStatement

public final void ReturnStatement() throws ParseException

Throws:
  `ParseException`

### SynchronizedStatement

public final void SynchronizedStatement() throws ParseException

Throws:
  `ParseException`

### ThrowStatement

public final void ThrowStatement() throws ParseException

Throws:
  `ParseException`

### TryStatement

public final void TryStatement() throws ParseException

Throws:
  `ParseException`

### ReInit

public void ReInit(InputStream stream)

### ReInit

public void ReInit(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()