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

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

Issue 8763001: Fix names with '$' to not conflict with operators or internal helpers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged again Created 9 years 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/parser.dart ('k') | frog/scripts/token_kind_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
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 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. 3 # BSD-style license that can be found in the LICENSE file.
4 4
5 class Token: 5 class Token:
6 def __init__(self, name, text, precedence, customFinishCode=None, 6 def __init__(self, name, text, precedence, customFinishCode=None,
7 stringRepr=None): 7 stringRepr=None):
8 self.name = name 8 self.name = name
9 self.text = text 9 self.text = text
10 self.precedence = precedence 10 self.precedence = precedence
11 self.customFinishCode = customFinishCode 11 self.customFinishCode = customFinishCode
12 12
13 if stringRepr is None: 13 if stringRepr is None:
14 if self.text: 14 if self.text:
15 stringRepr = self.text 15 stringRepr = self.text
16 elif self.name is not None: 16 elif self.name is not None:
17 stringRepr = self.name.lower().replace('_', ' ') 17 stringRepr = self.name.lower().replace('_', ' ')
18 18
19 self.stringRepr = stringRepr 19 self.stringRepr = stringRepr
20 20
21 # roughly the user-definable operators 21 # roughly the user-definable operators
22 EXCLUDES = ['!=', '===', '!==', '&&', '||'] 22 EXCLUDES = ['!=', '===', '!==', '&&', '||']
23 INCLUDES = ['[]', '[]=', '~'] 23 INCLUDES = ['[]', '[]=', '~']
24 if text in INCLUDES or (self.precedence >= 6 and text not in EXCLUDES): 24 if text in INCLUDES or (self.precedence >= 6 and text not in EXCLUDES):
25 self.methodName = '$' + name.lower() 25 self.methodName = ':' + name.lower()
26 else: 26 else:
27 self.methodName = None 27 self.methodName = None
28 28
29 def getFinishCode(self): 29 def getFinishCode(self):
30 if self.customFinishCode: 30 if self.customFinishCode:
31 return self.customFinishCode 31 return self.customFinishCode
32 else: 32 else:
33 return '_finishToken(TokenKind.%s)' % self.name 33 return '_finishToken(TokenKind.%s)' % self.name
34 34
35 35
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 Keyword('SUPER', "super", False), 203 Keyword('SUPER', "super", False),
204 Keyword('SWITCH', "switch", False), 204 Keyword('SWITCH', "switch", False),
205 Keyword('THIS', "this", False), 205 Keyword('THIS', "this", False),
206 Keyword('THROW', "throw", False), 206 Keyword('THROW', "throw", False),
207 Keyword('TRUE', "true", False), 207 Keyword('TRUE', "true", False),
208 Keyword('TYPEDEF', "typedef", True), 208 Keyword('TYPEDEF', "typedef", True),
209 Keyword('TRY', "try", False), 209 Keyword('TRY', "try", False),
210 Keyword('VAR', "var", False), 210 Keyword('VAR', "var", False),
211 Keyword('VOID', "void", False), 211 Keyword('VOID', "void", False),
212 Keyword('WHILE', "while", False)] 212 Keyword('WHILE', "while", False)]
OLDNEW
« no previous file with comments | « frog/parser.dart ('k') | frog/scripts/token_kind_gen.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698