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

Parser error on one-element lists #17

Open
AJnsm opened this issue Nov 25, 2022 · 1 comment
Open

Parser error on one-element lists #17

AJnsm opened this issue Nov 25, 2022 · 1 comment

Comments

@AJnsm
Copy link

AJnsm commented Nov 25, 2022

Description

When specifying an action space with a one-element list, this results in a parser error.

Minimal open game with this behaviour:

testGame = [opengame|
   inputs    :  ;
   feedback  :  ;
   :---------------------------:
   inputs:    ;
   feedback:  ;
   operation: dependentDecision "p1" (const [1]);
   outputs: discardedOutput;
   returns: 0;
   :----------------------------:
   outputs   :  ;
   returns   :  ;
   |]

Expected behaviour

The game compiles.

Actual behaviour

Compilation raises the following error:

/open-games-hs/src/Examples/PieCutting_open.hs:171:12: error:
    • Exception when trying to run compile-time code:
        "verbose parser" (line 6, column 47):
unexpected "]"
expecting digit, "(", "if", "\\", identifier, natural, literal string, "[", "do", "let", operator, "," or ".."
CallStack (from HasCallStack):
  error, called at /open-games-hs/src/Preprocessor/Compile.hs:108:39 in main:Preprocessor.Compile
      Code: Language.Haskell.TH.Quote.quoteExp
              opengame
              "\n\
              \   inputs    :  ;\n\
              \   feedback  :  ;\n\
              \   :---------------------------:\n\
              \   inputs:    ;\n\
              \   feedback:  ;\n\
              \   operation: dependentDecision \"p1\" (const [1]);\n\
              \   outputs: discardedOutput;\n\
              \   returns: 0;\n\
              \   :----------------------------:\n\
              \   outputs   :  ;\n\
              \   returns   :  ;\n\
              \   "
    • In the quasi-quotation:
        [opengame|
   inputs    :  ;
   feedback  :  ;
   :---------------------------:
   inputs:    ;
   feedback:  ;
   operation: dependentDecision "p1" (const [1]);
   outputs: discardedOutput;
   returns: 0;
   :----------------------------:
   outputs   :  ;
   returns   :  ;
   |]
    |
171 | testGame = [opengame|
    |            ^^^^^^^^^^...
Failed, 38 modules loaded.

Current solution

Specify the game like this:

testGame = [opengame|
   inputs    :  ;
   feedback  :  ;
   :---------------------------:
   inputs:    ;
   feedback:  ;
   operation: dependentDecision "p1" (const lsOne);
   outputs: discardedOutput;
   returns: 0;
   :----------------------------:
   outputs   :  ;
   returns   :  ;
   |]
    where 
        lsOne = [1]

This compiles, but is not a very nice solution, so changing the parser to be able to deal with this would be nicer.

@AJnsm
Copy link
Author

AJnsm commented Nov 28, 2022

Update: this bug also gets triggered for action spaces with a specified resolution:

operation : dependentDecision playerName (\x -> [0, 0.1 .. x]) ;

A similar where statement as above can get around this for the time being.

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