From 09e4db6773d6734c8c6e4de86fba0a0e4540b9aa Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 29 Nov 2015 10:53:01 +0000 Subject: [PATCH] Attempt to make all the identifiers look the same. --- Cycript.l.in | 186 ++++++++++++++++++++++----------------------- Cycript.yy.in | 207 +++++++++++++++++++++++++++----------------------- 2 files changed, 207 insertions(+), 186 deletions(-) diff --git a/Cycript.l.in b/Cycript.l.in index ea542c5..6398f35 100644 --- a/Cycript.l.in +++ b/Cycript.l.in @@ -361,125 +361,125 @@ XMLName {XMLNameStart}{XMLNamePart}* "]" L C F(tk::CloseBracket, hi::Structure); /* }}} */ /* Keyword {{{ */ -"@error" L C F(tk::AtError, hi::Error); +"@error" L C F(tk::At_error_, hi::Error); @begin Java -"@class" L C F(tk::AtClass, hi::Meta); +"@class" L C F(tk::At_class_, hi::Meta); @end @begin C -"@encode" L C F(tk::AtEncode, hi::Meta); +"@encode" L C F(tk::At_encode_, hi::Meta); @end @begin ObjectiveC -"@end" L C F(tk::AtEnd, hi::Meta); -"@false" L C F(tk::AtFalse, hi::Constant); -"@implementation" L C F(yyextra->no_.AtImplementation ? tk::AtImplementation_ : tk::AtImplementation, hi::Meta); -"@import" L C F(tk::AtImport, hi::Special); -"@NO" L C F(tk::AtNo, hi::Constant); -"@null" L C F(tk::AtNull, hi::Constant); -"@selector" L C F(tk::AtSelector, hi::Meta); -"@true" L C F(tk::AtTrue, hi::Constant); -"@YES" L C F(tk::AtYes, hi::Constant); +"@end" L C F(tk::At_end_, hi::Meta); +"@false" L C F(tk::At_false_, hi::Constant); +"@implementation" L C F(yyextra->no_.AtImplementation ? tk::At_implementation__ : tk::At_implementation_, hi::Meta); +"@import" L C F(tk::At_import_, hi::Special); +"@NO" L C F(tk::At_NO_, hi::Constant); +"@null" L C F(tk::At_null_, hi::Constant); +"@selector" L C F(tk::At_selector_, hi::Meta); +"@true" L C F(tk::At_true_, hi::Constant); +"@YES" L C F(tk::At_YES_, hi::Constant); @end @({UnicodeStart}{UnicodeScrap}|{UnicodeFail}) L E("invalid keyword") /* }}} */ /* Highlight {{{ */ -"undefined" L C I(identifier, Identifier("undefined"), tk::Identifier_, hi::Operator); +"undefined" L C F(tk::_undefined_, hi::Operator); @begin ObjectiveC -"bool" L C I(identifier, Identifier("bool"), tk::Identifier_, hi::Type); -"BOOL" L C I(identifier, Identifier("BOOL"), tk::Identifier_, hi::Type); -"id" L C I(identifier, Identifier("id"), tk::Identifier_, hi::Type); -"nil" L C I(identifier, Identifier("nil"), tk::Identifier_, hi::Constant); -"NULL" L C I(identifier, Identifier("NULL"), tk::Identifier_, hi::Constant); -"SEL" L C I(identifier, Identifier("SEL"), tk::Identifier_, hi::Type); +"bool" L C F(tk::_bool_, hi::Type); +"BOOL" L C F(tk::_BOOL_, hi::Type); +"id" L C F(tk::_id_, hi::Type); +"nil" L C F(tk::_nil_, hi::Constant); +"NULL" L C F(tk::_NULL_, hi::Constant); +"SEL" L C F(tk::_SEL_, hi::Type); @end /* }}} */ /* Reserved {{{ */ -"abstract" L C /*FII*/ F(tk::Abstract, hi::Meta); -"await" L C /*II?*/ F(tk::Await, hi::Meta); -"boolean" L C /*FII*/ F(tk::Boolean, hi::Type); -"break" L R /*KKK*/ F(tk::Break, hi::Control); -"byte" L C /*FII*/ F(tk::Byte, hi::Type); -"case" L C /*KKK*/ F(tk::Case, hi::Control); -"catch" L C /*KKK*/ F(tk::Catch, hi::Control); -"char" L C /*FII*/ F(tk::Char, hi::Type); -"class" L C /*FFK*/ F(tk::Class, hi::Meta); -"const" L C /*FFK*/ F(tk::Const, hi::Meta); -"continue" L R /*KKK*/ F(tk::Continue, hi::Control); -"debugger" L C /*FKK*/ F(tk::Debugger, hi::Meta); -"default" L C /*KKK*/ F(tk::Default, hi::Control); -"delete" L C /*KKK*/ F(tk::Delete, hi::Operator); -"do" L C /*KKK*/ F(tk::Do, hi::Control); -"double" L C /*FII*/ F(tk::Double, hi::Type); -"else" L C /*KKK*/ F(tk::Else, hi::Control); -"enum" L C /*FFF*/ F(tk::Enum, hi::Meta); -"export" L C /*FFK*/ F(tk::Export, hi::Meta); -"extends" L C /*FFK*/ F(tk::Extends, hi::Meta); -"false" L C /*LLL*/ F(tk::False, hi::Constant); -"final" L C /*FII*/ F(tk::Final, hi::Meta); -"finally" L C /*KKK*/ F(tk::Finally, hi::Control); -"float" L C /*FII*/ F(tk::Float, hi::Type); -"for" L C /*KKK*/ F(tk::For, hi::Control); -"function" L C /*KKK*/ F(yyextra->no_.Function ? tk::Function_ : tk::Function, hi::Meta); -"goto" L C /*FII*/ F(tk::Goto, hi::Control); -"if" L C /*KKK*/ F(tk::If, hi::Control); -"implements" L C /*FSS*/ F(tk::Implements, hi::Meta); -"import" L C /*FFK*/ F(tk::Import, hi::Meta); -"in" L C /*KKK*/ F(yyextra->in_.top() ? tk::In_ : tk::In, hi::Operator); -"instanceof" L C /*KKK*/ F(tk::InstanceOf, hi::Operator); -"int" L C /*FII*/ F(tk::Int, hi::Type); -"interface" L C /*FSS*/ F(tk::Interface, hi::Meta); -"let" L C /*IS?*/ F(tk::Let, hi::Meta); -"long" L C /*FII*/ F(tk::Long, hi::Type); -"native" L C /*FII*/ F(tk::Native, hi::Meta); -"new" L C /*KKK*/ F(tk::New, hi::Operator); -"null" L C /*LLL*/ F(tk::Null, hi::Constant); -"package" L C /*FSS*/ F(tk::Package, hi::Meta); -"private" L C /*FSS*/ F(tk::Private, hi::Meta); -"protected" L C /*FSS*/ F(tk::Protected, hi::Meta); -"public" L C /*FSS*/ F(tk::Public, hi::Meta); -"return" L R /*KKK*/ F(tk::Return, hi::Control); -"short" L C /*FII*/ F(tk::Short, hi::Type); -"static" L C /*FS?*/ F(tk::Static, hi::Meta); -"super" L C /*FFK*/ F(tk::Super, hi::Constant); -"switch" L C /*KKK*/ F(tk::Switch, hi::Control); -"synchronized" L C /*FII*/ F(tk::Synchronized, hi::Meta); -"this" L C /*KKK*/ F(tk::This, hi::Constant); -"throw" L R /*KKK*/ F(tk::Throw, hi::Control); -"throws" L C /*FII*/ F(tk::Throws, hi::Meta); -"transient" L C /*FII*/ F(tk::Transient, hi::Meta); -"true" L C /*LLL*/ F(tk::True, hi::Constant); -"try" L C /*KKK*/ F(tk::Try, hi::Control); -"typeof" L C /*KKK*/ F(tk::TypeOf, hi::Operator); -"var" L C /*KKK*/ F(tk::Var, hi::Meta); -"void" L C /*KKK*/ F(tk::Void, hi::Operator); -"volatile" L C /*FII*/ F(tk::Volatile, hi::Meta); -"while" L C /*KKK*/ F(tk::While, hi::Control); -"with" L C /*KKK*/ F(tk::With, hi::Control); -"yield" L R /*IS?*/ F(tk::Yield, hi::Control); - -"auto" L C F(tk::Auto, hi::Meta); -"each" L C F(tk::Each, hi::Control); -"of" L C F(tk::Of, hi::Operator); +"abstract" L C /*FII*/ F(tk::_abstract_, hi::Meta); +"await" L C /*II?*/ F(tk::_await_, hi::Meta); +"boolean" L C /*FII*/ F(tk::_boolean_, hi::Type); +"break" L R /*KKK*/ F(tk::_break_, hi::Control); +"byte" L C /*FII*/ F(tk::_byte_, hi::Type); +"case" L C /*KKK*/ F(tk::_case_, hi::Control); +"catch" L C /*KKK*/ F(tk::_catch_, hi::Control); +"char" L C /*FII*/ F(tk::_char_, hi::Type); +"class" L C /*FFK*/ F(tk::_class_, hi::Meta); +"const" L C /*FFK*/ F(tk::_const_, hi::Meta); +"continue" L R /*KKK*/ F(tk::_continue_, hi::Control); +"debugger" L C /*FKK*/ F(tk::_debugger_, hi::Meta); +"default" L C /*KKK*/ F(tk::_default_, hi::Control); +"delete" L C /*KKK*/ F(tk::_delete_, hi::Operator); +"do" L C /*KKK*/ F(tk::_do_, hi::Control); +"double" L C /*FII*/ F(tk::_double_, hi::Type); +"else" L C /*KKK*/ F(tk::_else_, hi::Control); +"enum" L C /*FFF*/ F(tk::_enum_, hi::Meta); +"export" L C /*FFK*/ F(tk::_export_, hi::Meta); +"extends" L C /*FFK*/ F(tk::_extends_, hi::Meta); +"false" L C /*LLL*/ F(tk::_false_, hi::Constant); +"final" L C /*FII*/ F(tk::_final_, hi::Meta); +"finally" L C /*KKK*/ F(tk::_finally_, hi::Control); +"float" L C /*FII*/ F(tk::_float_, hi::Type); +"for" L C /*KKK*/ F(tk::_for_, hi::Control); +"function" L C /*KKK*/ F(yyextra->no_.Function ? tk::_function__ : tk::_function_, hi::Meta); +"goto" L C /*FII*/ F(tk::_goto_, hi::Control); +"if" L C /*KKK*/ F(tk::_if_, hi::Control); +"implements" L C /*FSS*/ F(tk::_implements_, hi::Meta); +"import" L C /*FFK*/ F(tk::_import_, hi::Meta); +"in" L C /*KKK*/ F(yyextra->in_.top() ? tk::_in__ : tk::_in_, hi::Operator); +"instanceof" L C /*KKK*/ F(tk::_instanceof_, hi::Operator); +"int" L C /*FII*/ F(tk::_int_, hi::Type); +"interface" L C /*FSS*/ F(tk::_interface_, hi::Meta); +"let" L C /*IS?*/ F(tk::_let_, hi::Meta); +"long" L C /*FII*/ F(tk::_long_, hi::Type); +"native" L C /*FII*/ F(tk::_native_, hi::Meta); +"new" L C /*KKK*/ F(tk::_new_, hi::Operator); +"null" L C /*LLL*/ F(tk::_null_, hi::Constant); +"package" L C /*FSS*/ F(tk::_package_, hi::Meta); +"private" L C /*FSS*/ F(tk::_private_, hi::Meta); +"protected" L C /*FSS*/ F(tk::_protected_, hi::Meta); +"public" L C /*FSS*/ F(tk::_public_, hi::Meta); +"return" L R /*KKK*/ F(tk::_return_, hi::Control); +"short" L C /*FII*/ F(tk::_short_, hi::Type); +"static" L C /*FS?*/ F(tk::_static_, hi::Meta); +"super" L C /*FFK*/ F(tk::_super_, hi::Constant); +"switch" L C /*KKK*/ F(tk::_switch_, hi::Control); +"synchronized" L C /*FII*/ F(tk::_synchronized_, hi::Meta); +"this" L C /*KKK*/ F(tk::_this_, hi::Constant); +"throw" L R /*KKK*/ F(tk::_throw_, hi::Control); +"throws" L C /*FII*/ F(tk::_throws_, hi::Meta); +"transient" L C /*FII*/ F(tk::_transient_, hi::Meta); +"true" L C /*LLL*/ F(tk::_true_, hi::Constant); +"try" L C /*KKK*/ F(tk::_try_, hi::Control); +"typeof" L C /*KKK*/ F(tk::_typeof_, hi::Operator); +"var" L C /*KKK*/ F(tk::_var_, hi::Meta); +"void" L C /*KKK*/ F(tk::_void_, hi::Operator); +"volatile" L C /*FII*/ F(tk::_volatile_, hi::Meta); +"while" L C /*KKK*/ F(tk::_while_, hi::Control); +"with" L C /*KKK*/ F(tk::_with_, hi::Control); +"yield" L R /*IS?*/ F(tk::_yield_, hi::Control); + +"auto" L C F(tk::_auto_, hi::Meta); +"each" L C F(tk::_each_, hi::Control); +"of" L C F(tk::_of_, hi::Operator); @begin C -"extern" L C F(tk::Extern, hi::Type); -"signed" L C F(tk::Signed, hi::Type); -"typedef" L C F(tk::Typedef, hi::Meta); -"unsigned" L C F(tk::Unsigned, hi::Type); +"extern" L C F(tk::_extern_, hi::Type); +"signed" L C F(tk::_signed_, hi::Type); +"typedef" L C F(tk::_typedef_, hi::Meta); +"unsigned" L C F(tk::_unsigned_, hi::Type); @end @begin ObjectiveC -"NO" L C F(tk::No, hi::Constant); -"YES" L C F(tk::Yes, hi::Constant); +"NO" L C F(tk::_NO_, hi::Constant); +"YES" L C F(tk::_YES_, hi::Constant); @end @begin E4X -"namespace" L C F(tk::Namespace, hi::Meta); -"xml" L C F(tk::XML, hi::Meta); +"namespace" L C F(tk::_namespace_, hi::Meta); +"xml" L C F(tk::_xml_, hi::Meta); @end /* }}} */ /* Identifier {{{ */ diff --git a/Cycript.yy.in b/Cycript.yy.in index bb5f963..3e219cf 100644 --- a/Cycript.yy.in +++ b/Cycript.yy.in @@ -226,112 +226,123 @@ int cylex(YYSTYPE *, CYLocation *, void *); %token OpenBracket "[" %token CloseBracket "]" -%token AtError "@error" +%token At_error_ "@error" @begin Java -%token AtClass "@class" +%token At_class_ "@class" @end @begin C -%token Typedef "typedef" -%token Unsigned "unsigned" -%token Signed "signed" -%token Extern "extern" +%token _typedef_ "typedef" +%token _unsigned_ "unsigned" +%token _signed_ "signed" +%token _extern_ "extern" @end @begin C -%token AtEncode "@encode" +%token At_encode_ "@encode" @end @begin ObjectiveC -%token AtImplementation "@implementation" -%token AtImplementation_ ";@implementation" -%token AtImport "@import" -%token AtEnd "@end" -%token AtSelector "@selector" -%token AtNull "@null" -%token AtYes "@YES" -%token AtNo "@NO" -%token AtTrue "@true" -%token AtFalse "@false" -%token Yes "YES" -%token No "NO" +%token At_implementation_ "@implementation" +%token At_implementation__ ";@implementation" +%token At_import_ "@import" +%token At_end_ "@end" +%token At_selector_ "@selector" +%token At_null_ "@null" +%token At_YES_ "@YES" +%token At_NO_ "@NO" +%token At_true_ "@true" +%token At_false_ "@false" +%token _YES_ "YES" +%token _NO_ "NO" @end -%token False "false" -%token Null "null" -%token True "true" - -%token Break "break" -%token Case "case" -%token Catch "catch" -%token Class "class" -%token Const "const" -%token Continue "continue" -%token Debugger "debugger" -%token Default "default" -%token Delete "delete" -%token Do "do" -%token Else "else" -%token Enum "enum" -%token Export "export" -%token Extends "extends" -%token Finally "finally" -%token For "for" -%token Function "function" -%token Function_ ";function" -%token If "if" -%token Import "import" -%token In "in" -%token In_ "!in" -%token InstanceOf "instanceof" -%token New "new" -%token Return "return" -%token Super "super" -%token Switch "switch" -%token This "this" -%token Throw "throw" -%token Try "try" -%token TypeOf "typeof" -%token Var "var" -%token Void "void" -%token While "while" -%token With "with" - -%token Abstract "abstract" -%token Await "await" -%token Boolean "boolean" -%token Byte "byte" -%token Char "char" -%token Double "double" -%token Final "final" -%token Float "float" -%token Goto "goto" -%token Implements "implements" -%token Int "int" -%token Interface "interface" -%token Let "let" -%token Long "long" -%token Native "native" -%token Package "package" -%token Private "private" -%token Protected "protected" -%token Public "public" -%token Short "short" -%token Static "static" -%token Synchronized "synchronized" -%token Throws "throws" -%token Transient "transient" -%token Volatile "volatile" -%token Yield "yield" - -%token Auto "auto" -%token Each "each" -%token Of "of" +%token _false_ "false" +%token _null_ "null" +%token _true_ "true" + +%token _break_ "break" +%token _case_ "case" +%token _catch_ "catch" +%token _class_ "class" +%token _const_ "const" +%token _continue_ "continue" +%token _debugger_ "debugger" +%token _default_ "default" +%token _delete_ "delete" +%token _do_ "do" +%token _else_ "else" +%token _enum_ "enum" +%token _export_ "export" +%token _extends_ "extends" +%token _finally_ "finally" +%token _for_ "for" +%token _function_ "function" +%token _function__ ";function" +%token _if_ "if" +%token _import_ "import" +%token _in_ "in" +%token _in__ "!in" +%token _instanceof_ "instanceof" +%token _new_ "new" +%token _return_ "return" +%token _super_ "super" +%token _switch_ "switch" +%token _this_ "this" +%token _throw_ "throw" +%token _try_ "try" +%token _typeof_ "typeof" +%token _var_ "var" +%token _void_ "void" +%token _while_ "while" +%token _with_ "with" + +%token _abstract_ "abstract" +%token _await_ "await" +%token _boolean_ "boolean" +%token _byte_ "byte" +%token _char_ "char" +%token _double_ "double" +%token _final_ "final" +%token _float_ "float" +%token _goto_ "goto" +%token _implements_ "implements" +%token _int_ "int" +%token _interface_ "interface" +%token _let_ "let" +%token _long_ "long" +%token _native_ "native" +%token _package_ "package" +%token _private_ "private" +%token _protected_ "protected" +%token _public_ "public" +%token _short_ "short" +%token _static_ "static" +%token _synchronized_ "synchronized" +%token _throws_ "throws" +%token _transient_ "transient" +%token _volatile_ "volatile" +%token _yield_ "yield" + +%token _undefined_ "undefined" + +@begin ObjectiveC +%token _bool_ "bool" +%token _BOOL_ "BOOL" +%token _id_ "id" +%token _nil_ "nil" +%token _NULL_ "NULL" +%token _SEL_ "SEL" +@end + +%token _auto_ "auto" +%token _each_ "each" +%token _of_ "of" @begin E4X -%token Namespace "namespace" -%token XML "xml" +%token _namespace_ "namespace" +%token _xml_ "xml" @end %token AutoComplete @@ -570,12 +581,12 @@ LexNoBrace ; LexNoFunction - : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); } + : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::_function_)) yyla.type = yytranslate_(token::_function__); } ; LexNoAtImplementation : @begin ObjectiveC - { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); } + { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::At_implementation_)) yyla.type = yytranslate_(token::At_implementation__); } @end ; @@ -688,6 +699,13 @@ IdentifierType | "each" { $$ = CYNew CYIdentifier("each"); } | "of" { $$ = CYNew CYIdentifier("of"); } + +@begin ObjectiveC + | "bool" { $$ = CYNew CYIdentifier("bool"); } + | "BOOL" { $$ = CYNew CYIdentifier("BOOL"); } + | "id" { $$ = CYNew CYIdentifier("id"); } + | "SEL" { $$ = CYNew CYIdentifier("SEL"); } +@end ; Identifier @@ -696,6 +714,7 @@ Identifier | "int" { $$ = CYNew CYIdentifier("int"); } | "long" { $$ = CYNew CYIdentifier("long"); } | "short" { $$ = CYNew CYIdentifier("short"); } + | "undefined" { $$ = CYNew CYIdentifier("undefined"); } | "volatile" { $$ = CYNew CYIdentifier("volatile"); } @begin C | "extern" { $$ = CYNew CYIdentifier("extern"); } @@ -704,7 +723,9 @@ Identifier | "unsigned" { $$ = CYNew CYIdentifier("unsigned"); } @end @begin ObjectiveC + | "nil" { $$ = CYNew CYIdentifier("nil"); } | "NO" { $$ = CYNew CYIdentifier("NO"); } + | "NULL" { $$ = CYNew CYIdentifier("NULL"); } | "YES" { $$ = CYNew CYIdentifier("YES"); } @end ; -- 2.45.2