aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/viml/parser/expressions.h
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-09-17 17:33:03 +0300
committerZyX <kp-pav@yandex.ru>2017-10-08 22:25:06 +0300
commit7980614650f0aedb39bf88466e5bd3ce90429cc1 (patch)
treea8d8aeae8050ef30facfb8042d90577e59cd0dcc /src/nvim/viml/parser/expressions.h
parent7c97f783935ec122fbf0d7d070c00804738abd6a (diff)
downloadrneovim-7980614650f0aedb39bf88466e5bd3ce90429cc1.tar.gz
rneovim-7980614650f0aedb39bf88466e5bd3ce90429cc1.tar.bz2
rneovim-7980614650f0aedb39bf88466e5bd3ce90429cc1.zip
viml/parser/expressions: Add support for figure braces (three kinds)
Diffstat (limited to 'src/nvim/viml/parser/expressions.h')
-rw-r--r--src/nvim/viml/parser/expressions.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h
index 13888562df..13640ec137 100644
--- a/src/nvim/viml/parser/expressions.h
+++ b/src/nvim/viml/parser/expressions.h
@@ -2,6 +2,7 @@
#define NVIM_VIML_PARSER_EXPRESSIONS_H
#include <stddef.h>
+#include <stdint.h>
#include <stdbool.h>
#include "nvim/types.h"
@@ -130,6 +131,17 @@ typedef enum {
kExprNodePlainIdentifier = 'i',
/// Complex identifier: variable/function name with curly braces
kExprNodeComplexIdentifier = 'I',
+ /// Figure brace expression which is not yet known
+ ///
+ /// May resolve to any of kExprNodeDictLiteral, kExprNodeLambda or
+ /// kExprNodeCurlyBracesIdentifier.
+ kExprNodeUnknownFigure = '{',
+ kExprNodeLambda = '\\', ///< Lambda.
+ kExprNodeDictLiteral = 'd', ///< Dictionary literal.
+ kExprNodeCurlyBracesIdentifier= '}', ///< Part of the curly braces name.
+ kExprNodeComma = ',', ///< Comma “operator”.
+ kExprNodeColon = ':', ///< Colon “operator”.
+ kExprNodeArrow = '>', ///< Arrow “operator”.
} ExprASTNodeType;
typedef struct expr_ast_node ExprASTNode;
@@ -149,6 +161,27 @@ struct expr_ast_node {
struct {
int name; ///< Register name, may be -1 if name not present.
} reg; ///< For kExprNodeRegister.
+ struct {
+ /// Which nodes UnknownFigure can’t possibly represent.
+ struct {
+ /// True if UnknownFigure may actually represent dictionary literal.
+ bool allow_dict;
+ /// True if UnknownFigure may actually represent lambda.
+ bool allow_lambda;
+ /// True if UnknownFigure may actually be part of curly braces name.
+ bool allow_ident;
+ } type_guesses;
+ /// Highlight chunk index, used for rehighlighting if needed
+ size_t opening_hl_idx;
+ } fig; ///< For kExprNodeUnknownFigure.
+ struct {
+ int scope; ///< Scope character or 0 if not present.
+ /// Actual identifier without scope.
+ ///
+ /// Points to inside parser reader state.
+ const char *ident;
+ size_t ident_len; ///< Actual identifier length.
+ } var;
} data;
};
@@ -166,6 +199,8 @@ enum {
///
/// Without the flag they are only taken into account when parsing.
kExprFlagsPrintError = (1 << 2),
+ // WARNING: whenever you add a new flag, alter klee_assume() statement in
+ // viml_expressions_parser.c.
} ExprParserFlags;
/// Structure representing complety AST for one expression