Project

General

Profile

ScannerRequests » History » Version 1

Kornelius Kalnbach, 01/29/2009 12:31 AM

1 1 Kornelius Kalnbach
h1. Scanner Requests
2 1 Kornelius Kalnbach
3 1 Kornelius Kalnbach
Scanners are the heart of CodeRay. They split input code into tokens and classify them.
4 1 Kornelius Kalnbach
5 1 Kornelius Kalnbach
Each language has its own scanner: You can see what languages are currently supported in the "repository":http://code.licenser.net/repositories/browse/coderay/trunk/lib/coderay/scanners.
6 1 Kornelius Kalnbach
7 1 Kornelius Kalnbach
h2. Why is the CodeRay language support list so short?
8 1 Kornelius Kalnbach
9 1 Kornelius Kalnbach
CodeRay developing is a slow process, because the total number of active developers is 1 and he insists on high software quality.
10 1 Kornelius Kalnbach
11 1 Kornelius Kalnbach
Special attention is paid to the scanners: every CodeRay scanner is being tested carefully against lots of examle source code, and also randomized and junk code to make it safe. A CodeRay scanner is not officially released unless it highlights very, very well.
12 1 Kornelius Kalnbach
13 1 Kornelius Kalnbach
h2. I need a new Scanner - What can I do?
14 1 Kornelius Kalnbach
15 1 Kornelius Kalnbach
Here's what you can do to speed up the development of a new scanner:
16 1 Kornelius Kalnbach
17 1 Kornelius Kalnbach
# Request it! File a "new ticket":http://code.licenser.net/projects/coderay/issues/new unless it already "exists":http://code.licenser.net/projects/coderay/issues?query_id=3; add a +1 or something to existing tickets to show your interest.
18 1 Kornelius Kalnbach
# Upload or link to *example code* in the ticket discussion.
19 1 Kornelius Kalnbach
#* Typical code in large quantities is very helpful, also for benchmarking.
20 1 Kornelius Kalnbach
#* But we also need the most *weird and strange code* you can find to make the scanner.
21 1 Kornelius Kalnbach
# Provide links to useful *information about the language lexic*, such as:
22 1 Kornelius Kalnbach
#* a list of reserved words (Did you know that "void" is a JavaScript keyword?)
23 1 Kornelius Kalnbach
#* rules for string and number literals (Can a double quoted string contain a newline?)
24 1 Kornelius Kalnbach
#* rules for comments and other token types (Does XYZ have a special syntax for multiline comments?)
25 1 Kornelius Kalnbach
#* a description of any unusual syntactic features (There's this weird %w() thing in Ruby...)
26 1 Kornelius Kalnbach
#* If there are different versions / implementations / dialects of this language: How do they differ?
27 1 Kornelius Kalnbach
# Give examples for *good and bad highlighters / syntax definitions* for the language (usually from editors or other libraries)
28 1 Kornelius Kalnbach
# Find *more example code*!
29 1 Kornelius Kalnbach
30 1 Kornelius Kalnbach
Also, read the next paragraph.
31 1 Kornelius Kalnbach
32 1 Kornelius Kalnbach
h2. I want to write a Scanner myself
33 1 Kornelius Kalnbach
34 1 Kornelius Kalnbach
Wow, you're brave! Writing CodeRay scanners is not an easy task because:
35 1 Kornelius Kalnbach
36 1 Kornelius Kalnbach
* You need excellent knowledge about the language you want to scan. Every language has a dark side!
37 1 Kornelius Kalnbach
* You need good knowledge of (Ruby) regular expressions.
38 1 Kornelius Kalnbach
* There's no documentation to speak of.
39 1 Kornelius Kalnbach
** But this is a wiki ^hint hint^ ;o)
40 1 Kornelius Kalnbach
41 1 Kornelius Kalnbach
But it has been done before, so go and try it!
42 1 Kornelius Kalnbach
43 1 Kornelius Kalnbach
# You should still request the scanner (as described above) and announce that you are working on a patch yourself.
44 1 Kornelius Kalnbach
# Check out the "repository":http://code.licenser.net/wiki/coderay/Repository and try the test suite (@[lang=xyz] rake test:scanners@).
45 1 Kornelius Kalnbach
# Copy a scanner of your choice as a base. You would know what language comes closest.
46 1 Kornelius Kalnbach
# Create a test case directory in @test/scanners@.
47 1 Kornelius Kalnbach
# --- Advertisement --- (No, just kidding.)
48 1 Kornelius Kalnbach
# Write your scanner!
49 1 Kornelius Kalnbach
# Also, look into @lib/coderay/scanners/_map.rb@ and @lib/coderay/helpers/file_type.rb@.
50 1 Kornelius Kalnbach
# Make a patch (scanner, test cases and other changes) and upload it to the ticket.
51 1 Kornelius Kalnbach
# Follow the following discussion.
52 1 Kornelius Kalnbach
# Prepare to be added to the THX list.
53 1 Kornelius Kalnbach
54 1 Kornelius Kalnbach
Contact me (murphy) if you have any questions.