#! perl # Copyright (C) 2003-2006, The Perl Foundation. # $Id: kate_syntax.pl 23195 2007-11-28 16:02:36Z kjs $ # Create Kate syntax highlighting XML file for IMCC # Language: Parrot IMCC # Maintainer: Andy Bussey , Parrot Team # Last change: 2007 May 22 use strict; use warnings; my $parrot = $ARGV[0]; if ( $parrot eq '-h' ) { print "kate_syntax.pl\n\n", "Create Kate syntax highlighting file for Parrot IMCC.\n", "Supply the path to your Parrot directory as the only\n", "argument. The XML file will be written to the standard\n", "output.\n\n"; exit; } $parrot =~ s/\/$//; my @imcc_oplike = qw(.sym .arg prototyped non_prototyped .class .endclass .param inc dec new defined addr global clone saveall restoreall); my @imcc_spdirec = qw(.call .result .return .local .const .globalconst end goto if unless call branch jump jsr ret invoke invokecc throw rethrow die_hard .emit .eom .sub .end .begin_call .end_call .pcc_sub .begin_return .end_return .begin_yield .end_yield .loadlib .namespace .endnamespace .macro .include); my @pod_start = qw(head[1-6] over back item for begin end pod); my $pod_start_rx = join '|', @pod_start; my @imcc_basic_types = qw(int float string pmc); my $parrot_pmcsh_file = "include/parrot/core_pmcs.h"; my $date = localtime(time); my $ops_dir = "$parrot/src/ops"; opendir my $PARROT, "$ops_dir" or die "Supply Parrot directory as argument!"; my @ops_files = map { "$ops_dir/$_" } grep /\.ops$/, readdir $PARROT; closedir $PARROT; print < END my %ops; for my $dir (@imcc_spdirec) { $dir =~ s/\.//g; print " $dir\n"; $ops{$dir} = 1; } print < END for my $ops_file (@ops_files) { open my $OPS, "<", "$ops_file" or die "Can't read $ops_file!"; while (<$OPS>) { next unless (/^(inline\s+)?op\s+([a-zA-Z]\w*)/); my $op = $2; $op =~ s/\.//g; next if ( $ops{$op} ); print " $op\n"; $ops{$op} = 1; } } for my $op (@imcc_oplike) { $op =~ s/\.//g; next if ( $ops{$op} ); print " $op\n"; $ops{$op} = 1; } print < END my %types; for my $type (@imcc_basic_types) { $type =~ s/\./\&046;/g; next if ( $types{$type} ); print " $type\n"; $types{$type} = 1; } open my $TYPES, "<", "$parrot/$parrot_pmcsh_file" or die "Can't read $parrot/$parrot_pmcsh_file!"; while (<$TYPES>) { next unless (/^\s+enum_class_(\w+)\,/); my $type = $1; $type =~ s/\./\&046;/g; print " $type\n"; $types{$type} = 1; } close $TYPES; print < END print < END print < END print < END print < END print < END print < END # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 100 # End: # vim: expandtab shiftwidth=4: