Page 1 of 1

Error when compiling multiple files

PostPosted: Sun May 09, 2010 11:47 am
by Gameday
Let's say I have these two classes:

x.cobra
Code: Select all
class X
   get a from var = ""


and

e.cobra
Code: Select all
class T
   def main is shared
      x = X()
      puts x.a


When I run them, like cobra -c x.cobra e.cobra, I receive this error:
Code: Select all
e.cobra(4): error: e.cobra(4,8): error: Expecting EOL, but got "x" (ID) instead.
Compilation failed - 1 error, 0 warnings


If I run them separately, after adding a main method to the first file, they work. What am I doing wrong?

Re: Error when compiling multiple files

PostPosted: Sun May 09, 2010 5:41 pm
by Charles
I get that error too until I change "puts" to "print". They probably worked when you compiled separately because you commented out the "puts" line to do so.

Re: Error when compiling multiple files

PostPosted: Sun May 09, 2010 6:49 pm
by Charles
I enhanced the compiler to suggest "print" when it sees "puts" in this circumstance. It now reads:
Code: Select all
error: Expecting EOL, but got "x" (ID) instead. Try "print" instead of "puts".

There are already suggestions for various bits of Python, C# and Visual Basic that have direct corollaries in Cobra, but different names, so this type of enhancement fits in well.

Re: Error when compiling multiple files

PostPosted: Sun May 09, 2010 10:24 pm
by Gameday
Oh my god!
I didn't even notice I had "puts" there. I'm so sorry, it's just I've been using Ruby for such a long time, it's kind of like second nature. :oops:

Re: Error when compiling multiple files

PostPosted: Sun May 09, 2010 10:26 pm
by Charles
No apology necessary. Other Ruby users will have the same experience so this will lead to a useful improvement to the compiler which help people out.

Re: Error when compiling multiple files

PostPosted: Mon May 10, 2010 9:03 pm
by CodexArcanum
The cobra compiler's suggestions are pretty amazingly helpful, works out well since there's not Intellisense/Autocomplete for it yet. Just today I had something about foo.width, which doesn't exist, and the compiler suggested that maybe I meant foo.getFooWidth. That was, indeed, the call I needed.