Forums

Where is CobraCore?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Where is CobraCore?

Postby themaniac » Sun Mar 16, 2008 8:55 am

Hi,

Apologies in advance for the stupid question, but I've started trying to learn Cobra, and my first stumbling block was trying to find what is provided by CobraCore (and whatever the other automatically imported module is). But CobraCore isn't obviously in the svn repository:

Code: Select all
max@heaven ~/extscm/cobra $ find ./ -iname CobraCore*
max@heaven ~/extscm/cobra $


Am I missing something obvious? (or is it not in the svn repository for some reason)

Also, my first attempt to use it in anger was to create a oneliner to download a bunch of files (I'd normally use python for this). It occurred to me that it would be handy if there was some argument to the compiler to put cruft round the stuff in the file to make this easier (cf perl)?

Thus
Code: Select all
cobra -M Foo.cobra

(M for insert main or some such)

where Foo.cobra is e.g.
Code: Select all
for n in 1..10
    print n


gets interpreted as
Code: Select all
class Foo
    def main is shared
        for n in 1..10
             print n
themaniac
 
Posts: 28

Re: Where is CobraCore?

Postby Charles » Sun Mar 16, 2008 9:35 am

I think what you're missing is the use of grep which will give you more interesting results:
Code: Select all
$ grep -i "class cobracore" */*.cobra


Most of the time that I work on the implementation, I'm down in the Source/ directory. You can also find where things are used:
Code: Select all
$ grep -i truthexpr *.cobra


Actually, I have one-liner shell scripts for searching like so:
Code: Select all
$  cat ~/bin/gco
# grep cobra
grep -rniH --color --include=*.cobra --include=*.text "$*" .
$  cat ~/bin/gpy
# grep python
grep -rniH --color --include=*.py --include=*.text "$*" .
$ cd Cobra-Workspace
$ gco "class cobracore"


I like the -M idea. It will require a little bit of work to move the "use" directives out.

Since you're a shell guy, you should note that currently you cannot pass args like so:
Code: Select all
$ cobra myprog.cobra arg1 arg2


Cobra is greedy and will try to use arg1 and arg2 for itself. This was discussed earlier and will be fixed although I seem to always be tied up with other items. Patches are welcome.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 104 guests

cron