Structorizer.Desktop icon indicating copy to clipboard operation
Structorizer.Desktop copied to clipboard

Code import: Would it be possible to skip unexpected tokens in GOLDParser?

Open GitMensch opened this issue 7 years ago • 5 comments

The current behavior (for all import languages) is:

Output the error - where we had major improvements with showing context, source comments and expected tokens. Then abort.

I'm more firm with Bison parser where you can add special error tokens - after the error is handled the parser would fall back to this token and go on from there instead of aborting / going to the next token.

Here's a sample for the COBOL import (would be the same for others) with an invalid source:

grafik

Instead of only "OK" (=ABORT) it would be nice to present the user with an option to "skip" (= returning to the parser) or "skip line" (= deleting this line from the object we pass to the parser and re-run the parser [which may be done multiple times]). Is the first possible (likely would occur multiple times with the given source)? What do you think about the second one?

GitMensch avatar Nov 27 '17 08:11 GitMensch

You know that the error occurs when the GOLD Parser has given up. I am afraid that at this point it will be too late to push the parser back onto the tracks. There is an opportunity, however, to implement some rule handlers, originally intended to associate code generation activities with them (see the original program template for the Iden machine). I would have to analyse whether this might offer a chance to switch to an alternative parser action. But this might require us to put our fingers into the parsing machine core because all rule conflict handling is done by the grammar compiler and cast into the state tables. So your second suggested approach (to reiterate the parsing process after having done some source code manipulations) might be more viable, though looking clumsy and awful.

codemanyak avatar Nov 27 '17 10:11 codemanyak

So your second suggested approach (to reiterate the parsing process after having done some source code manipulations) might be more viable, though looking clumsy and awful.

The manual copy of the complete file + deletion of the line and restarting import on it seems even more clumsy. So the clumsy method outlined may be a nice approach until/if we find a better solution (which would often be more complicated then removing a single token).

A third approach may be:

  • add a button "change code"
  • upon request add a JTextArea with the complete current parser text
  • ending with either "restart parsing" or "abort"

GitMensch avatar Nov 27 '17 11:11 GitMensch

@GitMensch

The manual copy of the complete file + deletion of the line and restarting import on it seems even more clumsy.

No doubt. I will look for a workaround.

codemanyak avatar Nov 27 '17 14:11 codemanyak

ping with a reference to #472 and the same suggestion to replace the label with "question"

GitMensch avatar Feb 01 '18 11:02 GitMensch

@GitMensch Same answer as for #472.

codemanyak avatar Feb 02 '18 11:02 codemanyak