diff --git a/javascript/extractor/src/com/semmle/js/parser/JSONParser.java b/javascript/extractor/src/com/semmle/js/parser/JSONParser.java index 2e7f7a96b5f..58f28644870 100644 --- a/javascript/extractor/src/com/semmle/js/parser/JSONParser.java +++ b/javascript/extractor/src/com/semmle/js/parser/JSONParser.java @@ -21,6 +21,7 @@ import com.semmle.util.exception.Exceptions; import com.semmle.util.io.WholeIO; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -32,7 +33,6 @@ public class JSONParser { private int offset; private int length; private String src; - private List recoverableErrors; public static Pair> parseValue(String json) throws ParseError { JSONParser parser = new JSONParser(json); @@ -41,14 +41,13 @@ public class JSONParser { parser.consumeWhitespace(); if (parser.offset < parser.length) parser.raise("Expected end of input"); - return Pair.make(value, parser.recoverableErrors); + return Pair.make(value, Collections.emptyList()); } private JSONParser(String json) throws ParseError { this.line = 1; this.column = 0; this.offset = 0; - this.recoverableErrors = new ArrayList(); if (json == null) raise("Input string may not be null"); this.length = json.length(); @@ -351,17 +350,16 @@ public class JSONParser { } } - /** Skips the line comment starting at the current position and records a recoverable error. */ + /** Skips the line comment starting at the current position. */ private void skipLineComment() throws ParseError { Position pos = new Position(line, column, offset); char c; next(); next(); while ((c = peek()) != '\r' && c != '\n' && c != -1) next(); - recoverableErrors.add(new ParseError("Comments are not legal in JSON.", pos)); } - /** Skips the block comment starting at the current position and records a recoverable error. */ + /** Skips the block comment starting at the current position. */ private void skipBlockComment() throws ParseError { Position pos = new Position(line, column, offset); char c; @@ -376,7 +374,6 @@ public class JSONParser { break; } } while (true); - recoverableErrors.add(new ParseError("Comments are not legal in JSON.", pos)); } private void consume(char token) throws ParseError { diff --git a/javascript/extractor/tests/json/output/trap/comments.json.trap b/javascript/extractor/tests/json/output/trap/comments.json.trap index 320a172e3df..4d697f469a1 100644 --- a/javascript/extractor/tests/json/output/trap/comments.json.trap +++ b/javascript/extractor/tests/json/output/trap/comments.json.trap @@ -18,15 +18,5 @@ locations_default(#20003,#10000,3,12,3,18) json_locations(#20002,#20003) json_literals("world","""world""",#20002) json_properties(#20000,"hello",#20002) -#20004=* -json_errors(#20004,"Error: Comments are not legal in JSON.") -#20005=@"loc,{#10000},2,3,2,3" -locations_default(#20005,#10000,2,3,2,3) -json_locations(#20004,#20005) -#20006=* -json_errors(#20006,"Error: Comments are not legal in JSON.") -#20007=@"loc,{#10000},4,3,4,3" -locations_default(#20007,#10000,4,3,4,3) -json_locations(#20006,#20007) numlines(#10000,5,0,0) filetype(#10000,"json")