Conversation
|
Ok after the next commit, all open issues should be also fixed. After this there are a few known "issues" still, but I don't see them so important:
|
|
Test in |
|
I took a random compiling Fantomas linted project: |
d1ac90c to
5d5adc0
Compare
- open type declarations
- FSI directives (#time, #I, #help, #quit)
- XML doc comments (/// as distinct xml_doc node)
- Type test pattern in atomic patterns (:? Type)
- Quotation splicing (%%) prefix operator
- fixed expressions
- Range expressions in computation expressions
- Preprocessor boolean conditions (&&, ||, !, parens, true/false)
- Extern/P/Invoke declarations
- SRTP trait call expressions (^a : (static member ...) )
- Triple-quoted string interpolation ($""" {expr} """)
- Operator precedence for && and || (split into 3 levels)
- module rec (recursive modules)
- and! in computation expressions
- struct tuple type annotations (struct (int * int))
- Add optional type_argument_constraints to _function_or_value_defn_body for
SRTP 'when' constraints on return type annotations
- Add optional 'struct' to anon_record_type for struct anonymous record types
- Add optional 'then' clause to additional_constr_defn for secondary
constructor initialization expressions
- Expand fsharp_signature parser: named_module, namespace (global/rec),
module_defn, type_definition, exception_definition, import_decl,
module_abbrev, compiler_directive_decl, preproc_if support
- Fix indentation bug in type extension with ($) identifier test
- Add quotation expression support (<@ @>, <@@ @@>) with external tokens
- Add multi-dollar triple-quoted string interpolation ($$"""...""", $$$"""...""")
- Add module ... = begin...end with begin as external token
- Add exception named fields (of field1: type * field2: type)
- Add multiline type provider support via _multiline_generic_type
- Add signature parser named parameters (curried_spec)
- Fix scanner serialize/deserialize bugs (clamped count, bounds check, off-by-one)
- Update highlights, injections, indents queries
Scanner changes:
- Add FORMAT_TRIPLE_QUOTE_CONTENT external token that stops at
unescaped { for interpolation support
Grammar changes:
- fsharp/grammar.js: new rules (trait_call_expression, extern_binding,
extern_param, and_bang, struct_type, _preproc_expression, xml_doc),
extended existing rules (import_decl, prefixed_expression, module_defn,
named_module, infix_expression, format_triple_quoted_string)
- fsharp_signature/grammar.js: added conflict for operator precedence
- common/scanner.h: FORMAT_TRIPLE_QUOTE_CONTENT with {{ escape handling
…atterns (ionide#134, ionide#149) - Fix infinite loop during error recovery by returning false from scanner when ERROR_SENTINEL is set, preventing zero-length DEDENT loop - Fix multiline record patterns by adding indent/dedent alternative in record_pattern grammar rule so scanner-emitted INDENT tokens between fields on different lines are handled correctly - Add test case for multiline record patterns in match expressions
…essions The application_expression highlight query previously used a wildcard (_) @function.call that captured the entire first child node. For generic constructor calls like ResizeArray<string>(), this meant the typed_expression spanning 'ResizeArray<string>' was tagged as function.call, causing the '<' at column 19 to incorrectly receive the function.call highlight instead of a bracket highlight. Changes: - Replace the single broad application_expression query with four specific patterns that target only the identifier within long_identifier_or_op, dot_expression, and their typed_expression variants - Add typed_expression '>' @punctuation.bracket to highlight the closing angle bracket consistently with generic_type (the opening '<' uses the _tyapp_open external token which is anonymous and unmatchable in queries) - Update test expectations: remove assertions for '<' (unmatchable) and change '>' from operator to punctuation.bracket
5d5adc0 to
6af9a0f
Compare
Nsidorenco
left a comment
There was a problem hiding this comment.
Really nice you're picking this up! I fixed the workflow so the CI now tests the parser against the FSharp.Core testsuite again - that should give a pretty good indication of the state of the parser.
| // During error recovery, all valid_symbols are true and tree-sitter | ||
| // restores scanner state before each attempt. Emitting zero-length | ||
| // tokens (DEDENT/PREPROC_END) here causes infinite loops: the parser | ||
| // can't use the token, recovers, restores state (undoing the pop), | ||
| // and the scanner emits the same token again forever. | ||
| // Return false to let tree-sitter's built-in error recovery skip | ||
| // the problematic character and move on. | ||
| return false; |
There was a problem hiding this comment.
If you do not return DEDENT/PREPROC_END tokens during error recovery you get a much worse parse tree during typing since it will I many cases be able to identify a partial parse tree
Effectively, if you use tree-sitter for syntax highlighting and write something like
match x with
It will fail to highlight anything since it lacks the DEDENT token to identify this is a partially correct match-statement
There was a problem hiding this comment.
We should generally be wary of the size of the parser. It went from ~30mb to ~50mb here. 30mb was already rather large. An increase in parser size generally comes from an increased ambiguity within the grammar and is probably one of those things where mimicking the language spec won't necessarily lead to a performant tree-sitter parser
Add support for the following F# syntax features (all tests passing):
Scanner changes:
Grammar changes: