diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-01-18 15:28:00 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-01-18 15:28:00 +0100 |
commit | 03b6a8efc1834a4114f0d11e1a7cecff3242b305 (patch) | |
tree | f3b620b35ca765f32af4dd10aa29794be805c53a | |
parent | 61d0a34fb7501a1f8aa43cfa1063c8a7ca1fb1d2 (diff) |
syntax: drop legacy syntax support
Drop support for the `local` keyword and `delete` function calls.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | compiler.c | 49 | ||||
-rw-r--r-- | lexer.c | 3 |
3 files changed, 6 insertions, 52 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0621d51..7c84fc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,6 @@ OPTION(NL80211_SUPPORT "Wireless Netlink plugin support" ON) OPTION(RESOLV_SUPPORT "NS resolve plugin support" ON) OPTION(STRUCT_SUPPORT "Struct plugin support" ON) -OPTION(LEGACY_SUPPORT "Support deprecated syntax features" ON) - SET(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path") STRING(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}") ADD_DEFINITIONS(-DLIB_SEARCH_PATH="${LIB_SEARCH_DEFINE}") @@ -46,10 +44,6 @@ ELSE() ADD_DEFINITIONS(-DNDEBUG) ENDIF() -IF(NOT LEGACY_SUPPORT) - ADD_DEFINITIONS(-DNO_LEGACY) -ENDIF() - INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(JSONC json-c json) IF(JSONC_FOUND) @@ -972,52 +972,15 @@ uc_compiler_compile_delete(uc_compiler_t *compiler) uc_chunk_t *chunk = uc_compiler_current_chunk(compiler); uc_vm_insn_t type; -#ifndef NO_LEGACY - /* If the delete keyword is followed by an opening paren, it might be a - * legacy delete(object, propname) call */ - if (uc_compiler_parse_match(compiler, TK_LPAREN)) { - uc_compiler_parse_precedence(compiler, P_ASSIGN); - - if (uc_compiler_parse_match(compiler, TK_RPAREN)) { - type = chunk->entries[compiler->last_insn]; - - if (type != I_LVAL) - uc_compiler_syntax_error(compiler, 0, - "expecting a property access expression"); - - chunk->entries[compiler->last_insn] = I_DELETE; - } - else if (uc_compiler_parse_match(compiler, TK_COMMA)) { - if (uc_compiler_is_strict(compiler)) { - uc_compiler_syntax_error(compiler, 0, - "attempt to apply 'delete' operator on non-property access expression"); - } - else { - uc_compiler_parse_precedence(compiler, P_ASSIGN); - uc_compiler_emit_insn(compiler, 0, I_DELETE); - uc_compiler_parse_consume(compiler, TK_RPAREN); - } - } - else { - uc_compiler_syntax_error(compiler, 0, "expecting ')' or ','"); - } - } - - /* Otherwise compile expression, ensure that it results in a property - * access (I_LVAL) and overwrite it with delete operation. */ - else -#endif /* NO_LEGACY */ - { - uc_compiler_parse_precedence(compiler, P_UNARY); + uc_compiler_parse_precedence(compiler, P_UNARY); - type = chunk->entries[compiler->last_insn]; + type = chunk->entries[compiler->last_insn]; - if (type != I_LVAL) - uc_compiler_syntax_error(compiler, 0, - "expecting a property access expression"); + if (type != I_LVAL) + uc_compiler_syntax_error(compiler, 0, + "expecting a property access expression"); - chunk->entries[compiler->last_insn] = I_DELETE; - } + chunk->entries[compiler->last_insn] = I_DELETE; } static uc_vm_insn_t @@ -144,9 +144,6 @@ static const struct keyword reserved_words[] = { { TK_RETURN, "return", 6 }, { TK_ENDFOR, "endfor", 6 }, { TK_SWITCH, "switch", 6 }, -#ifndef NO_LEGACY - { TK_LOCAL, "local", 5 }, -#endif { TK_ENDIF, "endif", 5 }, { TK_WHILE, "while", 5 }, { TK_BREAK, "break", 5 }, |