Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing of record & list bodies. (#94)
### Brief Description Change the node structure of the record & list bodies to better represent the actual syntax of the language. This fixes some bugs as well as make the syntax more consistent & easier to read. ### Fixes - TS can't properly detect durantion values in records. It is instead deteced as integer & a command node that create an error: ```nu { key: 5sec } ``` - TS can't properly detect when value & key begins & allow invald syntax with value & key having no space or any separator in between. The following example is considered valid by TS: ```nu { key: 1536another_key: 8549 } ``` ### What is changed - Records use a new body structure which manages entries & separators in between. This fixes the separator bugs described above & creates new nodes that can be used for highlighting & indenting. - Lists also have their structure changed in the same manner (both records & list body acts the same in nushell syntax, with exception to what is actually a record entry ``key: value`` vs a list entry ``value``. - Record tests are added for the bugs described above. All tests have been updated with the new node syntax. ### Details - New function is added to grammar js for general body structure. It consist of repeated statement all seperated by a mandotory separator, followed by a final statement with an optional separator. - This function is applied to the bodies of lists & records with the corresponding entries. - List has an added node for the list_entry itself (before it was just hardcoded into the list rule) - Separator is added for entries ``[,\s\n\r]`` - Comment is added on top of the code to improve LSP parsing of code with tsserver (commonly used by other TS projects for grammar.sj) - Tests are updated with new new node syntax - I've individually checked the diffs of all tests to make sure they are working as indented - New test has been added to check if records can accept duration input. - New test has been added to test if records accept invaild input with no separator between value & key. --------- Co-authored-by: CabalCrow <[email protected]>
- Loading branch information