1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #if defined(__clang__)
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wdeprecated-register"
26 #pragma clang diagnostic ignored "-Wunused-function"
27 #pragma clang diagnostic ignored "-Wunused-variable"
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsign-compare"
31 #pragma GCC diagnostic ignored "-Wunused-function"
32 #pragma GCC diagnostic ignored "-Wunused-variable"
38 #define YYLTYPE CYLocation
39 #include "Cycript.tab.hh"
40 typedef cy::parser::token tk;
42 #include "Highlight.hpp"
44 #define YY_EXTRA_TYPE CYDriver *
46 #define F(value, highlight) do { \
47 yyextra->newline_ = yyextra->last_; \
48 yyextra->last_ = false; \
49 yyextra->next_ = false; \
50 BEGIN(yyextra->template_.top() ? DivOrTemplateTail : Div); \
51 yylval->highlight_ = highlight; \
55 #define P yyextra->pool_
57 #define Y P.strmemdup(yytext, yyleng)
59 #define I(type, Type, value, highlight) do { \
60 yylval->semantic_.type ## _ = A CY ## Type; \
61 F(value, highlight); \
65 if (yyextra->last_ && yyextra->next_) { \
66 yyextra->last_ = false; \
67 F(tk::NewLine, hi::Nothing); \
71 if (const char *nl = reinterpret_cast<const char *>(memchr(yytext, '\n', yyleng))) { \
76 left = yyleng - (nl - yytext) - 1; \
77 nl = reinterpret_cast<const char *>(memchr(nl + 1, '\n', left)); \
78 } while (nl != NULL); \
80 yylloc->end.lines(lines); \
81 yylloc->end.columns(left); \
86 #define R yylloc->end.columns(yyleng);
87 #define L yylloc->step(); R
89 #define H(value, highlight) do { \
90 if (yyextra->highlight_) \
91 F(value, highlight); \
95 H(tk::Comment, hi::Comment);
97 #define E(message) { \
98 CYDriver::Error error; \
99 error.location_ = *yylloc; \
100 error.message_ = "syntax error, " message; \
101 yyextra->errors_.push_back(error); \
106 if (c >= '0' && c <= '9')
108 if (c >= 'a' && c <= 'f')
110 if (c >= 'A' && c <= 'F')
115 template <typename Type_>
116 static void U(Type_ &local, unsigned point) {
118 } else if (point < 0x000080) {
120 } else if (point < 0x000800) {
121 *local++ = 0xc0 | point >> 0x06 & 0x1f;
123 } else if (point < 0x010000) {
124 *local++ = 0xe0 | point >> 0x0c & 0x0f;
126 } else if (point < 0x110000) {
127 *local++ = 0xf0 | point >> 0x12 & 0x07;
128 *local++ = 0x80 | point >> 0x0c & 0x3f;
130 *local++ = 0x80 | point >> 0x06 & 0x3f;
132 *local++ = 0x80 | point >> 0x00 & 0x3f;
133 } else _assert(false);
136 static void U(char *&local, const char *text, yy_size_t &i) {
139 char next(text[++i]);
141 point = X(text[i + 0]) << 12 | X(text[i + 1]) << 8 | X(text[i + 2]) << 4 | X(text[i + 3]);
149 point = (point << 4) | X(next);
156 #define CYLexBufferPoint(point) do { \
157 std::back_insert_iterator<std::vector<char> > inserter(yyextra->buffer_); \
158 U(inserter, point); \
161 #define CYLexBufferUnit(value) do { \
162 yyextra->buffer_.push_back(value); \
165 #define CYLexBufferUnits(data, size) do { \
166 yyextra->buffer_.insert(yyextra->buffer_.end(), data, data + size); \
169 #define CYLexBufferStart(condition) do { \
170 yyextra->buffer_.clear(); \
171 yy_push_state(condition, yyscanner); \
174 #define CYLexBufferEnd(type, Type, value, highlight) do { \
175 yy_pop_state(yyscanner); \
176 I(type, Type(P.strmemdup(yyextra->buffer_.data(), yyextra->buffer_.size()), yyextra->buffer_.size()), value, highlight); \
179 #define YY_INPUT(data, value, size) { \
180 if (yyextra->data_.eof()) \
183 yyextra->data_.read(data, size); \
184 size_t copy(yyextra->data_.gcount()); \
185 value = copy == 0 ? YY_NULL : copy; \
193 %option bison-locations
202 %option never-interactive
215 UN [\xc0-\xc1\xf5-\xff]
218 LineTerminatorSequence \r?\n|\r|\xe2\x80[\xa8\xa9]
219 WhiteSpace [\x09\x0b\x0c\x20]|\xc2\xa0|\xef\xbb\xbf
220 UnicodeEscape \\u({HexDigit}{4}|\{{HexDigit}+\})
222 @include NotLineTerminator.l
223 CommentCharacter [^*/]{-}[\r\n\x80-\xff]|{NotLineTerminator}
224 SingleCharacter [^'\\]{-}[\r\n\x80-\xff]|{NotLineTerminator}
225 DoubleCharacter [^"\\]{-}[\r\n\x80-\xff]|{NotLineTerminator}
226 PlateCharacter [^$`\\]{-}[\r\n\x80-\xff]|{NotLineTerminator}
228 @include UnicodeIDStart.l
229 @include UnicodeIDContinue.l
232 UnicodeStart {IdentifierMore}|{UnicodeIDStart}
233 UnicodePart {IdentifierMore}|\xe2\x80[\x8c\x8d]|{UnicodeIDContinue}
234 UnicodeFail {U2}|{U3}|{U3}{U0}|{U4}|{U4}{U0}|{U4}{U0}{U0}|{UN}|{U0}
235 UnicodeScrap {UnicodePart}*{UnicodeFail}?
237 IdentifierStart {UnicodeStart}|{UnicodeEscape}
238 IdentifierPart {UnicodePart}|{UnicodeEscape}
239 IdentifierFail {UnicodeFail}|\\(u({HexDigit}{0,3}|\{{HexDigit}*))?
240 IdentifierScrap {IdentifierPart}*{IdentifierFail}?
243 BackslashSequence \\{NonTerminator}
244 RegularExpressionFirstChar [^\n*\\/]|{BackslashSequence}
245 RegularExpressionChar [^\n\\/]|{BackslashSequence}
246 RegularExpressionFlags {UnicodePart}*
247 RegularExpressionChars {RegularExpressionChar}*
248 RegularExpressionBody {RegularExpressionFirstChar}{RegularExpressionChars}
251 XMLNameStart [a-zA-Z_:]
252 XMLNamePart [a-zA-Z0-9.-_:]
253 XMLName {XMLNameStart}{XMLNamePart}*
258 %x LegacySingleString
259 %x LegacyDoubleString
261 %x StrictSingleString
262 %x StrictDoubleString
263 %x StrictAccentString
268 %s RegExpOrTemplateTail
278 <RegExp,RegExpOrTemplateTail>{
279 \/{RegularExpressionBody}\/{RegularExpressionFlags} L I(literal, RegEx(Y), tk::RegularExpressionLiteral, hi::Constant);
280 \/{RegularExpressionBody}\/{RegularExpressionFlags}{UnicodeFail} L E("invalid flags")
281 \/{RegularExpressionBody}?\\? L E("unterminated regex")
288 \/\* L yy_push_state(MultiLine, yyscanner);
291 \**\*\/ R yy_pop_state(yyscanner); M N
292 \**{LineTerminatorSequence} yylloc->end.lines(); yyextra->last_ = true;
293 \**{CommentCharacter}|\/ R
294 \**({UnicodeFail}|\*) R E("invalid comment");
295 <<EOF>> R E("invalid comment")
300 <RegExp>"<>" L F(tk::LeftRight, hi::Structure);
301 <XMLContent>"</>" L F(tk::LeftSlashRight, hi::Structure);
303 <RegExp,XMLContent>\<!\[CDATA\[(\n|[^[]|\[[^[]|\[\[[^>])*]]> V() F(tk::XMLCDATA, hi::Constant);
304 <RegExp,XMLContent>\<!--(\n|[^-]|-[^-])*--> V() F(tk::XMLComment, hi::Comment);
305 <RegExp,XMLContent>\<?(\n|[^?]|\?[^>])*?> V() F(tk::XMLPI, hi::Meta);
307 <XMLTag>"=" L F(tk::Equal, hi::Structure);
308 <XMLTag>">" L F(tk::Right, hi::Structure);
309 <XMLTag>"/>" L F(tk::SlashRight, hi::Structure);
310 <XMLTag>"{" L F(tk::OpenBrace, hi::Structure);
312 <XMLTag>\"(\n|[^"])*\"|'(\n|[^'])*' V() F(tk::XMLAttributeValue, hi::Constant);
313 <XMLTag>{XMLName} L F(tk::XMLName, hi::Identifier);
314 <XMLTag>[ \t\r\n] V() F(tk::XMLWhitespace, hi::Nothing);
316 <XMLContent>"{" L F(tk::OpenBrace, hi::Structure);
317 <XMLContent>"<" L F(tk::Left, hi::Structure);
318 <XMLContent>"</" L F(tk::LeftSlash, hi::Structure);
322 "..." L F(tk::PeriodPeriodPeriod, hi::Meta);
323 ".." L E("invalid operator")
326 "::" L F(tk::ColonColon, hi::Operator);
327 ".." L F(tk::PeriodPeriod, hi::Operator);
330 @begin E4X ObjectiveC
331 "@" L F(tk::At, hi::Operator);
332 "#" L F(tk::Pound, hi::Operator);
335 "&" L F(tk::Ampersand, hi::Operator);
336 "&&" L F(tk::AmpersandAmpersand, hi::Operator);
337 "&=" L F(tk::AmpersandEqual, hi::Operator);
338 "^" L F(tk::Carrot, hi::Operator);
339 "^=" L F(tk::CarrotEqual, hi::Operator);
340 "=" L F(tk::Equal, hi::Operator);
341 "==" L F(tk::EqualEqual, hi::Operator);
342 "===" L F(tk::EqualEqualEqual, hi::Operator);
343 "=>" L F(yyextra->newline_ ? tk::EqualRight_ : tk::EqualRight, hi::Operator);
344 "!" L F(tk::Exclamation, hi::Operator);
345 "!=" L F(tk::ExclamationEqual, hi::Operator);
346 "!==" L F(tk::ExclamationEqualEqual, hi::Operator);
347 "-" L F(tk::Hyphen, hi::Operator);
348 "-=" L F(tk::HyphenEqual, hi::Operator);
349 "--" L F(yyextra->newline_ ? tk::HyphenHyphen_ : tk::HyphenHyphen, hi::Operator);
350 "->" L F(tk::HyphenRight, hi::Operator);
351 "<" L F(tk::Left, hi::Operator);
352 "<=" L F(tk::LeftEqual, hi::Operator);
353 "<<" L F(tk::LeftLeft, hi::Operator);
354 "<<=" L F(tk::LeftLeftEqual, hi::Operator);
355 "%" L F(tk::Percent, hi::Operator);
356 "%=" L F(tk::PercentEqual, hi::Operator);
357 "." L F(tk::Period, hi::Operator);
358 "|" L F(tk::Pipe, hi::Operator);
359 "|=" L F(tk::PipeEqual, hi::Operator);
360 "||" L F(tk::PipePipe, hi::Operator);
361 "+" L F(tk::Plus, hi::Operator);
362 "+=" L F(tk::PlusEqual, hi::Operator);
363 "++" L F(yyextra->newline_ ? tk::PlusPlus_ : tk::PlusPlus, hi::Operator);
364 ">" L F(tk::Right, hi::Operator);
365 ">=" L F(tk::RightEqual, hi::Operator);
366 ">>" L F(tk::RightRight, hi::Operator);
367 ">>=" L F(tk::RightRightEqual, hi::Operator);
368 ">>>" L F(tk::RightRightRight, hi::Operator);
369 ">>>=" L F(tk::RightRightRightEqual, hi::Operator);
370 "*" L F(tk::Star, hi::Operator);
371 "*=" L F(tk::StarEqual, hi::Operator);
372 "~" L F(tk::Tilde, hi::Operator);
374 <Div,DivOrTemplateTail>"/" L F(tk::Slash, hi::Operator);
375 <Div,DivOrTemplateTail>"/=" L F(tk::SlashEqual, hi::Operator);
377 ":" L F(tk::Colon, hi::Structure);
378 "," L F(tk::Comma, hi::Structure);
379 "?" L F(tk::Question, hi::Structure);
380 ";" L F(tk::SemiColon, hi::Structure);
382 "(" L F(tk::OpenParen, hi::Structure);
383 ")" L F(tk::CloseParen, hi::Structure);
385 "{" L yyextra->template_.push(false); F(yyextra->newline_ ? tk::OpenBrace_ : tk::OpenBrace, hi::Structure);
386 <Div,RegExp>"}" L yyextra->template_.pop(); F(tk::CloseBrace, hi::Structure);
388 "[" L F(tk::OpenBracket, hi::Structure);
389 "]" L F(tk::CloseBracket, hi::Structure);
392 "@error" L F(tk::At_error_, hi::Error);
395 "@class" L F(tk::At_class_, hi::Meta);
399 "@encode" L F(tk::At_encode_, hi::Meta);
403 "@end" L F(tk::At_end_, hi::Meta);
404 "@false" L F(tk::At_false_, hi::Constant);
405 "@implementation" L F(tk::At_implementation_, hi::Meta);
406 "@import" L F(tk::At_import_, hi::Special);
407 "@NO" L F(tk::At_NO_, hi::Constant);
408 "@null" L F(tk::At_null_, hi::Constant);
409 "@selector" L F(tk::At_selector_, hi::Meta);
410 "@true" L F(tk::At_true_, hi::Constant);
411 "@YES" L F(tk::At_YES_, hi::Constant);
414 @({UnicodeStart}{UnicodeScrap}|{UnicodeFail}) L E("invalid keyword")
417 "undefined" L F(tk::_undefined_, hi::Operator);
420 "bool" L F(tk::_bool_, hi::Type);
421 "BOOL" L F(tk::_BOOL_, hi::Type);
422 "id" L F(tk::_id_, hi::Type);
423 "nil" L F(tk::_nil_, hi::Constant);
424 "NULL" L F(tk::_NULL_, hi::Constant);
425 "SEL" L F(tk::_SEL_, hi::Type);
429 "abstract" L /*FII*/ F(tk::_abstract_, hi::Meta);
430 "await" L /*II?*/ F(tk::_await_, hi::Meta);
431 "boolean" L /*FII*/ F(tk::_boolean_, hi::Type);
432 "break" L /*KKK*/ F(tk::_break_, hi::Control);
433 "byte" L /*FII*/ F(tk::_byte_, hi::Type);
434 "case" L /*KKK*/ F(tk::_case_, hi::Control);
435 "catch" L /*KKK*/ F(tk::_catch_, hi::Control);
436 "char" L /*FII*/ F(tk::_char_, hi::Type);
437 "class" L /*FFK*/ F(tk::_class_, hi::Meta);
438 "const" L /*FFK*/ F(tk::_const_, hi::Meta);
439 "continue" L /*KKK*/ F(tk::_continue_, hi::Control);
440 "debugger" L /*FKK*/ F(tk::_debugger_, hi::Meta);
441 "default" L /*KKK*/ F(tk::_default_, hi::Control);
442 "delete" L /*KKK*/ F(tk::_delete_, hi::Operator);
443 "do" L /*KKK*/ F(tk::_do_, hi::Control);
444 "double" L /*FII*/ F(tk::_double_, hi::Type);
445 "else" L /*KKK*/ F(tk::_else_, hi::Control);
446 "enum" L /*FFF*/ F(tk::_enum_, hi::Meta);
447 "export" L /*FFK*/ F(tk::_export_, hi::Meta);
448 "extends" L /*FFK*/ F(tk::_extends_, hi::Meta);
449 "false" L /*LLL*/ F(tk::_false_, hi::Constant);
450 "final" L /*FII*/ F(tk::_final_, hi::Meta);
451 "finally" L /*KKK*/ F(tk::_finally_, hi::Control);
452 "float" L /*FII*/ F(tk::_float_, hi::Type);
453 "for" L /*KKK*/ F(tk::_for_, hi::Control);
454 "function" L /*KKK*/ F(tk::_function_, hi::Meta);
455 "goto" L /*FII*/ F(tk::_goto_, hi::Control);
456 "if" L /*KKK*/ F(tk::_if_, hi::Control);
457 "implements" L /*FSS*/ F(tk::_implements_, hi::Meta);
458 "import" L /*FFK*/ F(tk::_import_, hi::Meta);
459 "in" L /*KKK*/ F(yyextra->in_.top() ? tk::_in__ : tk::_in_, hi::Operator);
460 "instanceof" L /*KKK*/ F(tk::_instanceof_, hi::Operator);
461 "int" L /*FII*/ F(tk::_int_, hi::Type);
462 "interface" L /*FSS*/ F(tk::_interface_, hi::Meta);
463 "let" L /*IS?*/ F(tk::_let_, hi::Meta);
464 "long" L /*FII*/ F(tk::_long_, hi::Type);
465 "native" L /*FII*/ F(tk::_native_, hi::Meta);
466 "new" L /*KKK*/ F(tk::_new_, hi::Operator);
467 "null" L /*LLL*/ F(tk::_null_, hi::Constant);
468 "package" L /*FSS*/ F(tk::_package_, hi::Meta);
469 "private" L /*FSS*/ F(tk::_private_, hi::Meta);
470 "protected" L /*FSS*/ F(tk::_protected_, hi::Meta);
471 "public" L /*FSS*/ F(tk::_public_, hi::Meta);
472 "return" L /*KKK*/ F(tk::_return_, hi::Control);
473 "short" L /*FII*/ F(tk::_short_, hi::Type);
474 "static" L /*FS?*/ F(tk::_static_, hi::Meta);
475 "super" L /*FFK*/ F(tk::_super_, hi::Constant);
476 "switch" L /*KKK*/ F(tk::_switch_, hi::Control);
477 "synchronized" L /*FII*/ F(tk::_synchronized_, hi::Meta);
478 "this" L /*KKK*/ F(tk::_this_, hi::Constant);
479 "throw" L /*KKK*/ F(tk::_throw_, hi::Control);
480 "throws" L /*FII*/ F(tk::_throws_, hi::Meta);
481 "transient" L /*FII*/ F(tk::_transient_, hi::Meta);
482 "true" L /*LLL*/ F(tk::_true_, hi::Constant);
483 "try" L /*KKK*/ F(tk::_try_, hi::Control);
484 "typeof" L /*KKK*/ F(tk::_typeof_, hi::Operator);
485 "var" L /*KKK*/ F(tk::_var_, hi::Meta);
486 "void" L /*KKK*/ F(tk::_void_, hi::Operator);
487 "volatile" L /*FII*/ F(tk::_volatile_, hi::Meta);
488 "while" L /*KKK*/ F(tk::_while_, hi::Control);
489 "with" L /*KKK*/ F(tk::_with_, hi::Control);
490 "yield" L /*IS?*/ F(tk::_yield_, hi::Control);
492 "auto" L F(tk::_auto_, hi::Meta);
493 "each" L F(tk::_each_, hi::Control);
494 "of" L F(tk::_of_, hi::Operator);
497 "extern" L F(tk::_extern_, hi::Type);
498 "signed" L F(tk::_signed_, hi::Type);
499 "typedef" L F(tk::_typedef_, hi::Meta);
500 "unsigned" L F(tk::_unsigned_, hi::Type);
504 "NO" L F(tk::_NO_, hi::Constant);
505 "YES" L F(tk::_YES_, hi::Constant);
509 "namespace" L F(tk::_namespace_, hi::Meta);
510 "xml" L F(tk::_xml_, hi::Meta);
514 {UnicodeStart}{UnicodePart}* L I(identifier, Identifier(Y), tk::Identifier_, hi::Identifier);
516 {IdentifierStart}{IdentifierPart}* L {
517 char *value(A char[yyleng + 1]);
520 for (yy_size_t i(0), e(yyleng); i != e; ++i) {
521 char next(yytext[i]);
525 U(local, yytext, ++i);
529 I(identifier, Identifier(value), tk::Identifier_, hi::Identifier);
532 ({IdentifierStart}{IdentifierPart}*)?{IdentifierFail} L E("invalid identifier")
535 0[0-7]+ L I(number, Number(strtoull(yytext + 1, NULL, 8)), tk::NumericLiteral, hi::Constant);
536 0[0-9]+ L I(number, Number(strtoull(yytext + 1, NULL, 10)), tk::NumericLiteral, hi::Constant);
538 0[xX][0-9a-fA-F]+ L I(number, Number(strtoull(yytext + 2, NULL, 16)), tk::NumericLiteral, hi::Constant);
539 0[oO][0-7]+ L I(number, Number(strtoull(yytext + 2, NULL, 8)), tk::NumericLiteral, hi::Constant);
540 0[bB][0-1]+ L I(number, Number(strtoull(yytext + 2, NULL, 2)), tk::NumericLiteral, hi::Constant);
542 (\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?)([eE][+-]?[0-9]+)? L I(number, Number(strtod(yytext, NULL)), tk::NumericLiteral, hi::Constant);
543 (\.[0-9]+|(0|[1-9][0-9]*)(\.[0-9]*)?)[eE][+-]?{IdentifierScrap} L E("invalid exponent")
544 (\.?[0-9]|(0|[1-9][0-9]*)\.){IdentifierScrap} L E("invalid number")
547 \' L CYLexBufferStart(LegacySingleString);
548 <LegacySingleString,StrictSingleString>{
549 \' R CYLexBufferEnd(string, String, tk::StringLiteral, hi::Constant);
550 {SingleCharacter}+ R CYLexBufferUnits(yytext, yyleng);
551 {SingleCharacter}*{UnicodeFail} R E("invalid character");
552 {LineTerminatorSequence} R E("invalid newline");
555 \" L CYLexBufferStart(LegacyDoubleString);
556 <LegacyDoubleString,StrictDoubleString>{
557 \" R CYLexBufferEnd(string, String, tk::StringLiteral, hi::Constant);
558 {DoubleCharacter}+ R CYLexBufferUnits(yytext, yyleng);
559 {DoubleCharacter}*{UnicodeFail} R E("invalid character");
560 {LineTerminatorSequence} R E("invalid newline");
564 "`" L yyextra->tail_ = false; CYLexBufferStart(StrictAccentString);
565 <DivOrTemplateTail,RegExpOrTemplateTail>"}" L yyextra->tail_ = true; yyextra->template_.pop(); CYLexBufferStart(StrictAccentString);
567 <StrictAccentString>{
568 "`" R CYLexBufferEnd(string, String, yyextra->tail_ ? tk::TemplateTail : tk::NoSubstitutionTemplate, hi::Constant);
569 "${" R yyextra->template_.push(true); CYLexBufferEnd(string, String, yyextra->tail_ ? tk::TemplateMiddle : tk::TemplateHead, hi::Constant);
571 "$" R CYLexBufferUnit('$');
573 {PlateCharacter}+ R CYLexBufferUnits(yytext, yyleng);
574 {PlateCharacter}*{UnicodeFail} R E("invalid character");
575 {LineTerminatorSequence} R E("invalid newline");
579 <LegacySingleString,LegacyDoubleString>{
580 \\[0-3][0-7][0-7] R CYLexBufferPoint(X(yytext[1]) << 6 | X(yytext[2]) << 3 | X(yytext[3]));
581 \\[0-7][0-7] R CYLexBufferUnit(X(yytext[1]) << 3 | X(yytext[2]));
582 \\[0-7] R CYLexBufferUnit(X(yytext[1]));
585 <StrictSingleString,StrictDoubleString,StrictAccentString>{
586 \\0[0-7] R E("legacy escape");
587 \\0 R CYLexBufferUnit('\0');
590 <LegacySingleString,LegacyDoubleString,StrictSingleString,StrictDoubleString,StrictAccentString>{
591 \\b R CYLexBufferUnit('\b');
592 \\f R CYLexBufferUnit('\f');
593 \\n R CYLexBufferUnit('\n');
594 \\r R CYLexBufferUnit('\r');
595 \\t R CYLexBufferUnit('\t');
596 \\v R CYLexBufferUnit('\v');
598 \\x{HexDigit}{2} R CYLexBufferPoint(X(yytext[2]) << 4 | X(yytext[3]));
600 \\u{HexDigit}{4} R CYLexBufferPoint(X(yytext[2]) << 12 | X(yytext[3]) << 8 | X(yytext[4]) << 4 | X(yytext[5]));
602 \\u\{{HexDigit}+\} R {
604 for (yy_size_t i(3); i != yyleng - 1; ++i)
605 point = point << 4 | X(yytext[i]);
606 CYLexBufferPoint(point);
609 \\{LineTerminatorSequence} yylloc->end.lines();
610 \\(.|{NotLineTerminator}) R CYLexBufferUnits(yytext + 1, yyleng - 1);
612 \\(x{HexDigit}{0,1}|u({HexDigit}{0,3}|\{{HexDigit}*)|{UnicodeFail})? R E("invalid escape");
613 <<EOF>> R E("invalid string");
617 {LineTerminatorSequence} yylloc->step(); yylloc->end.lines(); yyextra->last_ = true; N
620 <<EOF>> if (yyextra->auto_) { yyextra->auto_ = false; F(tk::AutoComplete, hi::Nothing); } L yyterminate();
622 . L E("invalid character")
626 void CYDriver::ScannerInit() {
627 cylex_init(&scanner_);
628 cyset_extra(this, scanner_);
631 void CYDriver::ScannerDestroy() {
632 cylex_destroy(scanner_);
635 void CYDriver::SetCondition(Condition condition) {
636 struct yyguts_t *yyg(reinterpret_cast<struct yyguts_t *>(scanner_));
639 case RegExpCondition:
640 BEGIN(template_.top() ? RegExpOrTemplateTail : RegExp);
643 case XMLContentCondition:
646 case XMLTagCondition:
655 void CYDriver::PushCondition(Condition condition) {
657 case RegExpCondition:
658 yy_push_state(RegExp, scanner_);
661 case XMLContentCondition:
662 yy_push_state(XMLContent, scanner_);
664 case XMLTagCondition:
665 yy_push_state(XMLTag, scanner_);
673 void CYDriver::PopCondition() {
674 yy_pop_state(scanner_);
677 #if defined(__clang__)
678 #pragma clang diagnostic pop
680 // must not pop -Wunused-function
681 //#pragma GCC diagnostic pop