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

SATF/SASF Grammar support #1574

Merged
merged 4 commits into from
Jan 15, 2025
Merged

SATF/SASF Grammar support #1574

merged 4 commits into from
Jan 15, 2025

Conversation

goetzrrGit
Copy link
Contributor

@goetzrrGit goetzrrGit commented Dec 10, 2024

Closes #1496
I added support for SATF and SASF formats, which includes:

  • 85% of the grammar rules in SATF are now supported
  • I've also added support for 60% of the grammar rules in SASF, using references from Psyche SASF and NISAR

I created a converter which will eventually be a npm plugin that can take SeqN data and generate most of the SATF/SASF content. This is because each mission has slight variation so they can use this to generate 90% of the SATF/SASF and fill in the mission specific parts in their adaptation.

There's also a way to convert a SATF/SASF file into SeqN format. Not everything is carried over as SeqN doesn't support all the features of SATF/SASF

TESTING
You can find a bunch of SATF/SASF here: https://jpl365prod-my.sharepoint.com/:f:/g/personal/shaheer_khan_jpl_nasa_gov/EplqvV9nI9ZJo6JT1KVzoVwBKZHzFNbVGXWi2qUaN6k1yg?e=zIbLEa

This is hard to test as it requires hacking the Sequence Editor to use the top editor as a SATF/SASF editor and the bottom editor as a SeqN. Here is the modification I did.

  // Reconfigure sequence editor.
          editorSequenceView.dispatch({
            effects: [
              compartmentSeqLanguage.reconfigure(
                setupLanguageSupport(
                  $sequenceAdaptation.autoComplete(
                    parsedChannelDictionary,
                    parsedCommandDictionary,
                    nonNullParsedParameterDictionaries,
                    librarySequences,
                  ),
                ),
              ),
              compartmentSeqLanguage.reconfigure(setupSatfLanguageSupport()), <---- Add this line
              compartmentSeqLinter.reconfigure(
                inputLinter(
                  parsedChannelDictionary,
                  parsedCommandDictionary,
                  nonNullParsedParameterDictionaries,
                  librarySequences,
                ),
              ),
              compartmentSeqTooltip.reconfigure(
                sequenceTooltip(parsedChannelDictionary, parsedCommandDictionary, nonNullParsedParameterDictionaries),
              ),
              ...($sequenceAdaptation.autoIndent
                ? [compartmentSeqAutocomplete.reconfigure(indentService.of($sequenceAdaptation.autoIndent()))]
                : []),
            ],
          });

    if ($sequenceAdaptation?.modifyOutput !== undefined && output !== undefined) {
      const modifiedOutput = $sequenceAdaptation.modifyOutput(output, parameterDictionaries, channelDictionary);
      if (modifiedOutput === null) {
        output = 'modifyOutput returned null. Verify your adaptation is correct';
      } else if (modifiedOutput === undefined) {
        output = 'modifyOutput returned undefined. Verify your adaptation is correct';
      } else if (typeof modifiedOutput === 'object') {
        output = JSON.stringify(modifiedOutput);
      } else {
        output = `${modifiedOutput}`;
      }
    }
    
    const seqN = await satfToSequence(sequence);  <--------- Add this line
    output = seqN.header + '\n' + seqN.sequences.join('\n'); <----- Add this line

    editorOutputView.dispatch({ changes: { from: 0, insert: output, to: editorOutputView.state.doc.length } });

    if (output !== undefined) {
      dispatch('sequence', { input: sequence, output });
    }

@goetzrrGit goetzrrGit requested a review from a team as a code owner December 10, 2024 16:37
@goetzrrGit goetzrrGit self-assigned this Dec 10, 2024
@goetzrrGit goetzrrGit requested a review from cohansen December 10, 2024 16:37
Copy link
Collaborator

@joswig joswig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax highlighting looks good in my testing.

Were you able to test for parse errors in all of the linked files?

src/utilities/codemirror/satf/satf.test.ts Outdated Show resolved Hide resolved
src/utilities/codemirror/satf/satf-sasf-utils.ts Outdated Show resolved Hide resolved
@cohansen
Copy link
Contributor

cohansen commented Jan 3, 2025

Is there a list somewhere of remaining work? You mention that this is about 60% of the current grammar rules.

@goetzrrGit
Copy link
Contributor Author

Is there a list somewhere of remaining work? You mention that this is about 60% of the current grammar rules.

The remaining work is to verify that both satf/sasf sis are 100% implemented. The rules I left out are things that PSYCHE, NISAR are not using here is a rough list of unsupported steps:

for,
while,
pause,
spawn,
call,
wait_change,
Delay_by,
Delay_until,
Test_and_set,
command_wait,
noop,
re_command,
reservation,
if/else conditional

duranb
duranb previously requested changes Jan 6, 2025
src/utilities/codemirror/satf/sasf.test.ts Outdated Show resolved Hide resolved
src/utilities/codemirror/satf/satf.test.ts Outdated Show resolved Hide resolved
* Converts parts of SeqN to SATF/SASF
* Converts parts SATF/SASF to SeqN
@goetzrrGit goetzrrGit force-pushed the feature/satf_grammar branch from 46eecf9 to 7b9a181 Compare January 7, 2025 19:26
@duranb duranb dismissed their stale review January 7, 2025 21:46

lgtm, but will defer to @joswig for the final approval

Copy link
Contributor

@cohansen cohansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I did some manual testing and I think @joswig and @duranb had good feedback.

@joswig
Copy link
Collaborator

joswig commented Jan 14, 2025

lgtm

@goetzrrGit goetzrrGit merged commit e588f48 into develop Jan 15, 2025
5 checks passed
@goetzrrGit goetzrrGit deleted the feature/satf_grammar branch January 15, 2025 14:49
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

Successfully merging this pull request may close these issues.

Unify Psyche and Nisar SASF and SATF support
4 participants