/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2010 Jay Freeman (saurik)
+ * Copyright (C) 2009-2012 Jay Freeman (saurik)
*/
/* GNU Lesser General Public License, Version 3 {{{ */
#define F(value) do { \
int token(value); \
+ yyextra->no_.AtImplementation = false; \
+ yyextra->no_.Function = false; \
+ yyextra->no_.OpenBrace = false; \
return token; \
} while (false)
#define C T yyextra->state_ = CYClear;
#define R T yyextra->state_ = CYRestricted;
-#define E L C I(literal, RegEx(Y), tk::RegularExpressionLiteral);
-
#define N \
if (yyextra->state_ != CYNewLine) { \
if (yyextra->state_ != CYRestricted) \
}
#define YY_INPUT(data, value, size) { \
- if (yyextra->file_ != NULL) { \
- size_t copy(fread(data, 1, size, yyextra->file_)); \
- value = copy == 0 ? YY_NULL : copy; \
- } else if (yyextra->size_ == 0) \
+ if (yyextra->data_.eof()) \
value = YY_NULL; \
else { \
- size_t copy(size); \
- copy = (std::min(copy, yyextra->size_)); \
- memcpy(data, yyextra->data_, copy); \
- yyextra->data_ += copy; \
- yyextra->size_ -= copy; \
- value = copy; \
+ yyextra->data_.read(data, size); \
+ size_t copy(yyextra->data_.gcount()); \
+ value = copy == 0 ? YY_NULL : copy; \
} \
}
%%
-<RegExp>\/{RegularExpressionBody}\/{RegularExpressionFlags} E
+<RegExp>\/{RegularExpressionBody}\/{RegularExpressionFlags} L C I(literal, RegEx(Y), tk::RegularExpressionLiteral);
\/\/[^\n]* L
"(" L C F(tk::OpenParen);
")" L C F(tk::CloseParen);
-"{" L C F(yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace);
+"{" L C F(yyextra->no_.OpenBrace ? tk::OpenBrace__ : yylval->newline_ ? tk::OpenBrace_ : tk::OpenBrace);
"}" L C F(tk::CloseBrace);
"[" L C F(tk::OpenBracket);
@begin ObjectiveC
"@end" L C F(tk::AtEnd);
-"@implementation" L C F(tk::AtImplementation);
+"@implementation" L C F(yyextra->no_.AtImplementation ? tk::AtImplementation_ : tk::AtImplementation);
"@import" L C F(tk::AtImport);
"@selector" L C F(tk::AtSelector);
@end
"null" L C I(null, Null(), tk::Null);
"true" L C I(true, True(), tk::True);
+"auto" L C I(word, Word("auto"), tk::Auto);
"break" L R I(word, Word("break"), tk::Break);
"case" L C I(word, Word("case"), tk::Case);
"catch" L C I(word, Word("catch"), tk::Catch);
"else" L C I(word, Word("else"), tk::Else);
"finally" L C I(word, Word("finally"), tk::Finally);
"for" L C I(word, Word("for"), tk::For);
-"function" L C I(word, Word("function"), tk::Function);
+"function" L C I(word, Word("function"), yyextra->no_.Function ? tk::Function_ : tk::Function);
"if" L C I(word, Word("if"), tk::If);
"in" L C I(word, Word("in"), yyextra->in_.top() ? tk::In_ : tk::In);
"instanceof" L C I(word, Word("instanceof"), tk::InstanceOf);
"yield" L C I(identifier, Identifier("yield"), tk::Yield);
"each" L C I(identifier, Identifier("each"), tk::Each);
+"of" L C I(identifier, Identifier("of"), tk::Of);
@begin E4X
"namespace" L C I(identifier, Identifier("namespace"), tk::Namespace);