use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method SynchronizedStatement.
public final SynchronizedStmt SynchronizedStatement() {
Expression expr;
BlockStmt block;
Position begin;
jj_consume_token(SYNCHRONIZED);
begin = tokenBegin();
jj_consume_token(LPAREN);
expr = Expression();
jj_consume_token(RPAREN);
block = Block();
return new SynchronizedStmt(range(begin, tokenEnd()), expr, block);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method MemberValuePair.
public final MemberValuePair MemberValuePair() {
String name;
Expression value;
Position begin;
jj_consume_token(IDENTIFIER);
name = token.image;
begin = tokenBegin();
jj_consume_token(ASSIGN);
value = MemberValue();
return new MemberValuePair(range(begin, tokenEnd()), name, value);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method CompilationUnit.
/**
***************************************
* THE JAVA LANGUAGE GRAMMAR STARTS HERE *
****************************************
*/
/*
* Program structuring syntax follows.
*/
public final CompilationUnit CompilationUnit() {
PackageDeclaration pakage = null;
List<ImportDeclaration> imports = null;
ImportDeclaration in = null;
List<TypeDeclaration<?>> types = null;
TypeDeclaration tn = null;
Position begin = INVALID;
if (jj_2_1(2147483647)) {
pakage = PackageDeclaration();
begin = begin.orIfInvalid(pakage.getBegin());
} else {
;
}
label_1: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IMPORT:
case SEMICOLON:
{
;
break;
}
default:
jj_la1[0] = jj_gen;
break label_1;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IMPORT:
{
in = ImportDeclaration();
begin = begin.orIfInvalid(in.getBegin());
imports = add(imports, in);
break;
}
case SEMICOLON:
{
in = EmptyImportDeclaration();
begin = begin.orIfInvalid(in.getBegin());
imports = add(imports, in);
break;
}
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
label_2: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case ABSTRACT:
case CLASS:
case ENUM:
case FINAL:
case INTERFACE:
case NATIVE:
case PRIVATE:
case PROTECTED:
case PUBLIC:
case STATIC:
case STRICTFP:
case SYNCHRONIZED:
case TRANSIENT:
case VOLATILE:
case SEMICOLON:
case AT:
{
;
break;
}
default:
jj_la1[2] = jj_gen;
break label_2;
}
tn = TypeDeclaration();
begin = begin.orIfInvalid(tn.getBegin());
types = add(types, tn);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case 0:
{
jj_consume_token(0);
break;
}
case 156:
{
jj_consume_token(156);
break;
}
default:
jj_la1[3] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
return new CompilationUnit(begin.invalid() ? Range.UNKNOWN : range(begin, tokenEnd()), pakage, imports, types);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method BreakStatement.
public final BreakStmt BreakStatement() {
String id = null;
Position begin;
jj_consume_token(BREAK);
begin = tokenBegin();
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENTIFIER:
{
jj_consume_token(IDENTIFIER);
id = token.image;
break;
}
default:
jj_la1[142] = jj_gen;
;
}
jj_consume_token(SEMICOLON);
return new BreakStmt(range(begin, tokenEnd()), id);
}
use of com.github.javaparser.Position in project javaparser by javaparser.
the class ASTParser method MethodDeclaration.
public final MethodDeclaration MethodDeclaration(ModifierHolder modifier) {
RangedList<TypeParameter> typeParameters = new RangedList<TypeParameter>(null);
Type type;
NameExpr name;
List<Parameter> parameters;
ArrayBracketPair arrayBracketPair;
List<ArrayBracketPair> arrayBracketPairs = null;
List<ReferenceType> throws_ = null;
BlockStmt block = null;
Position begin = modifier.begin;
ReferenceType throwType;
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LT:
{
typeParameters = TypeParameters();
begin = begin.orIfInvalid(typeParameters.range.begin);
break;
}
default:
jj_la1[37] = jj_gen;
;
}
type = ResultType();
begin = begin.orIfInvalid(type.getBegin());
name = Name();
parameters = FormalParameters();
label_15: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LBRACKET:
case AT:
{
;
break;
}
default:
jj_la1[38] = jj_gen;
break label_15;
}
arrayBracketPair = ArrayBracketPair();
arrayBracketPairs = add(arrayBracketPairs, arrayBracketPair);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case THROWS:
{
jj_consume_token(THROWS);
throwType = ReferenceTypeWithAnnotations();
throws_ = add(throws_, throwType);
label_16: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COMMA:
{
;
break;
}
default:
jj_la1[39] = jj_gen;
break label_16;
}
jj_consume_token(COMMA);
throwType = ReferenceTypeWithAnnotations();
throws_ = add(throws_, throwType);
}
break;
}
default:
jj_la1[40] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case LBRACE:
{
block = Block();
break;
}
case SEMICOLON:
{
jj_consume_token(SEMICOLON);
break;
}
default:
jj_la1[41] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
Pair<Type, List<ArrayBracketPair>> typeListPair = unwrapArrayTypes(type);
return new MethodDeclaration(range(begin, pos(token.endLine, token.endColumn)), modifier.modifiers, modifier.annotations, typeParameters.list, typeListPair.a, typeListPair.b, name, parameters, arrayBracketPairs, throws_, block);
}
Aggregations