2015-01-15 21:21:40 -08:00
#!/usr/bin/perl
2021-07-10 15:00:22 -07:00
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT
2015-01-15 21:21:40 -08:00
use warnings ;
use strict ;
2022-01-23 07:49:23 -08:00
package Languages::tendra ;
use parent 'Languages::_c_base' ;
2015-01-15 21:21:40 -08:00
sub initialize {
my ( $ self , % conf ) = @ _ ;
$ self - > { sourcefile } = 'prog.c' ;
$ self - > { execfile } = 'prog' ;
2015-01-16 17:29:41 -08:00
$ self - > { default_options } = '-Xp -Yansi' ;
2015-01-21 17:43:39 -08:00
$ self - > { cmdline } = 'tcc $sourcefile $options -o $execfile' ;
2015-01-15 21:21:40 -08:00
2015-07-17 00:32:26 -07:00
$ self - > { no_gdb_extensions } = 1 ;
2015-01-15 21:21:40 -08:00
$ self - > { prelude } = << 'END' ;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2015-01-17 04:40:00 -08:00
#include <float.h>
2015-01-15 21:21:40 -08:00
#include <math.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#include <assert.h>
#include <locale.h>
#include <setjmp.h>
#include <signal.h>
2015-01-17 04:40:00 -08:00
#include <time.h>
#include <stdarg.h>
#include <stddef.h>
2015-01-15 21:21:40 -08:00
2015-07-12 02:54:08 -07:00
#define print_last_statement(s) s
2015-01-15 21:21:40 -08:00
END
}
2015-01-16 17:29:41 -08:00
sub postprocess_output {
my $ self = shift ;
$ self - > SUPER:: postprocess_output ;
2015-01-16 22:24:54 -08:00
$ self - > { output } =~ s/^\n+//mg ;
2015-01-16 17:29:41 -08:00
$ self - > { output } =~ s/^\[Warning: Directory 'c89' already defined.\]\s*// ;
$ self - > { output } =~ s/\s*Warning: Directory 'c89' already defined.//g ;
2015-01-16 22:24:54 -08:00
if ( ( not exists $ self - > { options } - > { '-paste' } ) and ( not defined $ self - > { got_run } or $ self - > { got_run } ne 'paste' ) ) {
2015-01-16 17:29:41 -08:00
$ self - > { output } =~ s/"$self->{sourcefile}", line \d+:\s*//g ;
2015-01-16 22:24:54 -08:00
$ self - > { output } =~ s/Error:\s+\[/Error: [/g ;
2015-01-16 17:29:41 -08:00
$ self - > { output } =~ s/Warning:\s+\[/Warning: [/g ;
2015-01-21 01:05:49 -08:00
$ self - > { output } =~ s/^\[\s+(Warning|Error)/[$1/ ;
2015-01-16 17:29:41 -08:00
}
2015-07-12 02:54:08 -07:00
if ( $ self - > { channel } =~ m/^#/ ) {
$ self - > { output } =~ s/^/[Notice: TenDRA is missing support for candide extensions; use `cc` or `clang` instead.]\n/ unless $ self - > { output } =~ m/^tcc: Version/ ;
}
2015-01-16 17:29:41 -08:00
}
2015-01-15 21:21:40 -08:00
1 ;