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

Unified Diff: sdk/lib/internal/symbol.dart

Issue 140643006: Update documentation on Symbol. Make validation match. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disallow symbols with private parts. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/internal/symbol.dart
diff --git a/sdk/lib/internal/symbol.dart b/sdk/lib/internal/symbol.dart
index 7a0369a9a5686a9b4fb926e632cd3eced29a11cf..5078cd3623f495f58570413f883d1b4c10156865 100644
--- a/sdk/lib/internal/symbol.dart
+++ b/sdk/lib/internal/symbol.dart
@@ -15,28 +15,24 @@ part of dart._internal;
class Symbol implements core.Symbol {
final String _name;
+ // Reserved words are not allowed as identifiers.
+ static const String reservedWord =
+ r'assert|break|c(?:a(?:se|tch)|lass|on(?:st|tinue))|d(?:efault|o)|'
+ r'e(?:lse|num|xtends)|f(?:alse|inal(?:ly)?|or)|i[fns]|n(?:ew|ull)|'
+ r'ret(?:hrow|urn)|s(?:uper|witch)|t(?:h(?:is|row)|r(?:ue|y))|'
+ r'v(?:ar|oid)|w(?:hile|ith)';
+
static final RegExp validationPattern =
- new RegExp(r'^(?:[a-zA-Z$][a-zA-Z$0-9_]*\.)*(?:[a-zA-Z$][a-zA-Z$0-9_]*=?|'
- r'-|'
- r'unary-|'
- r'\[\]=|'
- r'~|'
+ new RegExp(r'^(?:'
+ r'[\-+*/%&|^]|'
+ r'\[\]=?|'
r'==|'
- r'\[\]|'
- r'\*|'
- r'/|'
- r'%|'
- r'~/|'
- r'\+|'
- r'<<|'
- r'>>|'
- r'>=|'
- r'>|'
- r'<=|'
- r'<|'
- r'&|'
- r'\^|'
- r'\|'
+ r'~/?|'
+ r'<[<=]?|'
+ r'>[>=]?|'
+ r'unary-|'
+ r'(?!(?:''$reservedWord'r')\b)[a-zA-Z$][\w$]*'
+ r'(?:=?|(?:\.(?!(?:''$reservedWord'r')\b)[a-zA-Z$][\w$]*)*)'
r')$');
external const Symbol(String name);

Powered by Google App Engine
This is Rietveld 408576698