use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseSpreadExpression.
private SpreadExpressionTree parseSpreadExpression() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.SPREAD);
ParseTree operand = parseAssignmentExpression();
return new SpreadExpressionTree(getTreeLocation(start), operand);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseInterfaceDeclaration.
private ParseTree parseInterfaceDeclaration() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.INTERFACE);
IdentifierToken name = eatId();
GenericTypeListTree generics = maybeParseGenericTypes();
ImmutableList.Builder<ParseTree> superTypes = ImmutableList.builder();
if (peek(TokenType.EXTENDS)) {
eat(TokenType.EXTENDS);
ParseTree type = parseType();
superTypes.add(type);
while (peek(TokenType.COMMA)) {
eat(TokenType.COMMA);
type = parseType();
if (type != null) {
superTypes.add(type);
}
}
}
eat(TokenType.OPEN_CURLY);
ImmutableList<ParseTree> elements = parseInterfaceElements();
eat(TokenType.CLOSE_CURLY);
return new InterfaceDeclarationTree(getTreeLocation(start), name, generics, superTypes.build(), elements);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseTypeName.
private TypeNameTree parseTypeName() {
SourcePosition start = getTreeStartLocation();
// for 'void'.
IdentifierToken token = eatIdOrKeywordAsId();
return new TypeNameTree(getTreeLocation(start), buildIdentifierPath(token));
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseNamespaceDeclaration.
private NamespaceDeclarationTree parseNamespaceDeclaration(boolean isAmbient) {
SourcePosition start = getTreeStartLocation();
if (eatOpt(TokenType.MODULE) == null) {
// Accept "module" or "namespace"
eat(TokenType.NAMESPACE);
}
NamespaceNameTree name = parseNamespaceName();
eat(TokenType.OPEN_CURLY);
ImmutableList<ParseTree> elements = isAmbient ? parseAmbientNamespaceElements() : parseNamespaceElements();
eat(TokenType.CLOSE_CURLY);
return new NamespaceDeclarationTree(getTreeLocation(start), name, elements);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseTypeQuery.
private ParseTree parseTypeQuery() {
SourcePosition start = getTreeStartLocation();
if (peek(TokenType.TYPEOF)) {
eat(TokenType.TYPEOF);
IdentifierToken token = eatId();
ImmutableList.Builder<String> identifiers = ImmutableList.builder();
if (token != null) {
identifiers.add(token.value);
}
while (peek(TokenType.PERIOD)) {
// TypeQueryExpression . IdentifierName
eat(TokenType.PERIOD);
token = eatId();
if (token == null) {
break;
}
identifiers.add(token.value);
}
return new TypeQueryTree(getTreeLocation(start), identifiers.build());
} else {
return parseTypeReference();
}
}
Aggregations