Prettified a little

master
Yevgen Muntyan 2007-07-17 11:53:03 -05:00
parent bbbe5ea899
commit a3d4734d3c
4 changed files with 56 additions and 42 deletions

View File

@ -36,12 +36,12 @@
<style id="string" _name="String" map-to="def:string"/>
<style id="escape" _name="Escape" map-to="def:escape"/>
<style id="preprocessor" _name="Preprocessor" map-to="def:preprocessor"/>
<style id="common-defines" _name="Common defines" map-to="def:special-value"/>
<style id="common-defines" _name="Common Defines" map-to="def:special-value"/>
<style id="included-file" _name="Included File" map-to="c:preprocessor"/>
<style id="char" _name="Character" map-to="def:character"/>
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
<style id="data-type" _name="Data Type" map-to="def:data-type"/>
<style id="printf" _name="printf conversion" map-to="def:character"/>
<style id="printf" _name="printf Conversion" map-to="def:character"/>
<style id="escaped-character" _name="Escaped Character" map-to="def:escape"/>
<style id="floating-point" _name="Float" map-to="def:floating-point"/>
<style id="decimal" _name="Decimal" map-to="def:decimal"/>

View File

@ -2,6 +2,7 @@
import xml.dom.minidom as dom
import cgi
import sys
default_styles = {
'Comment' : 'def:comment',
@ -21,6 +22,15 @@ default_styles = {
'Others 3' : None,
}
def get_default_style(style):
map_to = default_styles[style]
if map_to is None:
print >> sys.stderr, "Warning: '%s' style is used, it is replaced with 'foobar'. Fix it after converting" % (style,)
map_to = 'foobar'
elif map_to == 'def:preprocessor':
print >> sys.stderr, "Warning: '%s' style is used, it is highly unlikely this use is correct, check after converting" % (style,)
return map_to
def escape_escape_char(ch):
if ch == '\\':
return '\\\\'
@ -105,7 +115,7 @@ class LangFile(object):
string = indent + "<styles>\n"
styles = {}
for ctx in self.contexts:
map_to = default_styles[ctx.style_name]
map_to = get_default_style(ctx.style_name)
styles[ctx.style] = [ctx.style_name, map_to]
for s in styles:
id = s

View File

@ -40,7 +40,7 @@
<style id="shebang" _name="Shebang"/>
<style id="doc-comment" _name="Documentation Comment" map-to="def:comment"/>
<style id="doc-comment-element" _name="Documentation Comment Element"/>
<!-- This one is for '#include <foo.h>' and "#pragma blah" and ''. -->
<!-- This one is for '#include <foo.h>' and "#pragma blah", or 'use foobar', etc.. -->
<style id="preprocessor" _name="Preprocessor directive"/>
<!-- For things like TRUE and NULL in C. -->
<style id="special-value" _name="Special value" map-to="def:preprocessor"/>

View File

@ -1,5 +1,9 @@
#!/bin/sh
# Running this file will create "testdir" directory with bunch
# of files inside. Open them all to see if something broke.
# Kind of smoke test.
# Langs covered here:
# changelog.lang c.lang cpp.lang desktop.lang diff.lang dtd.lang
# gap.lang gtkrc.lang html.lang ini.lang latex.lang m4.lang
@ -28,6 +32,44 @@ int main (void)
}
EOFEOF
cat > $dir/file.m <<EOFEOF
#import <stdio.h>
#import <Object.h>
@interface Lalala : Object
- (BOOL) sayHello;
@end
@implementation Lalala : Object
- (BOOL) sayHello
{
printf ("Hello there!\n");
return YES;
}
@end
int main (void)
{
Lalala *obj = [[Lalala alloc] init];
[obj sayHello];
[obj free];
return 0;
}
EOFEOF
cat > $dir/file.h <<EOFEOF
/* A C header damn it */
#include <foo.h>
#import <Object.h>
@interface Lalala : Object
- (void) sayHello;
@end
class Boo {
void hello ();
};
EOFEOF
cat > $dir/ChangeLog <<EOFEOF
2006-12-10 Kristian Rietveld <kris@gtk.org>
@ -507,41 +549,3 @@ Version:
Cflags: -I${prefix}/include/moo
Libs: -L${libdir} -lmoo -L/usr/lib/python2.4 -lpython2.4 -lpthread -ldl -lutil
EOFEOF
cat > $dir/file.m <<EOFEOF
#import <stdio.h>
#import <Object.h>
@interface Lalala : Object
- (BOOL) sayHello;
@end
@implementation Lalala : Object
- (BOOL) sayHello
{
printf ("Hello there!\n");
return YES;
}
@end
int main (void)
{
Lalala *obj = [[Lalala alloc] init];
[obj sayHello];
[obj free];
return 0;
}
EOFEOF
cat > $dir/file.h <<EOFEOF
/* A C header damn it */
#include <foo.h>
#import <Object.h>
@interface Lalala : Object
- (void) sayHello;
@end
class Boo {
void hello ();
};
EOFEOF