Data Structures | Macros | Typedefs | Enumerations | Variables
expressions.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "nvim/types.h"
#include "nvim/viml/parser/parser.h"
#include "nvim/eval/typval.h"

Go to the source code of this file.

Data Structures

struct  LexExprToken
 Lexer token. More...
 
struct  expr_ast_node
 Structure representing one AST node. More...
 
struct  ExprASTError
 AST error definition. More...
 
struct  ExprAST
 Structure representing complety AST for one expression. More...
 

Macros

#define EXPR_OPT_SCOPE_LIST   ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
 
#define EXPR_VAR_SCOPE_LIST
 

Typedefs

typedef struct expr_ast_node ExprASTNode
 

Enumerations

enum  ExprCaseCompareStrategy { kCCStrategyUseOption = 0, kCCStrategyMatchCase = '#', kCCStrategyIgnoreCase = '?' }
 
enum  LexExprTokenType {
  kExprLexInvalid = 0, kExprLexMissing, kExprLexSpacing, kExprLexEOC,
  kExprLexQuestion, kExprLexColon, kExprLexOr, kExprLexAnd,
  kExprLexComparison, kExprLexPlus, kExprLexMinus, kExprLexDot,
  kExprLexMultiplication, kExprLexNot, kExprLexNumber, kExprLexSingleQuotedString,
  kExprLexDoubleQuotedString, kExprLexOption, kExprLexRegister, kExprLexEnv,
  kExprLexPlainIdentifier, kExprLexBracket, kExprLexFigureBrace, kExprLexParenthesis,
  kExprLexComma, kExprLexArrow, kExprLexAssignment
}
 Lexer token type. More...
 
enum  ExprComparisonType {
  kExprCmpEqual, kExprCmpMatches, kExprCmpGreater, kExprCmpGreaterOrEqual,
  kExprCmpIdentical
}
 
enum  ExprOptScope { kExprOptScopeUnspecified = 0, kExprOptScopeGlobal = 'g', kExprOptScopeLocal = 'l' }
 All possible option scopes. More...
 
enum  ExprAssignmentType { kExprAsgnPlain = 0, kExprAsgnAdd, kExprAsgnSubtract, kExprAsgnConcat }
 All possible assignment types: = and {op}=. More...
 
enum  ExprVarScope {
  kExprVarScopeMissing = 0, kExprVarScopeScript = 's', kExprVarScopeGlobal = 'g', kExprVarScopeVim = 'v',
  kExprVarScopeBuffer = 'b', kExprVarScopeWindow = 'w', kExprVarScopeTabpage = 't', kExprVarScopeLocal = 'l',
  kExprVarScopeArguments = 'a'
}
 All possible variable scopes. More...
 
enum  LexExprFlags {
  kELFlagPeek = (1 << 0), kELFlagForbidScope = (1 << 1), kELFlagAllowFloat = (1 << 2), kELFlagIsNotCmp = (1 << 3),
  kELFlagForbidEOC = (1 << 4)
}
 
enum  ExprASTNodeType {
  kExprNodeMissing = 0, kExprNodeOpMissing, kExprNodeTernary, kExprNodeTernaryValue,
  kExprNodeRegister, kExprNodeSubscript, kExprNodeListLiteral, kExprNodeUnaryPlus,
  kExprNodeBinaryPlus, kExprNodeNested, kExprNodeCall, kExprNodePlainIdentifier,
  kExprNodePlainKey, kExprNodeComplexIdentifier, kExprNodeUnknownFigure, kExprNodeLambda,
  kExprNodeDictLiteral, kExprNodeCurlyBracesIdentifier, kExprNodeComma, kExprNodeColon,
  kExprNodeArrow, kExprNodeComparison, kExprNodeConcat, kExprNodeConcatOrSubscript,
  kExprNodeInteger, kExprNodeFloat, kExprNodeSingleQuotedString, kExprNodeDoubleQuotedString,
  kExprNodeOr, kExprNodeAnd, kExprNodeUnaryMinus, kExprNodeBinaryMinus,
  kExprNodeNot, kExprNodeMultiplication, kExprNodeDivision, kExprNodeMod,
  kExprNodeOption, kExprNodeEnvironment, kExprNodeAssignment
}
 Expression AST node type. More...
 
enum  { kExprFlagsMulti = (1 << 0), kExprFlagsDisallowEOC = (1 << 1), kExprFlagsParseLet = (1 << 2) }
 

Variables

enum { ... }  ExprParserFlags
 
const uint8_t node_maxchildren []
 Array mapping ExprASTNodeType to maximum amount of children node may have. More...
 
const char *const east_node_type_tab []
 Array mapping ExprASTNodeType values to their stringified versions. More...
 
const char *const eltkn_cmp_type_tab []
 Array mapping ExprComparisonType values to their stringified versions. More...
 
const char *const ccs_tab []
 Array mapping ExprCaseCompareStrategy values to their stringified versions. More...
 
const char *const expr_asgn_type_tab []
 Array mapping ExprAssignmentType values to their stringified versions. More...
 

Macro Definition Documentation

#define EXPR_OPT_SCOPE_LIST   ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
#define EXPR_VAR_SCOPE_LIST
Value:
((char[]) { \
})
Definition: expressions.h:91
Definition: expressions.h:95
Definition: expressions.h:93
Definition: expressions.h:90
Definition: expressions.h:92
Definition: expressions.h:89
Definition: expressions.h:88
Definition: expressions.h:94

Typedef Documentation

typedef struct expr_ast_node ExprASTNode

Enumeration Type Documentation

anonymous enum
Enumerator
kExprFlagsMulti 

Allow multiple expressions in a row: e.g. for :echo

Parser will still parse only one of them though.

kExprFlagsDisallowEOC 

Allow NL, NUL and bar to be EOC

When parsing expressions input by user bar is assumed to be a binary operator and other two are spacings.

kExprFlagsParseLet 

Parse :let argument

That mean that top level node must be an assignment and first nodes belong to lvalues.

All possible assignment types: = and {op}=.

Enumerator
kExprAsgnPlain 

Plain assignment: =.

kExprAsgnAdd 

Assignment augmented with addition: +=.

kExprAsgnSubtract 

Assignment augmented with subtraction: -=.

kExprAsgnConcat 

Assignment augmented with concatenation: .=.

Expression AST node type.

Enumerator
kExprNodeMissing 
kExprNodeOpMissing 
kExprNodeTernary 

Ternary operator.

kExprNodeTernaryValue 

Ternary operator, colon.

kExprNodeRegister 

Register.

kExprNodeSubscript 

Subscript.

kExprNodeListLiteral 

List literal.

kExprNodeUnaryPlus 
kExprNodeBinaryPlus 
kExprNodeNested 

Nested parenthesised expression.

kExprNodeCall 

Function call.

kExprNodePlainIdentifier 

Plain identifier: simple variable/function name

Looks like "string", "g:Foo", etc: consists from a single kExprLexPlainIdentifier token.

kExprNodePlainKey 

Plain dictionary key, for use with kExprNodeConcatOrSubscript.

kExprNodeComplexIdentifier 

Complex identifier: variable/function name with curly braces.

kExprNodeUnknownFigure 

Figure brace expression which is not yet known

May resolve to any of kExprNodeDictLiteral, kExprNodeLambda or kExprNodeCurlyBracesIdentifier.

kExprNodeLambda 

Lambda.

kExprNodeDictLiteral 

Dictionary literal.

kExprNodeCurlyBracesIdentifier 

Part of the curly braces name.

kExprNodeComma 

Comma “operator”.

kExprNodeColon 

Colon “operator”.

kExprNodeArrow 

Arrow “operator”.

kExprNodeComparison 

Various comparison operators.

kExprNodeConcat 

Concat operator

To be only used in cases when it is known for sure it is not a subscript.

kExprNodeConcatOrSubscript 

Concat or subscript operator

For cases when it is not obvious whether expression is a concat or a subscript. May only have either number or plain identifier as the second child. To make it easier to avoid curly braces in place of kExprNodePlainIdentifier node kExprNodePlainKey is used.

kExprNodeInteger 

Integral number.

kExprNodeFloat 

Floating-point number.

kExprNodeSingleQuotedString 
kExprNodeDoubleQuotedString 
kExprNodeOr 
kExprNodeAnd 
kExprNodeUnaryMinus 
kExprNodeBinaryMinus 
kExprNodeNot 
kExprNodeMultiplication 
kExprNodeDivision 
kExprNodeMod 
kExprNodeOption 
kExprNodeEnvironment 
kExprNodeAssignment 
Enumerator
kCCStrategyUseOption 
kCCStrategyMatchCase 
kCCStrategyIgnoreCase 
Enumerator
kExprCmpEqual 

Equality, unequality.

kExprCmpMatches 

Matches regex, not matches regex.

kExprCmpGreater 

> or <=

kExprCmpGreaterOrEqual 

>= or <.

kExprCmpIdentical 

is or isnot

All possible option scopes.

Enumerator
kExprOptScopeUnspecified 
kExprOptScopeGlobal 
kExprOptScopeLocal 

All possible variable scopes.

Enumerator
kExprVarScopeMissing 
kExprVarScopeScript 
kExprVarScopeGlobal 
kExprVarScopeVim 
kExprVarScopeBuffer 
kExprVarScopeWindow 
kExprVarScopeTabpage 
kExprVarScopeLocal 
kExprVarScopeArguments 
Enumerator
kELFlagPeek 

If set, “pointer” to the current byte in pstate will not be shifted.

kELFlagForbidScope 

Determines whether scope is allowed to come before the identifier.

kELFlagAllowFloat 

Determines whether floating-point numbers are allowed

I.e. whether dot is a decimal point separator or is not a part of a number at all.

kELFlagIsNotCmp 

Determines whether is and isnot are seen as comparison operators

If set they are supposed to be just regular identifiers.

kELFlagForbidEOC 

Determines whether EOC tokens are allowed

If set then it will yield Invalid token with E15 in place of EOC one if “EOC” is something like "|". It is fine with emitting EOC at the end of string still, with or without this flag set.

Lexer token type.

Enumerator
kExprLexInvalid 

Invalid token, indicaten an error.

kExprLexMissing 

Missing token, for use in parser.

kExprLexSpacing 

Spaces, tabs, newlines, etc.

kExprLexEOC 

End of command character: NL, |, just end of stream.

kExprLexQuestion 

Question mark, for use in ternary.

kExprLexColon 

Colon, for use in ternary.

kExprLexOr 

Logical or operator.

kExprLexAnd 

Logical and operator.

kExprLexComparison 

One of the comparison operators.

kExprLexPlus 

Plus sign.

kExprLexMinus 

Minus sign.

kExprLexDot 

Dot: either concat or subscript, also part of the float.

kExprLexMultiplication 

Multiplication, division or modulo operator.

kExprLexNot 

Not: !.

kExprLexNumber 

Integer number literal, or part of a float.

kExprLexSingleQuotedString 

Single quoted string literal.

kExprLexDoubleQuotedString 

Double quoted string literal.

kExprLexOption 

&optionname option value.

kExprLexRegister 

register value.

kExprLexEnv 

Environment $variable value.

kExprLexPlainIdentifier 

Identifier without scope: abc, foo::bar.

kExprLexBracket 

Bracket, either opening or closing.

kExprLexFigureBrace 

Figure brace, either opening or closing.

kExprLexParenthesis 

Parenthesis, either opening or closing.

kExprLexComma 

Comma.

kExprLexArrow 

Arrow, like from lambda expressions.

kExprLexAssignment 

Assignment: = or {op}=.

Variable Documentation

const char* const ccs_tab[]

Array mapping ExprCaseCompareStrategy values to their stringified versions.

const char* const east_node_type_tab[]

Array mapping ExprASTNodeType values to their stringified versions.

const char* const eltkn_cmp_type_tab[]

Array mapping ExprComparisonType values to their stringified versions.

const char* const expr_asgn_type_tab[]

Array mapping ExprAssignmentType values to their stringified versions.

enum { ... } ExprParserFlags
const uint8_t node_maxchildren[]

Array mapping ExprASTNodeType to maximum amount of children node may have.