Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/chrome/tools/json_comment_eater.py

Issue 12300042: Update idlsync.py to pull in dependencies required for chrome api generation. (Closed) Base URL: git://github.com/dart-lang/bleeding_edge.git@master
Patch Set: From another checkout Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/chrome/tools/ipc_messages_log.py ('k') | third_party/chrome/tools/json_parse.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """ Utility to remove comments from JSON files so that they can be parsed by
6 json.loads."""
7
8 def _ReadString(input, start, output):
9 output.append('"')
10 in_escape = False
11 for pos in xrange(start, len(input)):
12 output.append(input[pos])
13 if in_escape:
14 in_escape = False
15 else:
16 if input[pos] == '\\':
17 in_escape = True
18 elif input[pos] == '"':
19 return pos + 1
20 return pos
21
22 def _ReadComment(input, start, output):
23 for pos in xrange(start, len(input)):
24 if input[pos] in ['\r', '\n']:
25 output.append(input[pos])
26 return pos + 1
27 return pos
28
29 def Nom(input):
30 output = []
31 pos = 0
32 while pos < len(input):
33 if input[pos] == '"':
34 pos = _ReadString(input, pos + 1, output)
35 elif input[pos:pos+2] == '//':
36 pos = _ReadComment(input, pos + 2, output)
37 else:
38 output.append(input[pos])
39 pos += 1
40 return ''.join(output)
OLDNEW
« no previous file with comments | « third_party/chrome/tools/ipc_messages_log.py ('k') | third_party/chrome/tools/json_parse.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698