Adding checks for unexpected tokens in parser

This commit is contained in:
Christoph Büscher 2015-12-08 15:50:44 +01:00
parent c57672c9b3
commit 9ea18fc576
1 changed files with 4 additions and 0 deletions

View File

@ -278,6 +278,8 @@ public class HighlightBuilder extends AbstractHighlighterBuilder<HighlightBuilde
} else {
throw new ParsingException(parser.getTokenLocation(), "cannot parse object with name [{}]", topLevelFieldName);
}
} else if (topLevelFieldName != null) {
throw new ParsingException(parser.getTokenLocation(), "unexpected token [{}] after [{}]", token, topLevelFieldName);
}
}
@ -482,6 +484,8 @@ public class HighlightBuilder extends AbstractHighlighterBuilder<HighlightBuilde
} else {
throw new ParsingException(parser.getTokenLocation(), "cannot parse object with name [{}]", currentFieldName);
}
} else if (currentFieldName != null) {
throw new ParsingException(parser.getTokenLocation(), "unexpected token [{}] after [{}]", token, currentFieldName);
}
}
return field;