Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutually recursive function syntax #13

Open
samueleaton opened this issue Jun 20, 2022 · 2 comments
Open

Mutually recursive function syntax #13

samueleaton opened this issue Jun 20, 2022 · 2 comments

Comments

@samueleaton
Copy link

Doesn't support the mutually recursive function syntax as described here: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/recursive-functions-the-rec-keyword

// Mutually recursive functions:
let rec function1-nameparameter-list =
    function1-body

and function2-nameparameter-list =
    function2-body
...

Example:

let rec Even x = 
    if x = 0 then true 
    else Odd (x-1) 
and Odd x = 
    if x = 0 then false 
    else Even (x-1)

Screenshots:

Odd is not recognized as a function:
Screen Shot 2022-06-13 at 4 07 13 PM
Screen Shot 2022-06-13 at 4 07 54 PM
Screen Shot 2022-06-13 at 4 08 03 PM

@samueleaton
Copy link
Author

This simple addition below fixes it. I copied the .sublime-syntax file locally and it worked. I saw that the official Sublime OCaml package just has let|and in the syntax def so I copied it.

...
definition:
    # "and" added between "|let|" and "|member val|"
    - match: '\b(let mutable|static let mutable|static let|let inline|let|and|member val|static member inline|static member|default|member|override|let!)(\s+rec|mutable)?(\s+\[\<.*\>\])?\s*(private|internal|public)?\s+(\[[^-=]*\]|[_[:alpha:]]([_[:alpha:]0-9\._]+)*|``[_[:alpha:]]([_[:alpha:]0-9\._`\s]+|(?<=,)\s)*)?'
      captures:
        1: keyword.fsharp
        2: keyword.fsharp
        3: support.function.attribute.fsharp
        4: storage.modifier.fsharp
        5: variable.fsharp
      push:
        - meta_scope: binding.fsharp
        - match: \s*(with\b|=|\n+=|(?<=\=))
          captures:
            1: keyword.fsharp
          pop: true
        - include: common_binding_definition
...

@samueleaton
Copy link
Author

samueleaton commented Aug 26, 2022

I would make a PR but it looks like you generate this from from the ionide grammar.

samueleaton added a commit to samueleaton/ionide-fsgrammar that referenced this issue Aug 26, 2022
See issue in [hoest/sublimetext-fsharp#13 which depends on this project and has more info.
baronfel pushed a commit to ionide/ionide-fsgrammar that referenced this issue Aug 26, 2022
See issue in [hoest/sublimetext-fsharp#13 which depends on this project and has more info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant