mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
GDScript: Add lambda syntax parsing
Lambda syntax is the same as a the function syntax (using the same
`func` keyword) except that the name is optional and it can be embedded
anywhere an expression is expected. E.g.:
func _ready():
var my_lambda = func(x):
print(x)
my_lambda.call("hello")
This commit is contained in:
parent
f879a08a62
commit
c6e66a43b0
6 changed files with 229 additions and 68 deletions
|
|
@ -217,6 +217,7 @@ private:
|
|||
Token last_newline;
|
||||
int pending_indents = 0;
|
||||
List<int> indent_stack;
|
||||
List<List<int>> indent_stack_stack; // For lambdas, which require manipulating the indentation point.
|
||||
List<char32_t> paren_stack;
|
||||
char32_t indent_char = '\0';
|
||||
int position = 0;
|
||||
|
|
@ -263,6 +264,8 @@ public:
|
|||
void set_multiline_mode(bool p_state);
|
||||
bool is_past_cursor() const;
|
||||
static String get_token_name(Token::Type p_token_type);
|
||||
void push_expression_indented_block(); // For lambdas, or blocks inside expressions.
|
||||
void pop_expression_indented_block(); // For lambdas, or blocks inside expressions.
|
||||
|
||||
GDScriptTokenizer();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue