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

use "relational.sml"; results in errors. #89

Open
DavidPratten opened this issue Dec 5, 2021 · 3 comments
Open

use "relational.sml"; results in errors. #89

DavidPratten opened this issue Dec 5, 2021 · 3 comments

Comments

@DavidPratten
Copy link

Hi,

Running https://github.com/julianhyde/morel/blob/main/src/test/resources/script/relational.sml using "use".

Does is this .sml file have dependencies?

use "relational.sml";

Appears to have multiple levels of issues.

  1. Fatal. Keeping the multi-line comments, the interpreter gives up with:
net.hydromatic.morel.parse.TokenMgrError: Lexical error at line 3, column 27.  Encountered: <EOF> after : ""
        at net.hydromatic.morel.parse.MorelParserImplTokenManager.getNextToken(MorelParserImplTokenManager.java:1434)
        at net.hydromatic.morel.parse.MorelParserImpl.jj_ntk_f(MorelParserImpl.java:2787)
        at net.hydromatic.morel.parse.MorelParserImpl.statement(MorelParserImpl.java:2174)
        at net.hydromatic.morel.parse.MorelParserImpl.statementSemicolon(MorelParserImpl.java:2212)
        at net.hydromatic.morel.Shell$SubShell.extracted(Shell.java:477)
        at net.hydromatic.morel.Shell$SubShell$Use.use(Shell.java:541)
        at net.hydromatic.morel.eval.Session.use(Session.java:61)
        at net.hydromatic.morel.eval.Codes$21.apply(Codes.java:323)
        at net.hydromatic.morel.eval.Codes$ApplyCode.eval(Codes.java:2657)
        at net.hydromatic.morel.compile.Compiler.lambda$compileValDecl$17(Compiler.java:610)
        at net.hydromatic.morel.compile.Compiler$1.lambda$eval$0(Compiler.java:99)
        at net.hydromatic.morel.util.ThreadLocals.let(ThreadLocals.java:37)
        at net.hydromatic.morel.compile.Compiler$1.eval(Compiler.java:95)
        at net.hydromatic.morel.Shell$SubShell.lambda$extracted$0(Shell.java:484)
        at net.hydromatic.morel.eval.Session.withShell(Session.java:50)
        at net.hydromatic.morel.Shell$SubShell.extracted(Shell.java:483)
        at net.hydromatic.morel.Shell.run(Shell.java:264)
        at net.hydromatic.morel.Shell.main(Shell.java:88)
  1. Negative Tests? After removing the multi-line comments the interpreter runs to completion but generates multiple instances like this:
Encountered "<EOF>" at line 2, column 18.
Was expecting one of:
    "datatype" ...
    "fun" ...
    "in" ...
    "val" ...

Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    "case" ...
    "datatype" ...
    "fn" ...
    "fun" ...
    "if" ...
    "let" ...
    "val" ...
    "from" ...
    <NON_NEGATIVE_INTEGER_LITERAL> ...
    <NEGATIVE_INTEGER_LITERAL> ...
    <REAL_LITERAL> ...
    <SCIENTIFIC_LITERAL> ...
    <QUOTED_STRING> ...
    <CHAR_LITERAL> ...
    "(" ...
    "{" ...
    "[" ...
    "~" ...
    <IDENTIFIER> ...
    <LABEL> ...
@julianhyde
Copy link
Collaborator

julianhyde commented Dec 6, 2021

I'm not at all surprised by this. The problem is that we use the .sml file suffix for two different languages - Morel scripts (such as can be run from the morel shell, and included from the shell via the use function) and test scripts (such as can be run using ScriptTest).

The requirements are different. We want tests to echo their input and output, and we want them to print an error and carry on if a command fails.

Both languages support the use function. But when you use use, they assume that the script is in the same language. Currently, the two languages each have their own implementation of use.

It might be possible to unify the languages by adding some built-in functions to control whether scripts echo their input, whether they carry on in the event of errors. These would have to be Morel functions, not merely directives to the shell. We have a few examples of such functions already: Sys.plan, Interact.use, Sys.set, Sys.show.

Also we would need to unify how we treat block comments (* ... *) and blank lines.

In summary, this is a bug, but it is low priority. Contributions welcome.

@DavidPratten
Copy link
Author

OK so there are some negative test cases in relational.sml?

That just leaves comment handling to sort out - right?

@julianhyde
Copy link
Collaborator

Sounds about right. We definitely need negative tests (and they can't cause the script to bomb out). I have not analyzed it in detail. As I said, it did not occur to me to run test scripts via use from the shell.

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

2 participants