3 # Copyright (C) 2003-2006, Parrot Foundation.
6 # Create Kate syntax highlighting XML file for IMCC
7 # Language: Parrot IMCC
8 # Maintainer: Andy Bussey <andybussey@yahoo.co.uk>, Parrot Team
9 # Last change: 2007 May 22
14 my $parrot = $ARGV[0];
16 if ( $parrot eq '-h' ) {
17 print "kate_syntax.pl\n\n", "Create Kate syntax highlighting file for Parrot IMCC.\n",
18 "Supply the path to your Parrot directory as the only\n",
19 "argument. The XML file will be written to the standard\n", "output.\n\n";
25 my @imcc_oplike = qw( .sym .arg prototyped non_prototyped .class
26 .endclass .param inc dec new defined global clone );
28 my @imcc_spdirec = qw(.call .result .return .local .const .globalconst
29 end goto if unless call branch jump jsr ret invoke invokecc throw
30 rethrow die_hard .emit .eom .sub .end .begin_call
31 .end_call .pcc_sub .begin_return .end_return .begin_yield
32 .end_yield .loadlib .namespace .endnamespace .macro .include);
33 my @pod_start = qw(head[1-6] over back item for begin end pod);
34 my $pod_start_rx = join '|', @pod_start;
35 my @imcc_basic_types = qw(int float string pmc);
36 my $parrot_pmcsh_file = "include/parrot/core_pmcs.h";
37 my $date = localtime(time);
39 my $ops_dir = "$parrot/src/ops";
40 opendir my $PARROT, "$ops_dir" or die "Supply Parrot directory as argument!";
41 my @ops_files = map { "$ops_dir/$_" } grep /\
.ops
$/, readdir $PARROT;
45 <?xml version="1.0" encoding="UTF-8"?>
46 <!DOCTYPE language SYSTEM "language.dtd">
47 <!-- Created automatically by kate_syntax.pl $date -->
49 <language name="IMCC" version="0.2" kateversion="2.0"
50 section="Sources" extensions="*.pasm;*.pir" mimetype="">
54 <list name="special_directives">
58 for my $dir (@imcc_spdirec) {
60 print " <item>$dir</item>\n";
70 for my $ops_file (@ops_files) {
71 open my $OPS, "<", "$ops_file" or die "Can't read $ops_file!";
73 next unless (/^(inline\s+)?op\s+([a-zA-Z]\w*)/);
76 next if ( $ops{$op} );
77 print " <item>$op</item>\n";
82 for my $op (@imcc_oplike) {
84 next if ( $ops{$op} );
85 print " <item>$op</item>\n";
96 for my $type (@imcc_basic_types) {
97 $type =~ s/\./\&046;/g;
98 next if ( $types{$type} );
99 print " <item>$type</item>\n";
103 open my $TYPES, "<", "$parrot/$parrot_pmcsh_file"
104 or die "Can't read $parrot/$parrot_pmcsh_file!";
106 next unless (/^\s+enum_class_(\w+)\,/);
108 $type =~ s/\./\&046;/g;
109 print " <item>$type</item>\n";
119 <context name="default" attribute="Normal Text" lineEndContext="#stay">
120 <RegExpr attribute="Label" context="#stay" String="[_\\w]+\\:" />
121 <keyword attribute="Op" context="#stay" String="ops" />
122 <keyword attribute="Special Directive" context="#stay"
123 String="special_directives" />
124 <keyword attribute="Type" context="#stay" String="types" />
125 <RegExpr attribute="Comment" context="#stay" String="#.*\$" />
126 <RegExpr attribute="Comment" context="pod"
127 String="^\\=($pod_start_rx).*" />
128 <HlCOct attribute="Octal" context="#stay" />
129 <HlCHex attribute="Hex" context="#stay" />
130 <Float attribute="Float" context="#stay" />
131 <Int attribute="Int" context="#stay" />
135 <RegExpr attribute="Register" context="#stay"
136 String="[INSP](\\d|[12]\\d|3[01])" />
137 <RegExpr attribute="TempRegister" context="#stay"
138 String="\\\$[INSP]\\d+" />
139 <RegExpr attribute="String" context="string" String="'" />
140 <RegExpr attribute="String Interp" context="string_interp"
142 <RegExpr attribute="Identifier" context="#stay"
143 String="[a-zA-Z_][\\w_]*" />
149 <context name="pod" attribute="Comment" lineEndContext="#stay">
150 <LineContinue attribute="Comment" context="#stay" />
151 <RegExpr attribute="Comment" context="#stay" String="[^\=]*" />
152 <RegExpr attribute="Comment" context="#pop" String="^\\=cut\\s*\$" />
158 <context name="string" attribute="String" lineEndContext="#pop">
159 <RegExpr attribute="String" context="#pop" String="'" />
165 <context name="string_interp" attribute="String Interp"
166 lineEndContext="#pop">
167 <HlCStringChar attribute="SpChar" context="#stay" />
168 <RegExpr attribute="String Interp" context="#pop" String=""" />
177 <itemData name="Normal Text" defStyleNum="dsNormal" />
178 <itemData name="Op" defStyleNum="dsNormal" color="#000080"
179 selColor="#ffffff" bold="0" italic="0" />
180 <itemData name="Special Directive" defStyleNum="dsKeyword" />
181 <itemData name="Type" defStyleNum="dsDataType" />
182 <itemData name="Comment" defStyleNum="dsComment" />
183 <itemData name="Octal" defStyleNum="dsBaseN" />
184 <itemData name="Hex" defStyleNum="dsBaseN" />
185 <itemData name="Float" defStyleNum="dsFloat" />
186 <itemData name="Int" defStyleNum="dsDecVal" />
187 <itemData name="Label" defStyleNum="dsKeyword" />
188 <itemData name="Register" defStyleNum="dsDecVal" />
189 <itemData name="TempRegister" defStyleNum="dsDecVal" />
190 <itemData name="String" defStyleNum="dsString" color="#FF6C6C"
191 selColor="#FF6C6C" bold="0" italic="0" />
192 <itemData name="String Interp" defStyleNum="dsString" />
193 <itemData name="Identifier" defStyleNum="dsDataType" color="#C00000"
194 selColor="#C00000" bold="0" italic="0" />
195 <itemData name="SpChar" defStyleNum="dsChar" />
206 <comment name="singleLine" start="#" />
209 <keywords casesensitive="1" />
219 # cperl-indent-level: 4
222 # vim: expandtab shiftwidth=4: