Quantcast

[groovy-user] error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[groovy-user] error

John Sanabria
Hi,

i'm exciting with the versatility of groovy. ;-) great language, i'm
newbie and i have this error.

I using of groovy-1.0-jsr-03 and i try to compile an example from
ibm-developerworks, the same code and i got an unexpected token @.

The code,
------------------ Demo.groovy -----------------------
class Demo {
 fname
}
d = new Demo()
d.fname = "John"
------------------ Demo.groovy -----------------------


josanabr@linux:~/Documents/Groovy/testing/RegexFilter> groovyc Demo.groovy
Demo.groovy: 2: unexpected token: fname @ line 2, column 2.
    fname
    ^

1 Error




                    (`'`'`'`'`)
                     |       |
                     |       |
                     |       |
    -----..        (()----   |
   |        ||     (_        |
   |        ||       |       |
   |        ||       |       |
   |        ||       /\   ..--
   '--------''   /\  ||-''    \
      /   \      \ \//   ,,   \---.
   .---------.    \./ |~| /__\  \  |
___|_________|__|""-.___ / ||   |  |
|               | .-----'  ||   |  |
|               |CC.-----.      |  |
|               |  '-----'      |  |-ABG
                                |  |
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [groovy-user] error

LARSON, BRIAN (SBCSI)
You need "def" or a type for variable declarations with the newer "jsr"
syntax.  IIRC, be careful not to name things the same as the filename
(e.g. Demo.groovy and class Demo).  This will work if the file is a
class and not a script, but below you have a script with code outside of
a class declaration.  So, you need to name them differently.

------------------ MyDemo.groovy -----------------------
class Demo {
 def fname
}
d = new Demo()
d.fname = "John"
------------------ MyDemo.groovy -----------------------



-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Monday, October 31, 2005 6:44 PM
To: [hidden email]
Subject: [groovy-user] error


Hi,

i'm exciting with the versatility of groovy. ;-) great language, i'm
newbie and i have this error.

I using of groovy-1.0-jsr-03 and i try to compile an example from
ibm-developerworks, the same code and i got an unexpected token @.

The code,
------------------ Demo.groovy -----------------------
class Demo {
 fname
}
d = new Demo()
d.fname = "John"
------------------ Demo.groovy -----------------------


josanabr@linux:~/Documents/Groovy/testing/RegexFilter> groovyc
Demo.groovy
Demo.groovy: 2: unexpected token: fname @ line 2, column 2.
    fname
    ^

1 Error




                    (`'`'`'`'`)
                     |       |
                     |       |
                     |       |
    -----..        (()----   |
   |        ||     (_        |
   |        ||       |       |
   |        ||       |       |
   |        ||       /\   ..--
   '--------''   /\  ||-''    \
      /   \      \ \//   ,,   \---.
   .---------.    \./ |~| /__\  \  |
___|_________|__|""-.___ / ||   |  |
|               | .-----'  ||   |  |
|               |CC.-----.      |  |
|               |  '-----'      |  |-ABG
                                |  |
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [groovy-user] error

Martin C. Martin


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Monday, October 31, 2005 6:44 PM
> To: [hidden email]
> Subject: [groovy-user] error
>
>
> Hi,
>
> i'm exciting with the versatility of groovy. ;-) great language, i'm
> newbie and i have this error.
>
> I using of groovy-1.0-jsr-03 and i try to compile an example from
> ibm-developerworks, the same code and i got an unexpected token @.

Not quite; you got an unexpected token "fname," which was at (@) line 2,
column 2.

>
> The code,
> ------------------ Demo.groovy -----------------------
> class Demo {
>  fname
> }
> d = new Demo()
> d.fname = "John"
> ------------------ Demo.groovy -----------------------
>
>
> josanabr@linux:~/Documents/Groovy/testing/RegexFilter> groovyc
> Demo.groovy
> Demo.groovy: 2: unexpected token: fname @ line 2, column 2.
>     fname
>     ^
>
> 1 Error
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [groovy-user] error

John Sanabria
In reply to this post by LARSON, BRIAN (SBCSI)
Many thanks for your help ;-)

it works.

> You need "def" or a type for variable declarations with the newer "jsr"
> syntax.  IIRC, be careful not to name things the same as the filename
> (e.g. Demo.groovy and class Demo).  This will work if the file is a
> class and not a script, but below you have a script with code outside of
> a class declaration.  So, you need to name them differently.
>
> ------------------ MyDemo.groovy -----------------------
> class Demo {
>  def fname
> }
> d = new Demo()
> d.fname = "John"
> ------------------ MyDemo.groovy -----------------------
>
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Monday, October 31, 2005 6:44 PM
> To: [hidden email]
> Subject: [groovy-user] error
>
>
> Hi,
>
> i'm exciting with the versatility of groovy. ;-) great language, i'm
> newbie and i have this error.
>
> I using of groovy-1.0-jsr-03 and i try to compile an example from
> ibm-developerworks, the same code and i got an unexpected token @.
>
> The code,
> ------------------ Demo.groovy -----------------------
> class Demo {
>  fname
> }
> d = new Demo()
> d.fname = "John"
> ------------------ Demo.groovy -----------------------
>
>
> josanabr@linux:~/Documents/Groovy/testing/RegexFilter> groovyc
> Demo.groovy
> Demo.groovy: 2: unexpected token: fname @ line 2, column 2.
>     fname
>     ^
>
> 1 Error
>
>
>
>
>                     (`'`'`'`'`)
>                      |       |
>                      |       |
>                      |       |
>     -----..        (()----   |
>    |        ||     (_        |
>    |        ||       |       |
>    |        ||       |       |
>    |        ||       /\   ..--
>    '--------''   /\  ||-''    \
>       /   \      \ \//   ,,   \---.
>    .---------.    \./ |~| /__\  \  |
> ___|_________|__|""-.___ / ||   |  |
> |               | .-----'  ||   |  |
> |               |CC.-----.      |  |
> |               |  '-----'      |  |-ABG
>                                 |  |
>


                    (`'`'`'`'`)
                     |       |
                     |       |
                     |       |
    -----..        (()----   |
   |        ||     (_        |
   |        ||       |       |
   |        ||       |       |
   |        ||       /\   ..--
   '--------''   /\  ||-''    \
      /   \      \ \//   ,,   \---.
   .---------.    \./ |~| /__\  \  |
___|_________|__|""-.___ / ||   |  |
|               | .-----'  ||   |  |
|               |CC.-----.      |  |
|               |  '-----'      |  |-ABG
                                |  |
Loading...