diff --git a/lib/ace/mode/php/php.js b/lib/ace/mode/php/php.js index 6c97c2d192c..3c7eb0b5809 100644 --- a/lib/ace/mode/php/php.js +++ b/lib/ace/mode/php/php.js @@ -21,370 +21,593 @@ define(function(require, exports, module) { var PHP = {Constants:{}}; - - - -PHP.Constants.T_INCLUDE = 262; -PHP.Constants.T_INCLUDE_ONCE = 261; -PHP.Constants.T_EVAL = 260; -PHP.Constants.T_REQUIRE = 259; -PHP.Constants.T_REQUIRE_ONCE = 258; -PHP.Constants.T_LOGICAL_OR = 263; -PHP.Constants.T_LOGICAL_XOR = 264; -PHP.Constants.T_LOGICAL_AND = 265; -PHP.Constants.T_PRINT = 266; -PHP.Constants.T_PLUS_EQUAL = 277; -PHP.Constants.T_MINUS_EQUAL = 276; -PHP.Constants.T_MUL_EQUAL = 275; -PHP.Constants.T_DIV_EQUAL = 274; +PHP.Constants.T_INCLUDE = 257; +PHP.Constants.T_INCLUDE_ONCE = 258; +PHP.Constants.T_EVAL = 259; +PHP.Constants.T_REQUIRE = 260; +PHP.Constants.T_REQUIRE_ONCE = 261; +PHP.Constants.T_LOGICAL_OR = 262; +PHP.Constants.T_LOGICAL_XOR = 263; +PHP.Constants.T_LOGICAL_AND = 264; +PHP.Constants.T_PRINT = 265; +PHP.Constants.T_YIELD = 266; +PHP.Constants.T_DOUBLE_ARROW = 267; +PHP.Constants.T_YIELD_FROM = 268; +PHP.Constants.T_PLUS_EQUAL = 269; +PHP.Constants.T_MINUS_EQUAL = 270; +PHP.Constants.T_MUL_EQUAL = 271; +PHP.Constants.T_DIV_EQUAL = 272; PHP.Constants.T_CONCAT_EQUAL = 273; -PHP.Constants.T_MOD_EQUAL = 272; -PHP.Constants.T_AND_EQUAL = 271; -PHP.Constants.T_OR_EQUAL = 270; -PHP.Constants.T_XOR_EQUAL = 269; -PHP.Constants.T_SL_EQUAL = 268; -PHP.Constants.T_SR_EQUAL = 267; -PHP.Constants.T_BOOLEAN_OR = 278; -PHP.Constants.T_BOOLEAN_AND = 279; -PHP.Constants.T_IS_EQUAL = 283; -PHP.Constants.T_IS_NOT_EQUAL = 282; -PHP.Constants.T_IS_IDENTICAL = 281; -PHP.Constants.T_IS_NOT_IDENTICAL = 280; -PHP.Constants.T_IS_SMALLER_OR_EQUAL = 285; -PHP.Constants.T_IS_GREATER_OR_EQUAL = 284; -PHP.Constants.T_SL = 287; -PHP.Constants.T_SR = 286; -PHP.Constants.T_INSTANCEOF = 288; -PHP.Constants.T_INC = 297; -PHP.Constants.T_DEC = 296; -PHP.Constants.T_INT_CAST = 295; -PHP.Constants.T_DOUBLE_CAST = 294; -PHP.Constants.T_STRING_CAST = 293; -PHP.Constants.T_ARRAY_CAST = 292; -PHP.Constants.T_OBJECT_CAST = 291; -PHP.Constants.T_BOOL_CAST = 290; -PHP.Constants.T_UNSET_CAST = 289; -PHP.Constants.T_NEW = 299; -PHP.Constants.T_CLONE = 298; -PHP.Constants.T_EXIT = 300; -PHP.Constants.T_IF = 301; -PHP.Constants.T_ELSEIF = 302; -PHP.Constants.T_ELSE = 303; -PHP.Constants.T_ENDIF = 304; -PHP.Constants.T_LNUMBER = 305; -PHP.Constants.T_DNUMBER = 306; -PHP.Constants.T_STRING = 307; -PHP.Constants.T_STRING_VARNAME = 308; -PHP.Constants.T_VARIABLE = 309; -PHP.Constants.T_NUM_STRING = 310; -PHP.Constants.T_INLINE_HTML = 311; -PHP.Constants.T_CHARACTER = 312; -PHP.Constants.T_BAD_CHARACTER = 313; -PHP.Constants.T_ENCAPSED_AND_WHITESPACE = 314; -PHP.Constants.T_CONSTANT_ENCAPSED_STRING = 315; -PHP.Constants.T_ECHO = 316; -PHP.Constants.T_DO = 317; -PHP.Constants.T_WHILE = 318; -PHP.Constants.T_ENDWHILE = 319; -PHP.Constants.T_FOR = 320; -PHP.Constants.T_ENDFOR = 321; -PHP.Constants.T_FOREACH = 322; -PHP.Constants.T_ENDFOREACH = 323; -PHP.Constants.T_DECLARE = 324; -PHP.Constants.T_ENDDECLARE = 325; -PHP.Constants.T_AS = 326; -PHP.Constants.T_SWITCH = 327; -PHP.Constants.T_ENDSWITCH = 328; -PHP.Constants.T_CASE = 329; -PHP.Constants.T_DEFAULT = 330; -PHP.Constants.T_BREAK = 331; -PHP.Constants.T_CONTINUE = 332; -PHP.Constants.T_GOTO = 333; -PHP.Constants.T_FUNCTION = 334; -PHP.Constants.T_CONST = 335; -PHP.Constants.T_RETURN = 336; -PHP.Constants.T_TRY = 337; -PHP.Constants.T_CATCH = 338; -PHP.Constants.T_THROW = 339; -PHP.Constants.T_USE = 340; -//PHP.Constants.T_INSTEADOF = ; -PHP.Constants.T_GLOBAL = 341; -PHP.Constants.T_STATIC = 347; -PHP.Constants.T_ABSTRACT = 346; -PHP.Constants.T_FINAL = 345; -PHP.Constants.T_PRIVATE = 344; -PHP.Constants.T_PROTECTED = 343; -PHP.Constants.T_PUBLIC = 342; -PHP.Constants.T_VAR = 348; -PHP.Constants.T_UNSET = 349; -PHP.Constants.T_ISSET = 350; -PHP.Constants.T_EMPTY = 351; -PHP.Constants.T_HALT_COMPILER = 352; -PHP.Constants.T_CLASS = 353; -PHP.Constants.T_TRAIT = 382; -PHP.Constants.T_INTERFACE = 354; -PHP.Constants.T_EXTENDS = 355; -PHP.Constants.T_IMPLEMENTS = 356; -PHP.Constants.T_OBJECT_OPERATOR = 357; -PHP.Constants.T_DOUBLE_ARROW = 358; -PHP.Constants.T_LIST = 359; -PHP.Constants.T_ARRAY = 360; -//PHP.Constants.T_CALLABLE = ; -PHP.Constants.T_CLASS_C = 361; -PHP.Constants.T_TRAIT_C = 381; -PHP.Constants.T_METHOD_C = 362; -PHP.Constants.T_FUNC_C = 363; -PHP.Constants.T_LINE = 364; -PHP.Constants.T_FILE = 365; -PHP.Constants.T_COMMENT = 366; -PHP.Constants.T_DOC_COMMENT = 367; -PHP.Constants.T_OPEN_TAG = 368; -PHP.Constants.T_OPEN_TAG_WITH_ECHO = 369; -PHP.Constants.T_CLOSE_TAG = 370; -PHP.Constants.T_WHITESPACE = 371; -PHP.Constants.T_START_HEREDOC = 372; -PHP.Constants.T_END_HEREDOC = 373; -PHP.Constants.T_DOLLAR_OPEN_CURLY_BRACES = 374; -PHP.Constants.T_CURLY_OPEN = 375; -PHP.Constants.T_PAAMAYIM_NEKUDOTAYIM = 376; -PHP.Constants.T_DOUBLE_COLON = 376; -PHP.Constants.T_NAMESPACE = 377; -PHP.Constants.T_NS_C = 378; -PHP.Constants.T_DIR = 379; -PHP.Constants.T_NS_SEPARATOR = 380; -PHP.Lexer = function( src, ini ) { - - - var heredoc, - lineBreaker = function( result ) { - if (result.match(/\n/) !== null) { - var quote = result.substring(0, 1); - result = '[' + result.split(/\n/).join( quote + "," + quote ) + '].join("\\n")'; - - } +PHP.Constants.T_MOD_EQUAL = 274; +PHP.Constants.T_AND_EQUAL = 275; +PHP.Constants.T_OR_EQUAL = 276; +PHP.Constants.T_XOR_EQUAL = 277; +PHP.Constants.T_SL_EQUAL = 278; +PHP.Constants.T_SR_EQUAL = 279; +PHP.Constants.T_POW_EQUAL = 280; +PHP.Constants.T_COALESCE = 281; +PHP.Constants.T_BOOLEAN_OR = 282; +PHP.Constants.T_BOOLEAN_AND = 283; +PHP.Constants.T_IS_EQUAL = 284; +PHP.Constants.T_IS_NOT_EQUAL = 285; +PHP.Constants.T_IS_IDENTICAL = 286; +PHP.Constants.T_IS_NOT_IDENTICAL = 287; +PHP.Constants.T_SPACESHIP = 288; +PHP.Constants.T_IS_SMALLER_OR_EQUAL = 289; +PHP.Constants.T_IS_GREATER_OR_EQUAL = 290; +PHP.Constants.T_SL = 291; +PHP.Constants.T_SR = 292; +PHP.Constants.T_INSTANCEOF = 293; +PHP.Constants.T_INC = 294; +PHP.Constants.T_DEC = 295; +PHP.Constants.T_INT_CAST = 296; +PHP.Constants.T_DOUBLE_CAST = 297; +PHP.Constants.T_STRING_CAST = 298; +PHP.Constants.T_ARRAY_CAST = 299; +PHP.Constants.T_OBJECT_CAST = 300; +PHP.Constants.T_BOOL_CAST = 301; +PHP.Constants.T_UNSET_CAST = 302; +PHP.Constants.T_POW = 303; +PHP.Constants.T_NEW = 304; +PHP.Constants.T_CLONE = 305; +PHP.Constants.T_EXIT = 306; +PHP.Constants.T_IF = 307; +PHP.Constants.T_ELSEIF = 308; +PHP.Constants.T_ELSE = 309; +PHP.Constants.T_ENDIF = 310; +PHP.Constants.T_LNUMBER = 311; +PHP.Constants.T_DNUMBER = 312; +PHP.Constants.T_STRING = 313; +PHP.Constants.T_STRING_VARNAME = 314; +PHP.Constants.T_VARIABLE = 315; +PHP.Constants.T_NUM_STRING = 316; +PHP.Constants.T_INLINE_HTML = 317; +PHP.Constants.T_CHARACTER = 318; +PHP.Constants.T_BAD_CHARACTER = 319; +PHP.Constants.T_ENCAPSED_AND_WHITESPACE = 320; +PHP.Constants.T_CONSTANT_ENCAPSED_STRING = 321; +PHP.Constants.T_ECHO = 322; +PHP.Constants.T_DO = 323; +PHP.Constants.T_WHILE = 324; +PHP.Constants.T_ENDWHILE = 325; +PHP.Constants.T_FOR = 326; +PHP.Constants.T_ENDFOR = 327; +PHP.Constants.T_FOREACH = 328; +PHP.Constants.T_ENDFOREACH = 329; +PHP.Constants.T_DECLARE = 330; +PHP.Constants.T_ENDDECLARE = 331; +PHP.Constants.T_AS = 332; +PHP.Constants.T_SWITCH = 333; +PHP.Constants.T_ENDSWITCH = 334; +PHP.Constants.T_CASE = 335; +PHP.Constants.T_DEFAULT = 336; +PHP.Constants.T_BREAK = 337; +PHP.Constants.T_CONTINUE = 338; +PHP.Constants.T_GOTO = 339; +PHP.Constants.T_FUNCTION = 340; +PHP.Constants.T_CONST = 341; +PHP.Constants.T_RETURN = 342; +PHP.Constants.T_TRY = 343; +PHP.Constants.T_CATCH = 344; +PHP.Constants.T_FINALLY = 345; +PHP.Constants.T_THROW = 346; +PHP.Constants.T_USE = 347; +PHP.Constants.T_INSTEADOF = 348; +PHP.Constants.T_GLOBAL = 349; +PHP.Constants.T_STATIC = 350; +PHP.Constants.T_ABSTRACT = 351; +PHP.Constants.T_FINAL = 352; +PHP.Constants.T_PRIVATE = 353; +PHP.Constants.T_PROTECTED = 354; +PHP.Constants.T_PUBLIC = 355; +PHP.Constants.T_VAR = 356; +PHP.Constants.T_UNSET = 357; +PHP.Constants.T_ISSET = 358; +PHP.Constants.T_EMPTY = 359; +PHP.Constants.T_HALT_COMPILER = 360; +PHP.Constants.T_CLASS = 361; +PHP.Constants.T_TRAIT = 362; +PHP.Constants.T_INTERFACE = 363; +PHP.Constants.T_EXTENDS = 364; +PHP.Constants.T_IMPLEMENTS = 365; +PHP.Constants.T_OBJECT_OPERATOR = 366; +PHP.Constants.T_LIST = 367; +PHP.Constants.T_ARRAY = 368; +PHP.Constants.T_CALLABLE = 369; +PHP.Constants.T_CLASS_C = 370; +PHP.Constants.T_TRAIT_C = 371; +PHP.Constants.T_METHOD_C = 372; +PHP.Constants.T_FUNC_C = 373; +PHP.Constants.T_LINE = 374; +PHP.Constants.T_FILE = 375; +PHP.Constants.T_COMMENT = 376; +PHP.Constants.T_DOC_COMMENT = 377; +PHP.Constants.T_OPEN_TAG = 378; +PHP.Constants.T_OPEN_TAG_WITH_ECHO = 379; +PHP.Constants.T_CLOSE_TAG = 380; +PHP.Constants.T_WHITESPACE = 381; +PHP.Constants.T_START_HEREDOC = 382; +PHP.Constants.T_END_HEREDOC = 383; +PHP.Constants.T_DOLLAR_OPEN_CURLY_BRACES = 384; +PHP.Constants.T_CURLY_OPEN = 385; +PHP.Constants.T_PAAMAYIM_NEKUDOTAYIM = 386; +PHP.Constants.T_NAMESPACE = 387; +PHP.Constants.T_NS_C = 388; +PHP.Constants.T_DIR = 389; +PHP.Constants.T_NS_SEPARATOR = 390; +PHP.Constants.T_ELLIPSIS = 391; + +PHP.Lexer = function(src, ini) { + var heredoc, heredocEndAllowed, + + stateStack = ['INITIAL'], stackPos = 0, + swapState = function(state) { + stateStack[stackPos] = state; + }, + pushState = function(state) { + stateStack[++stackPos] = state; + }, + popState = function() { + --stackPos; + }, - return result; + shortOpenTag = ini === undefined || /^(on|true|1)$/i.test(ini.short_open_tag), + openTag = shortOpenTag + ? /^(\<\?php(?:\r\n|[ \t\r\n])|<\?|\