use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method PreIncrementExpression.
public final Expression PreIncrementExpression() {
Expression ret;
Position begin = INVALID;
jj_consume_token(INCR);
begin = tokenBegin();
ret = UnaryExpression();
ret = new UnaryExpr(range(begin, tokenEnd()), ret, UnaryExpr.Operator.preIncrement);
return ret;
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method PrimaryPrefix.
public final Expression PrimaryPrefix() {
Expression ret = null;
NameExpr name;
RangedList<Type<?>> typeArgs = new RangedList<Type<?>>(null);
List<Expression> args = null;
List<Parameter> params = null;
boolean hasArgs = false;
boolean isLambda = false;
Type type;
Position begin;
Parameter p = null;
VariableDeclaratorId id = null;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case FALSE:
case NULL:
case TRUE:
case LONG_LITERAL:
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case CHARACTER_LITERAL:
case STRING_LITERAL:
{
ret = Literal();
break;
}
case THIS:
{
jj_consume_token(THIS);
ret = new ThisExpr(tokenRange(), null);
break;
}
case SUPER:
{
jj_consume_token(SUPER);
ret = new SuperExpr(tokenRange(), null);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case DOT:
{
jj_consume_token(DOT);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LT:
{
typeArgs = TypeArguments();
break;
}
default:
jj_la1[94] = jj_gen;
;
}
name = SimpleName();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LPAREN:
{
args = Arguments();
hasArgs = true;
break;
}
default:
jj_la1[95] = jj_gen;
;
}
if (hasArgs) {
MethodCallExpr m = new MethodCallExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, typeArgs.list, null, args);
m.setNameExpr(name);
ret = m;
} else {
FieldAccessExpr f = new FieldAccessExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, null, null);
f.setFieldExpr(name);
ret = f;
}
break;
}
case DOUBLECOLON:
{
jj_consume_token(DOUBLECOLON);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LT:
{
typeArgs = TypeArguments();
break;
}
default:
jj_la1[96] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENTIFIER:
{
jj_consume_token(IDENTIFIER);
break;
}
case NEW:
{
jj_consume_token(NEW);
break;
}
default:
jj_la1[97] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
ret = new MethodReferenceExpr(range(ret.getBegin(), pos(token.endLine, token.endColumn)), ret, typeArgs.list, token.image);
break;
}
default:
jj_la1[98] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
}
case LPAREN:
{
jj_consume_token(LPAREN);
begin = tokenBegin();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case ABSTRACT:
case BOOLEAN:
case BYTE:
case CHAR:
case DOUBLE:
case FALSE:
case FINAL:
case FLOAT:
case INT:
case LONG:
case NATIVE:
case NEW:
case NULL:
case PRIVATE:
case PROTECTED:
case PUBLIC:
case SHORT:
case STATIC:
case STRICTFP:
case SUPER:
case SYNCHRONIZED:
case THIS:
case TRANSIENT:
case TRUE:
case VOID:
case VOLATILE:
case LONG_LITERAL:
case INTEGER_LITERAL:
case FLOATING_POINT_LITERAL:
case CHARACTER_LITERAL:
case STRING_LITERAL:
case IDENTIFIER:
case LPAREN:
case AT:
case BANG:
case TILDE:
case INCR:
case DECR:
case PLUS:
case MINUS:
{
if (jj_2_27(2147483647)) {
p = FormalParameter();
isLambda = true;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
params = FormalLambdaParameters();
break;
}
default:
jj_la1[99] = jj_gen;
;
}
} 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:
case BANG:
case TILDE:
case INCR:
case DECR:
case PLUS:
case MINUS:
{
ret = Expression();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
params = InferredLambdaParameters();
isLambda = true;
break;
}
default:
jj_la1[100] = jj_gen;
;
}
break;
}
default:
jj_la1[101] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
break;
}
default:
jj_la1[102] = jj_gen;
;
}
jj_consume_token(RPAREN);
if (!isLambda) {
ret = new EnclosedExpr(range(begin, tokenEnd()), ret);
} else {
if (ret != null) {
if (ret instanceof NameExpr) {
id = new VariableDeclaratorId(range(ret.getBegin(), ret.getEnd()), ((NameExpr) ret).getName(), null);
p = new Parameter(range(ret.getBegin(), ret.getEnd()), EnumSet.noneOf(Modifier.class), null, new UnknownType(), null, false, id);
}
}
params = add(0, params, p);
// TODO p may be null here
ret = new LambdaExpr(range(p.getBegin(), tokenEnd()), params, null, true);
}
break;
}
case NEW:
{
ret = AllocationExpression(null);
break;
}
default:
jj_la1[106] = jj_gen;
if (jj_2_28(2147483647)) {
type = ResultType();
jj_consume_token(DOT);
jj_consume_token(CLASS);
ret = new ClassExpr(range(type.getBegin(), tokenEnd()), type);
} else if (jj_2_29(2147483647)) {
type = ResultType();
jj_consume_token(DOUBLECOLON);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LT:
{
typeArgs = TypeArguments();
break;
}
default:
jj_la1[103] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENTIFIER:
{
jj_consume_token(IDENTIFIER);
break;
}
case NEW:
{
jj_consume_token(NEW);
break;
}
default:
jj_la1[104] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
ret = new TypeExpr(type.getRange(), type);
ret = new MethodReferenceExpr(ret.getRange(), ret, typeArgs.list, token.image);
} else {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENTIFIER:
{
name = SimpleName();
begin = tokenBegin();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LPAREN:
{
args = Arguments();
hasArgs = true;
break;
}
default:
jj_la1[105] = jj_gen;
;
}
if (hasArgs) {
MethodCallExpr m = new MethodCallExpr(range(begin, tokenEnd()), null, null, null, args);
m.setNameExpr(name);
ret = m;
} else {
ret = name;
}
break;
}
default:
jj_la1[107] = 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 LabeledStatement.
public final LabeledStmt LabeledStatement() {
String label;
Statement stmt;
Position begin;
jj_consume_token(IDENTIFIER);
begin = tokenBegin();
label = token.image;
jj_consume_token(COLON);
stmt = Statement();
return new LabeledStmt(range(begin, tokenEnd()), label, stmt);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method Modifiers.
/*
* Modifiers. We match all modifiers in a single rule to reduce the chances of
* syntax errors for simple modifier mistakes. It will also enable us to give
* better error messages.
*/
public final ModifierHolder Modifiers() {
Position begin = INVALID;
EnumSet<Modifier> modifiers = EnumSet.noneOf(Modifier.class);
List<AnnotationExpr> annotations = null;
AnnotationExpr ann;
label_3: while (true) {
if (jj_2_2(2)) {
;
} else {
break label_3;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case PUBLIC:
{
jj_consume_token(PUBLIC);
addModifier(modifiers, Modifier.PUBLIC);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case STATIC:
{
jj_consume_token(STATIC);
addModifier(modifiers, Modifier.STATIC);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case PROTECTED:
{
jj_consume_token(PROTECTED);
addModifier(modifiers, Modifier.PROTECTED);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case PRIVATE:
{
jj_consume_token(PRIVATE);
addModifier(modifiers, Modifier.PRIVATE);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case FINAL:
{
jj_consume_token(FINAL);
addModifier(modifiers, Modifier.FINAL);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case ABSTRACT:
{
jj_consume_token(ABSTRACT);
addModifier(modifiers, Modifier.ABSTRACT);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case SYNCHRONIZED:
{
jj_consume_token(SYNCHRONIZED);
addModifier(modifiers, Modifier.SYNCHRONIZED);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case NATIVE:
{
jj_consume_token(NATIVE);
addModifier(modifiers, Modifier.NATIVE);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case TRANSIENT:
{
jj_consume_token(TRANSIENT);
addModifier(modifiers, Modifier.TRANSIENT);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case VOLATILE:
{
jj_consume_token(VOLATILE);
addModifier(modifiers, Modifier.VOLATILE);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case STRICTFP:
{
jj_consume_token(STRICTFP);
addModifier(modifiers, Modifier.STRICTFP);
begin = begin.orIfInvalid(tokenBegin());
break;
}
case AT:
{
ann = Annotation();
annotations = add(annotations, ann);
begin = begin.orIfInvalid(ann.getBegin());
break;
}
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
return new ModifierHolder(begin, modifiers, annotations);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method VariableDeclaratorId.
public final VariableDeclaratorId VariableDeclaratorId() {
String name;
Position begin;
ArrayBracketPair arrayBracketPair;
List<ArrayBracketPair> arrayBracketPairs = null;
jj_consume_token(IDENTIFIER);
name = token.image;
begin = tokenBegin();
label_13: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LBRACKET:
case AT:
{
;
break;
}
default:
jj_la1[33] = jj_gen;
break label_13;
}
arrayBracketPair = ArrayBracketPair();
arrayBracketPairs = add(arrayBracketPairs, arrayBracketPair);
}
return new VariableDeclaratorId(range(begin, tokenEnd()), name, arrayBracketPairs);
}
Aggregations