groovy
  1. groovy
  2. GROOVY-2178

Shell can not handle multi-line list defs

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.6, 2.2.0-beta-1
    • Fix Version/s: None
    • Component/s: Groovysh
    • Labels:
    • Number of attachments :
      0

      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 Laforge 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 Laforge 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
        blackdrag blackdrag 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
        blackdrag blackdrag 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.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jason Dillon
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: