-void CYString::Output(std::ostream &out, CYFlags flags) const {
- out << '\"';
- for (const char *value(value_), *end(value_ + size_); value != end; ++value)
- switch (*value) {
- case '"': out << "\\\""; break;
- case '\\': out << "\\\\"; break;
- case '\b': out << "\\b"; break;
- case '\f': out << "\\f"; break;
- case '\n': out << "\\n"; break;
- case '\r': out << "\\r"; break;
- case '\t': out << "\\t"; break;
- case '\v': out << "\\v"; break;
-
- default:
- if (*value < 0x20 || *value >= 0x7f)
- out << "\\x" << std::setbase(16) << std::setw(2) << std::setfill('0') << unsigned(*value);
- else
- out << *value;
- }
- out << '\"';
+void CYString::PropertyName(CYOutput &out) const {
+ if (const char *word = Word())
+ out << word;
+ else
+ out << *this;
+}
+
+static const char *Reserved_[] = {
+ "false", "null", "true",
+
+ "break", "case", "catch", "continue", "default",
+ "delete", "do", "else", "finally", "for", "function",
+ "if", "in", "instanceof", "new", "return", "switch",
+ "this", "throw", "try", "typeof", "var", "void",
+ "while", "with",
+
+ "debugger", "const",
+
+ "class", "enum", "export", "extends", "import", "super",
+
+ "abstract", "boolean", "byte", "char", "double", "final",
+ "float", "goto", "int", "long", "native", "short",
+ "synchronized", "throws", "transient", "volatile",
+
+ "let", "yield",
+
+ NULL
+};
+
+const char *CYString::Word() const {
+ if (size_ == 0 || !WordStartRange_[value_[0]])
+ return NULL;
+ for (size_t i(1); i != size_; ++i)
+ if (!WordEndRange_[value_[i]])
+ return NULL;
+ const char *value(Value());
+ for (const char **reserved(Reserved_); *reserved != NULL; ++reserved)
+ if (strcmp(*reserved, value) == 0)
+ return NULL;
+ return value;