Skip to content

Commit

Permalink
improve scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Sep 8, 2024
1 parent 860461d commit da9ac22
Show file tree
Hide file tree
Showing 11 changed files with 1,010,028 additions and 827,465 deletions.
14 changes: 14 additions & 0 deletions common/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum TokenType {
STRUCT,
INTERFACE,
END,
AND,
TRIPLE_QUOTE_CONTENT,
BLOCK_COMMENT_CONTENT,
INSIDE_STRING,
Expand Down Expand Up @@ -410,6 +411,19 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
}
}
}
} else if (lexer->lookahead == 'a' && valid_symbols[AND]) {
advance(lexer);
if (lexer->lookahead == 'n') {
advance(lexer);
if (lexer->lookahead == 'd') {
advance(lexer);
if (lexer->lookahead == ' ') {
lexer->result_symbol = AND;
lexer->mark_end(lexer);
return true;
}
}
}
} else if (lexer->lookahead == 'e' &&
(valid_symbols[ELSE] || valid_symbols[ELIF] ||
valid_symbols[END] || valid_symbols[DEDENT])) {
Expand Down
16 changes: 13 additions & 3 deletions fsharp/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module.exports = grammar({
$._struct_begin,
$._interface_begin,
"end",
"and",
$._triple_quoted_content,
$.block_comment_content,
$._inside_string_marker,
Expand Down Expand Up @@ -1499,8 +1500,14 @@ module.exports = grammar({
seq("=", $._expression_block),
seq(
"with",
$._property_accessors,
repeat(seq("and", $._property_accessors)),
scoped(
seq(
$._property_accessors,
repeat(seq("and", $._property_accessors)),
),
$._indent,
$._dedent,
),
),
),
),
Expand Down Expand Up @@ -1535,7 +1542,10 @@ module.exports = grammar({
choice(
$._method_defn,
$._property_defn,
seq("with", $._function_or_value_defns),
seq(
"with",
scoped($._function_or_value_defns, $._indent, $._dedent),
),
),
),
),
Expand Down
63 changes: 53 additions & 10 deletions fsharp/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -6372,21 +6372,43 @@
"value": "with"
},
{
"type": "SYMBOL",
"name": "_property_accessors"
},
{
"type": "REPEAT",
"type": "FIELD",
"name": "block",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "and"
"type": "SYMBOL",
"name": "_indent"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_property_accessors"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "and"
},
{
"type": "SYMBOL",
"name": "_property_accessors"
}
]
}
}
]
},
{
"type": "SYMBOL",
"name": "_property_accessors"
"name": "_dedent"
}
]
}
Expand Down Expand Up @@ -6533,8 +6555,25 @@
"value": "with"
},
{
"type": "SYMBOL",
"name": "_function_or_value_defns"
"type": "FIELD",
"name": "block",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_indent"
},
{
"type": "SYMBOL",
"name": "_function_or_value_defns"
},
{
"type": "SYMBOL",
"name": "_dedent"
}
]
}
}
]
}
Expand Down Expand Up @@ -8496,6 +8535,10 @@
"type": "STRING",
"value": "end"
},
{
"type": "STRING",
"value": "and"
},
{
"type": "SYMBOL",
"name": "_triple_quoted_content"
Expand Down
58 changes: 42 additions & 16 deletions fsharp/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,48 @@
}
]
},
"block": {
"multiple": true,
"required": false,
"types": [
{
"type": ":",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": "_expression",
"named": true
},
{
"type": "_type",
"named": true
},
{
"type": "and",
"named": false
},
{
"type": "function_declaration_left",
"named": true
},
{
"type": "property_getter",
"named": true
},
{
"type": "property_setter",
"named": true
},
{
"type": "value_declaration_left",
"named": true
}
]
},
"body": {
"multiple": true,
"required": false,
Expand Down Expand Up @@ -2248,25 +2290,9 @@
"type": "_type",
"named": true
},
{
"type": "function_declaration_left",
"named": true
},
{
"type": "property_getter",
"named": true
},
{
"type": "property_setter",
"named": true
},
{
"type": "type_arguments",
"named": true
},
{
"type": "value_declaration_left",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit da9ac22

Please sign in to comment.