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

Side by Side Diff: frog/scripts/codegen.py

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « frog/scripts/bootstrap/frogc.bat ('k') | frog/scripts/corejs_gen.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 Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file.
4
5 # TODO(jimhug): Move this and other gen files into Dart.
6
7 HEADER = '''// Copyright (c) 2012, the Dart project authors. Please see the AUT HORS file
8 // for details. All rights reserved. Use of this source code is governed by a
9 // BSD-style license that can be found in the LICENSE file.
10 // Generated by %s.
11
12 '''
13
14 EXT = '.g.dart'
15
16 class CodeWriter:
17 '''Helper class for generating source code. The main purpose right now
18 is to keep track of indentation for pretty printing. In the future
19 much more could be added here - but I'd rather wait until we can write
20 this directly in Dart.
21 '''
22 def __init__(self, genfile):
23 self._text = []
24 self._indent = 0
25 self._genfile = genfile
26
27 def enterBlock(self, text=None):
28 if text is not None: self.writeln(text)
29 self._indent += 1
30
31 def exitBlock(self, text=None):
32 assert self._indent > 0
33 self._indent -= 1
34 if text is not None: self.writeln(text)
35
36 def writeIndent(self):
37 self._text.append(' ' * self._indent)
38
39 def writeln(self, s=None, *args):
40 if not s:
41 self._text.append('\n')
42 return
43
44 self.writeIndent()
45 if args:
46 self._text.append(s % args)
47 else:
48 self._text.append(s)
49 self._text.append('\n')
50
51 def __str__(self):
52 return ''.join(self._text)
53
54 def writeToFile(self, filename):
55 with open(filename + EXT, 'w') as f:
56 f.write(HEADER % self._genfile)
57 for line in self._text:
58 f.write(line)
OLDNEW
« no previous file with comments | « frog/scripts/bootstrap/frogc.bat ('k') | frog/scripts/corejs_gen.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698