use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method UnaryExpression.
public final Expression UnaryExpression() {
Expression ret;
UnaryExpr.Operator op;
Position begin = INVALID;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case INCR:
{
ret = PreIncrementExpression();
break;
}
case DECR:
{
ret = PreDecrementExpression();
break;
}
case PLUS:
case MINUS:
{
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case PLUS:
{
jj_consume_token(PLUS);
op = UnaryExpr.Operator.positive;
begin = tokenBegin();
break;
}
case MINUS:
{
jj_consume_token(MINUS);
op = UnaryExpr.Operator.negative;
begin = tokenBegin();
break;
}
default:
jj_la1[86] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
ret = UnaryExpression();
if (op == UnaryExpr.Operator.negative) {
if (ret instanceof IntegerLiteralExpr && ((IntegerLiteralExpr) ret).isMinValue()) {
ret = new IntegerLiteralMinValueExpr(range(begin, tokenEnd()));
} else if (ret instanceof LongLiteralExpr && ((LongLiteralExpr) ret).isMinValue()) {
ret = new LongLiteralMinValueExpr(range(begin, tokenEnd()));
} else {
ret = new UnaryExpr(range(begin, tokenEnd()), ret, op);
}
} else {
ret = new UnaryExpr(range(begin, tokenEnd()), ret, op);
}
break;
}
case BOOLEAN:
case BYTE:
case CHAR:
case DOUBLE:
case FALSE:
case FLOAT:
case INT:
case LONG:
case NEW:
case NULL:
case SHORT:
case SUPER:
case THIS:
case TRUE:
case VOID:
case LONG_LITERAL:
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case CHARACTER_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case LPAREN:
case BANG:
case TILDE:
{
ret = UnaryExpressionNotPlusMinus();
break;
}
default:
jj_la1[87] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
return ret;
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method SwitchStatement.
public final SwitchStmt SwitchStatement() {
Expression selector;
SwitchEntryStmt entry;
List<SwitchEntryStmt> entries = null;
Position begin;
jj_consume_token(SWITCH);
begin = tokenBegin();
jj_consume_token(LPAREN);
selector = Expression();
jj_consume_token(RPAREN);
jj_consume_token(LBRACE);
label_44: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case CASE:
case _DEFAULT:
{
;
break;
}
default:
jj_la1[133] = jj_gen;
break label_44;
}
entry = SwitchEntry();
entries = add(entries, entry);
}
jj_consume_token(RBRACE);
return new SwitchStmt(range(begin, tokenEnd()), selector, entries);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method Block.
public final BlockStmt Block() {
List<Statement> stmts;
Position begin;
jj_consume_token(LBRACE);
begin = tokenBegin();
stmts = Statements();
jj_consume_token(RBRACE);
return new BlockStmt(range(begin, tokenEnd()), stmts);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method ThrowStatement.
public final ThrowStmt ThrowStatement() {
Expression expr;
Position begin;
jj_consume_token(THROW);
begin = tokenBegin();
expr = Expression();
jj_consume_token(SEMICOLON);
return new ThrowStmt(range(begin, tokenEnd()), expr);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method EnumDeclaration.
public final EnumDeclaration EnumDeclaration(ModifierHolder modifier) {
NameExpr name;
List<ClassOrInterfaceType> impList = null;
EnumConstantDeclaration entry;
List<EnumConstantDeclaration> entries = null;
BodyDeclaration<?> member;
List<BodyDeclaration<?>> members = null;
Position begin = modifier.begin;
jj_consume_token(ENUM);
begin = begin.orIfInvalid(tokenBegin());
name = Name();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IMPLEMENTS:
{
impList = ImplementsList(false);
break;
}
default:
jj_la1[15] = jj_gen;
;
}
jj_consume_token(LBRACE);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENTIFIER:
case AT:
{
entries = new LinkedList<EnumConstantDeclaration>();
entry = EnumConstantDeclaration();
entries.add(entry);
label_6: while (true) {
if (jj_2_3(2)) {
;
} else {
break label_6;
}
jj_consume_token(COMMA);
entry = EnumConstantDeclaration();
entries.add(entry);
}
break;
}
default:
jj_la1[16] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
jj_consume_token(COMMA);
break;
}
default:
jj_la1[17] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case SEMICOLON:
{
jj_consume_token(SEMICOLON);
label_7: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case ABSTRACT:
case BOOLEAN:
case BYTE:
case CHAR:
case CLASS:
case _DEFAULT:
case DOUBLE:
case ENUM:
case FINAL:
case FLOAT:
case INT:
case INTERFACE:
case LONG:
case NATIVE:
case PRIVATE:
case PROTECTED:
case PUBLIC:
case SHORT:
case STATIC:
case STRICTFP:
case SYNCHRONIZED:
case TRANSIENT:
case VOID:
case VOLATILE:
case IDENTIFIER:
case LBRACE:
case SEMICOLON:
case AT:
case LT:
{
;
break;
}
default:
jj_la1[18] = jj_gen;
break label_7;
}
member = ClassOrInterfaceBodyDeclaration(false);
members = add(members, member);
}
break;
}
default:
jj_la1[19] = jj_gen;
;
}
jj_consume_token(RBRACE);
EnumDeclaration tmp = new EnumDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, null, impList, entries, members);
tmp.setNameExpr(name);
return tmp;
}
Aggregations