Groovy
  1. Groovy
  2. GROOVY-2178

Shell can not handle multi-line list defs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.6, 2.2.0-beta-1
    • Fix Version/s: 2.4.6
    • Component/s: Groovysh
    • Labels:
      None

      Description

      Things like this, while valid Groovy, don't eval in groovysh:

      a = [
          1,
          2,
          3
      ]
      

      Pukes up something like:

      groovy:000> a = [
      groovy:001> 1,
      groovy:002> 2,
      groovy:003> 3
      ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, groovysh_parse: 4: unexpected token: 3 @ line 4, column 1.
         3
         ^
      
      1 error
      

      Though this works:

      a = [
          1,
          2,
          3,
      ]
      

        Activity

        Hide
        Guillaume Delcroix added a comment -

        Jason, in case you've got some spare cycles, you can have a look at it, otherwise I'm scheduling it for 1.7 for the moment.

        Show
        Guillaume Delcroix added a comment - Jason, in case you've got some spare cycles, you can have a look at it, otherwise I'm scheduling it for 1.7 for the moment.
        Hide
        Jason Dillon added a comment -

        This is parser voodoo to me... I wish I could fix this, but the truth is that the parser doesn't like line by line compilation similar to how python works.

        Show
        Jason Dillon added a comment - This is parser voodoo to me... I wish I could fix this, but the truth is that the parser doesn't like line by line compilation similar to how python works.
        Hide
        Jochen Theodorou added a comment -

        well, you could try to not to send incomplete scripts to the compiler. For example if there is a open [(

        {, then do not send before the corresponding }

        )] is given. Also a line is incomplete if it ends with one of ,.-+/*%&|?<>=: and not to forget open strings. Writing something that recognizes this should not be too difficult.

        Show
        Jochen Theodorou added a comment - well, you could try to not to send incomplete scripts to the compiler. For example if there is a open [( {, then do not send before the corresponding } )] is given. Also a line is incomplete if it ends with one of ,.-+/*%&|?<>=: and not to forget open strings. Writing something that recognizes this should not be too difficult.
        Hide
        ASF GitHub Bot added a comment -

        GitHub user jwagenleitner opened a pull request:

        https://github.com/apache/incubator-groovy/pull/181

        GROOVY-2178 - Shell can not handle multi-line list defs

        To address @blackdrag's comments on the issue, there was already some code that handles [detecting incomplete lines] (https://github.com/apache/incubator-groovy/blob/1eb37ea96428e14f0418fa003292cce9d3f94f94/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/Parser.groovy#L204-L212) and it looks like it captures all the chars referenced in the comment. I wasn't able to replicate the problem with opened braces `{` so am just trying to detect (if compilation error is thrown) if there's an unmatched bracket `[` or paren `(`.

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/jwagenleitner/incubator-groovy GROOVY-2178

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/incubator-groovy/pull/181.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #181


        commit 314e6858dce81d5e6ca585b104c495fe5e220a0d
        Author: John Wagenleitner <john.wagenleitner@gmail.com>
        Date: 2015-11-07T15:28:48Z

        GROOVY-2178 - Shell can not handle multi-line list defs


        Show
        ASF GitHub Bot added a comment - GitHub user jwagenleitner opened a pull request: https://github.com/apache/incubator-groovy/pull/181 GROOVY-2178 - Shell can not handle multi-line list defs To address @blackdrag's comments on the issue, there was already some code that handles [detecting incomplete lines] ( https://github.com/apache/incubator-groovy/blob/1eb37ea96428e14f0418fa003292cce9d3f94f94/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/Parser.groovy#L204-L212 ) and it looks like it captures all the chars referenced in the comment. I wasn't able to replicate the problem with opened braces `{` so am just trying to detect (if compilation error is thrown) if there's an unmatched bracket `[` or paren `(`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jwagenleitner/incubator-groovy GROOVY-2178 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-groovy/pull/181.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #181 commit 314e6858dce81d5e6ca585b104c495fe5e220a0d Author: John Wagenleitner <john.wagenleitner@gmail.com> Date: 2015-11-07T15:28:48Z GROOVY-2178 - Shell can not handle multi-line list defs
        Hide
        ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/incubator-groovy/pull/181

        Show
        ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/incubator-groovy/pull/181
        Hide
        Pascal Schumacher added a comment -

        Pull request merged! Thanks!

        Show
        Pascal Schumacher added a comment - Pull request merged! Thanks!

          People

          • Assignee:
            Pascal Schumacher
            Reporter:
            Jason Dillon
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development