summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/json_comment_eater/everything.json9
-rw-r--r--tools/json_comment_eater/everything_expected.json7
-rwxr-xr-xtools/json_comment_eater/json_comment_eater.py7
3 files changed, 21 insertions, 2 deletions
diff --git a/tools/json_comment_eater/everything.json b/tools/json_comment_eater/everything.json
index 31db503..4dc8e45 100644
--- a/tools/json_comment_eater/everything.json
+++ b/tools/json_comment_eater/everything.json
@@ -9,5 +9,12 @@
"escaped\"": "string\"isescaped",
"more//": "\"more",
"so\\many": "\\\\escapes\\\\\"whoa",
- "comment//inmiddle": "of string"
+ "comment//inmiddle": "of string",
+ "comments": "yo", /* Comments all have a /* in them. */
+ "strings": "yes", /* Comment with "strings" and " character */
+ "more/*": "\"more",
+ /* SOMECOMMENT
+ "with": "anything\"" //inside
+ */
+ "and": /*can be anywhere */ "in string"
}
diff --git a/tools/json_comment_eater/everything_expected.json b/tools/json_comment_eater/everything_expected.json
index 3fa02c1..5c6442c 100644
--- a/tools/json_comment_eater/everything_expected.json
+++ b/tools/json_comment_eater/everything_expected.json
@@ -9,5 +9,10 @@
"escaped\"": "string\"isescaped",
"more//": "\"more",
"so\\many": "\\\\escapes\\\\\"whoa",
- "comment//inmiddle": "of string"
+ "comment//inmiddle": "of string",
+ "comments": "yo",
+ "strings": "yes",
+ "more/*": "\"more",
+
+ "and": "in string"
}
diff --git a/tools/json_comment_eater/json_comment_eater.py b/tools/json_comment_eater/json_comment_eater.py
index 93261bf..d61ece2 100755
--- a/tools/json_comment_eater/json_comment_eater.py
+++ b/tools/json_comment_eater/json_comment_eater.py
@@ -50,11 +50,18 @@ def _ReadComment(input, start, output):
output.append(eol_token)
return eol_token_index + len(eol_token)
+def _ReadMultilineComment(input, start, output):
+ end_tokens = ('*/',)
+ end_token_index, end_token = _FindNextToken(input, end_tokens, start)
+ if end_token is None:
+ raise Exception("Multiline comment end token (*/) not found")
+ return end_token_index + len(end_token)
def Nom(input):
token_actions = {
'"': _ReadString,
'//': _ReadComment,
+ '/*': _ReadMultilineComment,
}
output = []
pos = 0