diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
commit | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch) | |
tree | d8c1843a95da5ea0bb4acc09f7e37843d9995c86 /src/nvim/viml | |
parent | 142d9041391780ac15b89886a54015fdc5c73995 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-userreg.tar.gz rneovim-userreg.tar.bz2 rneovim-userreg.zip |
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'src/nvim/viml')
-rw-r--r-- | src/nvim/viml/parser/expressions.c | 44 | ||||
-rw-r--r-- | src/nvim/viml/parser/expressions.h | 8 | ||||
-rw-r--r-- | src/nvim/viml/parser/parser.c | 3 | ||||
-rw-r--r-- | src/nvim/viml/parser/parser.h | 5 |
4 files changed, 23 insertions, 37 deletions
diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 53224f2ee9..8b637fbb9b 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1,10 +1,7 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - -/// VimL expression parser +/// Vimscript expression parser // Planned incompatibilities (to be included into vim_diff.txt when this parser -// will be an actual part of VimL evaluation process): +// will be an actual part of Vimscript evaluation process): // // 1. Expressions are first fully parsed and only then executed. This means // that while ":echo [system('touch abc')" will create file "abc" in Vim and @@ -58,17 +55,17 @@ #include <string.h> #include "klib/kvec.h" -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/charset.h" -#include "nvim/eval/typval.h" +#include "nvim/eval.h" +#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/keycodes.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" -#include "nvim/types.h" -#include "nvim/vim.h" +#include "nvim/types_defs.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" @@ -89,7 +86,7 @@ typedef enum { /// Parse type: what is being parsed currently typedef enum { - /// Parsing regular VimL expression + /// Parsing regular Vimscript expression kEPTExpr = 0, /// Parsing lambda arguments /// @@ -171,7 +168,7 @@ static inline float_T scale_number(const float_T num, const uint8_t base, return ret; } -/// Get next token for the VimL expression input +/// Get next token for the Vimscript expression input /// /// @param pstate Parser state. /// @param[in] flags Flags, @see LexExprFlags. @@ -367,7 +364,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) // uses recorded position to scale number down when processing exponent. float_T significand_part = 0; uvarnumber_T exp_part = 0; - const size_t frac_size = (size_t)(frac_end - frac_start); + const size_t frac_size = frac_end - frac_start; for (size_t i = 0; i < frac_end; i++) { if (i == frac_start - 1) { continue; @@ -376,7 +373,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) } if (exp_start) { vim_str2nr(pline.data + exp_start, NULL, NULL, 0, NULL, &exp_part, - (int)(ret.len - exp_start), false); + (int)(ret.len - exp_start), false, NULL); } if (exp_negative) { exp_part += frac_size; @@ -394,7 +391,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) int len; int prep; vim_str2nr(pline.data, &prep, &len, STR2NR_ALL, NULL, - &ret.data.num.val.integer, (int)pline.size, false); + &ret.data.num.val.integer, (int)pline.size, false, NULL); ret.len = (size_t)len; const uint8_t bases[] = { [0] = 10, @@ -938,7 +935,6 @@ static const char *intchar2str(const int ch) } #ifdef UNIT_TESTING -# include <stdio.h> REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_ast_node(const ExprASTNode *const *const eastnode_p, @@ -1168,7 +1164,7 @@ static struct { // represented as "list(comma(a, comma(b, comma(c, d))))" then if it is // "list(comma(comma(comma(a, b), c), d))" in which case you will need to // traverse all three comma() structures. And with comma operator (including - // actual comma operator from C which is not present in VimL) nobody cares + // actual comma operator from C which is not present in Vimscript) nobody cares // about associativity, only about order of execution. [kExprNodeComma] = { kEOpLvlComma, kEOpAssRight }, @@ -1273,8 +1269,8 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, ExprASTStack const ExprOpAssociativity bop_node_ass = ( (bop_node->type == kExprNodeCall || bop_node->type == kExprNodeSubscript) - ? kEOpAssLeft - : node_ass(*bop_node)); + ? kEOpAssLeft + : node_ass(*bop_node)); #endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); @@ -1915,7 +1911,7 @@ static const uint8_t base_to_prefix_length[] = { [16] = 2, }; -/// Parse one VimL expression +/// Parse one Vimscript expression /// /// @param pstate Parser state. /// @param[in] flags Additional flags, see ExprParserFlags @@ -2207,8 +2203,8 @@ viml_pexpr_parse_process_token: cur_node->data.opt.ident_len = 0; cur_node->data.opt.scope = ( cur_token.len == 3 - ? (ExprOptScope)pline.data[cur_token.start.col + 1] - : kExprOptScopeUnspecified); + ? (ExprOptScope)pline.data[cur_token.start.col + 1] + : kExprOptScopeUnspecified); } else { cur_node->data.opt.ident = cur_token.data.opt.name; cur_node->data.opt.ident_len = cur_token.data.opt.len; @@ -2866,7 +2862,7 @@ viml_pexpr_parse_no_paren_closing_error: {} case kENodeOperator: if (prev_token.type == kExprLexSpacing) { // For some reason "function (args)" is a function call, but - // "(funcref) (args)" is not. AFAIR this somehow involves + // "(funcref) (args)" is not. As far as I remember this somehow involves // compatibility and Bram was commenting that this is // intentionally inconsistent and he is not very happy with the // situation himself. diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 6fe6a784a0..94287ea4e1 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -1,13 +1,11 @@ -#ifndef NVIM_VIML_PARSER_EXPRESSIONS_H -#define NVIM_VIML_PARSER_EXPRESSIONS_H +#pragma once #include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/viml/parser/parser.h" struct expr_ast_node; @@ -388,5 +386,3 @@ extern const char *const expr_asgn_type_tab[]; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.h.generated.h" #endif - -#endif // NVIM_VIML_PARSER_EXPRESSIONS_H diff --git a/src/nvim/viml/parser/parser.c b/src/nvim/viml/parser/parser.c index 1547feba90..b854aedca6 100644 --- a/src/nvim/viml/parser/parser.c +++ b/src/nvim/viml/parser/parser.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include "nvim/viml/parser/parser.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index f387301c2d..cd5a493643 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -1,5 +1,4 @@ -#ifndef NVIM_VIML_PARSER_PARSER_H -#define NVIM_VIML_PARSER_PARSER_H +#pragma once #include <assert.h> #include <stdbool.h> @@ -227,5 +226,3 @@ static inline void viml_parser_highlight(ParserState *const pstate, const Parser #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/parser.h.generated.h" #endif - -#endif // NVIM_VIML_PARSER_PARSER_H |