use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method VariableDeclarationExpression.
public final VariableDeclarationExpr VariableDeclarationExpression() {
ModifierHolder modifier;
Type type;
List<VariableDeclarator> variables = new LinkedList<VariableDeclarator>();
VariableDeclarator var;
modifier = Modifiers();
type = Type();
var = VariableDeclarator();
variables.add(var);
label_43: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
;
break;
}
default:
jj_la1[126] = jj_gen;
break label_43;
}
jj_consume_token(COMMA);
var = VariableDeclarator();
variables.add(var);
}
Position begin = modifier.begin.orIfInvalid(type.getBegin());
Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type);
return new VariableDeclarationExpr(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, typeListPair.a, variables, typeListPair.b);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method MemberValueArrayInitializer.
public final Expression MemberValueArrayInitializer() {
List<Expression> ret = new LinkedList<Expression>();
Expression member;
Position begin;
jj_consume_token(LBRACE);
begin = tokenBegin();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
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 LBRACE:
case AT:
case BANG:
case TILDE:
case INCR:
case DECR:
case PLUS:
case MINUS:
{
member = MemberValue();
ret.add(member);
label_51: while (true) {
if (jj_2_43(2)) {
;
} else {
break label_51;
}
jj_consume_token(COMMA);
member = MemberValue();
ret.add(member);
}
break;
}
default:
jj_la1[154] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
jj_consume_token(COMMA);
break;
}
default:
jj_la1[155] = jj_gen;
;
}
jj_consume_token(RBRACE);
return new ArrayInitializerExpr(range(begin, tokenEnd()), ret);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method SwitchEntry.
public final SwitchEntryStmt SwitchEntry() {
Expression label = null;
List<Statement> stmts;
Position begin;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case CASE:
{
jj_consume_token(CASE);
begin = tokenBegin();
label = Expression();
break;
}
case _DEFAULT:
{
jj_consume_token(_DEFAULT);
begin = tokenBegin();
break;
}
default:
jj_la1[134] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
jj_consume_token(COLON);
stmts = Statements();
return new SwitchEntryStmt(range(begin, tokenEnd()), label, stmts);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method ClassOrInterfaceDeclaration.
public final ClassOrInterfaceDeclaration ClassOrInterfaceDeclaration(ModifierHolder modifier) {
boolean isInterface = false;
NameExpr name;
RangedList<TypeParameter> typePar = new RangedList<TypeParameter>(null);
List<ClassOrInterfaceType> extList = null;
List<ClassOrInterfaceType> impList = null;
List<BodyDeclaration<?>> members;
Position begin = modifier.begin;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case CLASS:
{
jj_consume_token(CLASS);
break;
}
case INTERFACE:
{
jj_consume_token(INTERFACE);
isInterface = true;
break;
}
default:
jj_la1[9] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
begin = begin.orIfInvalid(tokenBegin());
name = Name();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LT:
{
typePar = TypeParameters();
break;
}
default:
jj_la1[10] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case EXTENDS:
{
extList = ExtendsList(isInterface);
break;
}
default:
jj_la1[11] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IMPLEMENTS:
{
impList = ImplementsList(isInterface);
break;
}
default:
jj_la1[12] = jj_gen;
;
}
members = ClassOrInterfaceBody(isInterface);
ClassOrInterfaceDeclaration tmp = new ClassOrInterfaceDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, isInterface, null, typePar.list, extList, impList, members);
tmp.setNameExpr(name);
return tmp;
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method UnaryExpressionNotPlusMinus.
public final Expression UnaryExpressionNotPlusMinus() {
Expression ret;
UnaryExpr.Operator op;
Position begin = INVALID;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case BANG:
case TILDE:
{
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case TILDE:
{
jj_consume_token(TILDE);
op = UnaryExpr.Operator.inverse;
begin = tokenBegin();
break;
}
case BANG:
{
jj_consume_token(BANG);
op = UnaryExpr.Operator.not;
begin = tokenBegin();
break;
}
default:
jj_la1[88] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
ret = UnaryExpression();
ret = new UnaryExpr(range(begin, tokenEnd()), ret, op);
break;
}
default:
jj_la1[89] = jj_gen;
if (jj_2_22(2147483647)) {
ret = CastExpression();
} else {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
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:
{
ret = PostfixExpression();
break;
}
default:
jj_la1[90] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
}
return ret;
}
Aggregations