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

Support Tree-sitter MATLAB switch statement #561

Closed
jastier opened this issue Oct 10, 2023 · 2 comments
Closed

Support Tree-sitter MATLAB switch statement #561

jastier opened this issue Oct 10, 2023 · 2 comments
Assignees
Labels
CI continuous integration and automated workflows Code2FN lang/MATLAB Used for work related to MATLAB frontend

Comments

@jastier
Copy link
Contributor

jastier commented Oct 10, 2023

Support Tree-sitter parsing and unit testing of the MATLAB switch statement

Support CAST generation and validation testing of this code snippet:

switch x
    case 1
        n = 1;
        j = 1;
    case {3, three, 'three'}
        n = 3;
    case {{1, 2, 3,}, {7, 8, 9}}
        n = 6;
    otherwise
        n = 0;
end
@jastier jastier self-assigned this Oct 10, 2023
@jastier jastier added this to the [DARPA] Milestone 10 milestone Oct 10, 2023
@jastier jastier added Code2FN CI continuous integration and automated workflows lang/MATLAB Used for work related to MATLAB frontend labels Oct 10, 2023
@jastier jastier removed this from the [DARPA] Milestone 10 milestone Oct 12, 2023
jastier added a commit that referenced this issue Nov 1, 2023
## MATLAB conditional logic added to CAST parser

This PR fixes the if statement handler in `matlab_to_cast.py`. We now
fully support `if elseif else` conditional logic of arbitrary depth in
MATLAB.

- One `if` statement is always included
- Zero or more `elseif` clauses can be included
- Zero or one `else` clause can be included

## Relevant issues
Completes issue #593
Partially completes  issue #561

---------

Co-authored-by: Joseph Astier <[email protected]>
Co-authored-by: Vincent Raymond <[email protected]>
github-actions bot added a commit that referenced this issue Nov 1, 2023
## MATLAB conditional logic added to CAST parser

This PR fixes the if statement handler in `matlab_to_cast.py`. We now
fully support `if elseif else` conditional logic of arbitrary depth in
MATLAB.

- One `if` statement is always included
- Zero or more `elseif` clauses can be included
- Zero or one `else` clause can be included

## Relevant issues
Completes issue #593
Partially completes  issue #561

---------

Co-authored-by: Joseph Astier <[email protected]>
Co-authored-by: Vincent Raymond <[email protected]> a66fba6
@jastier
Copy link
Contributor Author

jastier commented Nov 9, 2023

PR #634 resolves this issue and is up for review.

jastier added a commit that referenced this issue Nov 13, 2023
## MATLAB switch statement support
This PR adds Tree-sitter coverage of MATLAB switch statements. CI tests
are also included.

``` matlab
switch x
    case 1
        n = 1;
        j = 1;
    case {3, three, 'three'}
        n = 3;
    case {{1, 2, 3,}, {7, 8, 9}}
        n = 6;
    otherwise
        n = 0;
end
```

## Relevant features
- Switch statements are translated into CAST conditional logic
- Multiple argument cases are reduced to single list inclusion test
- Case arguments may be of differing datatypes (string, number,
identifier)

## Related issues

- Resolves issue #561

---------

Co-authored-by: Joseph Astier <[email protected]>
github-actions bot added a commit that referenced this issue Nov 13, 2023
## MATLAB switch statement support
This PR adds Tree-sitter coverage of MATLAB switch statements. CI tests
are also included.

``` matlab
switch x
    case 1
        n = 1;
        j = 1;
    case {3, three, 'three'}
        n = 3;
    case {{1, 2, 3,}, {7, 8, 9}}
        n = 6;
    otherwise
        n = 0;
end
```

## Relevant features
- Switch statements are translated into CAST conditional logic
- Multiple argument cases are reduced to single list inclusion test
- Case arguments may be of differing datatypes (string, number,
identifier)

## Related issues

- Resolves issue #561

---------

Co-authored-by: Joseph Astier <[email protected]> 391786e
@jastier
Copy link
Contributor Author

jastier commented Nov 14, 2023

PR #634 has been merged into main, issue resolved and closed.

@jastier jastier closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI continuous integration and automated workflows Code2FN lang/MATLAB Used for work related to MATLAB frontend
Projects
None yet
Development

No branches or pull requests

1 participant