Forums

Request For Help: cobra2html via Pygments

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

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Mon Mar 31, 2008 11:36 am


* The highlighter is confused by generics.
* Doesn't recognize the nilable suffix ("?" in "int?")
* Doesn't recognize the "!" in "foo to !" which is a typecast to non-nil.
* Declared method names get special highlighting, but not property names.

Fixed, fixed, fixed and property names are picked up, but reference css style 'py', which doesn't look any different to normal text (at least not on my screen).

I use the same commandline as you in order to get the css inlined; if I work out how to do it properly I'll let you know.
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Mon Mar 31, 2008 2:23 pm

I take that back - generics are harder than I thought (and are still borked) - will have to do it 'properly'. *puts thinking cap on*
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Mon Mar 31, 2008 4:17 pm

Right, generics fixed (I hope!)

Identified issues:
- namespace when *not* used as a keyword (i.e. foo.namespace) is a nightmare
- can't get $ to work properly

Will keep releasing fixes as they come and post here / respond to bugs
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Wed Apr 02, 2008 10:29 am

So, in trying to write a pathological case (from a code highlighting point of view) I came up with the following:
use System.Collections

namespace Foo

class Hard

def in(paths as List<of String>, writeTestInvocation as bool)
pass

var _dictionary as IDictionary<of System.Type, String>?

def def(fileNames as IList<of String>, options as dynamic?, resultsWriter as uint32, verbose as bool)
.namespace([[1] to List<of uint>,[1,2,3] to List<of uint>], 'bar')
print 'double quoted string'

def namespace(foo as List<of List<of uint>>, bar) as List<of String?>
has MustUseResult
print 'single quoted string'
.in(['one', 'two'], false)
return ['Foo', 'Bar'] to !


var _string as String = ''

var intlist as List<of int> = [1,2,3]

var four = 4

var five as int = 5

var str = "string"

shared
#Following generates a warning
def main
Hard().def(['one', 'two'], nil, 42, false)

which yields a
Code: Select all
error: COBRA INTERNAL ERROR / NullReferenceException / Object reference not set to an instance of an objectObject reference not set to an instance of an objectObject reference not set to an instance of an objectObject reference not set to an instance of an object
Compilation failed - 1 error, 0 warnings

error, with latest svn and mono 1.2.6 on OSX, and I can't see why.

Is it worth posting to the forum when one gets an error like this? Is there any more information we can give you to help with diagnosis?
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby Charles » Wed Apr 02, 2008 10:46 am

This is definitely the right place to post and I love getting this information. Often I'm able to fix these problems within 24 hours and, of course, I lock them down with a regression test case.

Thanks for including the version of Cobra, Mono and Mac. (Btw I upgraded from Mono 1.2.6 to 1.9 on the Mac and Mono is working fine.)

The only other thing I would ask is that for longer examples like this, attach the file for subsequent downloading.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Request For Help: cobra2html via Pygments

Postby Charles » Wed Apr 02, 2008 10:40 pm

Fixed.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Thu Apr 03, 2008 10:13 am

Fix verified. Btw, it feels like
Code: Select all
var _intlist2 as List<of int>= [1,2,3]

ought to be valid code, but it yields
Code: Select all
error: tests/examplefiles/hard.cobra(46,31): error: Expecting COMMA, but got ">=" (GE) instead.

Any views?
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby Charles » Thu Apr 03, 2008 10:45 am

Interesting. The tokenizer is picking up ">=" which is confusing the parser. I had the same problem with ">>" a long time ago. Will fix.

Obviously the workaround is to put a space before "=".
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Request For Help: cobra2html via Pygments

Postby themaniac » Thu Apr 03, 2008 4:39 pm

Added lots of improvements to the pygments parser (including fixing problems with $, generics and .<keyword> references).

Can now qualify how much better it is - I don't get any pygments error tokens generated when looking at the contents of the cobra Source/ dir

(That said, there may be stuff that is incorrectly classified).

I have committed hard.cobra in the tests/examplefiles/ directory as my regression testing file.

Fwiw, the parser is now *way* more complicated than any of teh other dotnet ones - don't know whether that's because cobra is more complicated or because there's more context needed. (i.e. Foo inherits Bar is either a declaration of Inheritance or a test for it).

Do you need the cobra.css stylesheeting stuff sorted before you can plug it into trac?
themaniac
 
Posts: 28

Re: Request For Help: cobra2html via Pygments

Postby Charles » Fri Apr 04, 2008 9:23 am

Not sure about the Trac plugin. My biggest Trac headache right now is that by default its set up for private editing. There is a plugin to give it a public signup and login process, but then I realized what I really wanted was for a public login page that uses the phpBB3 user table so people can have just one login.

It's should be doable as Trac is open source in Python and both db's are on MySQL. Whether it means having Trac read the table directly or having some cron job copy the phpBB3 table over to the Trac database, I don't know. I haven't had any time to look into it.

I'll give the highlighter another run this weekend. Sounds like it's in good shape!
Charles
 
Posts: 2515
Location: Los Angeles, CA

PreviousNext

Return to Discussion

Who is online

Users browsing this forum: No registered users and 27 guests

cron