MAINTAINERS: Update for treelang deletion.

.	* MAINTAINERS: Update for treelang deletion.
gcc
2008-03-05  Tom Tromey  <tromey@redhat.com>

	* treelang: Delete.
	* doc/standards.texi (Standards): Don't mention treelang.
	* doc/invoke.texi (Overall Options): Don't mention treelang.
	* doc/install.texi (Prerequisites): Don't mention bison or
	treelang.
	(Configuration): Don't mention treelang.
	(Building): Likewise.
	* doc/frontends.texi (G++ and GCC): Don't mention treelang.
gcc/testsuite
	* lib/treelang-dg.exp, lib/treelang.exp: Delete.
	* treelang: Delete.
gcc/testsuite/treelang
Removed
gcc/treelang
Removed

From-SVN: r132976
This commit is contained in:
Tom Tromey 2008-03-06 17:14:05 +00:00 committed by Tom Tromey
parent 3825be8c96
commit e8645a4001
57 changed files with 32 additions and 7183 deletions

View file

@ -1,3 +1,7 @@
2008-03-06 Tom Tromey <tromey@redhat.com>
* MAINTAINERS: Update for treelang deletion.
2008-03-03 James E. Wilson <wilson@tuliptree.org>
* MAINTAINERS: Update my email address.

View file

@ -130,8 +130,6 @@ java Andrew Haley aph@redhat.com
java Tom Tromey tromey@redhat.com
objective-c/c++ Mike Stump mrs@apple.com
objective-c/c++ Stan Shebs stanshebs@earthlink.net
treelang Tim Josling tej@melbpc.org.au
treelang James A. Morrison phython@gcc.gnu.org
Various Maintainers
@ -338,6 +336,7 @@ Andreas Jaeger aj@suse.de
Harsha Jagasia harsha.jagasia@amd.com
Fariborz Jahanian fjahanian@apple.com
Phillip Jordan phillip.m.jordan@gmail.com
Tim Josling tej@melbpc.org.au
Klaus Kaempf kkaempf@progis.de
Victor Kaplansky victork@il.ibm.com
Brendan Kehoe brendan@zen.org
@ -385,6 +384,7 @@ Lee Millward lee.millward@gmail.com
Alan Modra amodra@bigpond.net.au
Alexander Monakov amonakov@ispras.ru
Catherine Moore clm@redhat.com
James A. Morrison phython@gcc.gnu.org
Dirk Mueller dmueller@suse.de
Adam Nemet anemet@caviumnetworks.com
Thomas Neumann tneumann@users.sourceforge.net

View file

@ -1,3 +1,14 @@
2008-03-06 Tom Tromey <tromey@redhat.com>
* treelang: Delete.
* doc/standards.texi (Standards): Don't mention treelang.
* doc/invoke.texi (Overall Options): Don't mention treelang.
* doc/install.texi (Prerequisites): Don't mention bison or
treelang.
(Configuration): Don't mention treelang.
(Building): Likewise.
* doc/frontends.texi (G++ and GCC): Don't mention treelang.
2008-03-06 Paolo Bonzini <bonzini@gnu.org>
* simplify-rtx.c (simplify_subreg): Remove useless shifts from

View file

@ -1,5 +1,5 @@
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
@c 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
@c 1999, 2000, 2001, 2002, 2004, 2008 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@ -14,7 +14,6 @@
@cindex Java
@cindex Objective-C
@cindex Objective-C++
@cindex treelang
GCC stands for ``GNU Compiler Collection''. GCC is an integrated
distribution of compilers for several major programming languages. These
languages currently include C, C++, Objective-C, Objective-C++, Java,

View file

@ -372,16 +372,6 @@ Necessary to run @samp{make check} for @file{fixinc}.
Necessary to regenerate the top level @file{Makefile.in} file from
@file{Makefile.tpl} and @file{Makefile.def}.
@item GNU Bison version 1.28 (or later)
Necessary when modifying @file{*.y} files. Necessary to build the
@code{treelang} front end (which is not enabled by default) from a
checkout of the SVN repository; the generated files are not in the
repository. They are included in releases.
Berkeley @command{yacc} (@command{byacc}) has been reported to work
as well.
@item Flex version 2.5.4 (or later)
Necessary when modifying @file{*.l} files.
@ -1161,11 +1151,11 @@ grep language= */config-lang.in
@end smallexample
Currently, you can use any of the following:
@code{all}, @code{ada}, @code{c}, @code{c++}, @code{fortran}, @code{java},
@code{objc}, @code{obj-c++}, @code{treelang}.
@code{objc}, @code{obj-c++}.
Building the Ada compiler has special requirements, see below.
If you do not pass this flag, or specify the option @code{all}, then all
default languages available in the @file{gcc} sub-tree will be configured.
Ada, Objective-C++, and treelang are not default languages; the rest are.
Ada and Objective-C++ are not default languages; the rest are.
Re-defining @code{LANGUAGES} when calling @samp{make} @strong{does not}
work anymore, as those language sub-directories might not have been
configured!
@ -1707,18 +1697,13 @@ that type mismatches occur, this could be the cause.
The solution is not to use such a directory for building GCC@.
When building from SVN or snapshots and enabling the @code{treelang}
front end, or if you modify @file{*.y} files, you need the Bison parser
generator installed. If you do not modify @file{*.y} files, releases
contain the Bison-generated files and you do not need Bison installed
to build them. Note that most front ends now use hand-written parsers,
which can be modified with no need for Bison.
Similarly, when building from SVN or snapshots, or if you modify
@file{*.l} files, you need the Flex lexical analyzer generator installed.
There is still one Flex-based lexical analyzer (part of the build
machinery, not of GCC itself) that is used even if you only build the
C front end.
@file{*.l} files, you need the Flex lexical analyzer generator
installed. If you do not modify @file{*.l} files, releases contain
the Flex-generated files and you do not need Flex installed to build
them. There is still one Flex-based lexical analyzer (part of the
build machinery, not of GCC itself) that is used even if you only
build the C front end.
When building from SVN or snapshots, or if you modify Texinfo
documentation, you need version 4.4 or later of Texinfo installed if you

View file

@ -1001,7 +1001,6 @@ assembler assembler-with-cpp
ada
f95 f95-cpp-input
java
treelang
@end smallexample
@item -x none

View file

@ -1,4 +1,4 @@
@c Copyright (C) 2000, 2001, 2002, 2004, 2006, 2007 Free Software Foundation,
@c Copyright (C) 2000, 2001, 2002, 2004, 2006, 2007, 2008 Free Software Foundation,
@c Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@ -219,14 +219,6 @@ and
have additional useful information.
@end itemize
@section Treelang language
@cindex treelang
There is no standard for treelang, which is a sample language front end
for GCC@. Its only purpose is as a sample for people wishing to write a
new language for GCC@. The language is documented in
@file{gcc/treelang/treelang.texi} which can be turned into info or
HTML format.
@xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,
GNAT Reference Manual}, for information on standard
conformance and compatibility of the Ada compiler.

View file

@ -1,3 +1,8 @@
2008-03-06 Tom Tromey <tromey@redhat.com>
* lib/treelang-dg.exp, lib/treelang.exp: Delete.
* treelang: Delete.
2008-03-05 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/pack33.ads: New test.

View file

@ -1,36 +0,0 @@
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2007
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
load_lib gcc-dg.exp
# Define gcc callbacks for dg.exp.
proc treelang-dg-test { prog do_what extra_tool_flags } {
return [gcc-dg-test-1 treelang_target_compile $prog $do_what $extra_tool_flags]
}
proc treelang-dg-prune { system text } {
return [gcc-dg-prune $system $text]
}
# Utility routines.
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc treelang-dg-runtest { testcases default-extra-flags } {
return [gcc-dg-runtest $testcases ${default-extra-flags}]
}

View file

@ -1,269 +0,0 @@
# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004,
# 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This file was written by Rob Savoye (rob@cygnus.com)
# Currently maintained by James A. Morrison (ja2morri@uwaterloo.ca)
# Having this file here magically tells dejagnu that the treelang
# directory is worthy of testing
# This file is basically gcc.exp with gcc replaced with treelang.
# This file is loaded by the tool init file (eg: unix.exp). It provides
# default definitions for treelang_start, etc. and other supporting cast
# members.
# These globals are used by treelang_start if no compiler arguments are
# provided. They are also used by the various testsuites to define the
# environment: where to find stdio.h, libc.a, etc.
load_lib libgloss.exp
load_lib prune.exp
load_lib gcc-defs.exp
load_lib target-libpath.exp
#
# TREELANG_UNDER_TEST is the compiler under test.
#
#
# default_treelang_version -- extract and print the version number of the compiler
#
proc default_treelang_version { } {
global TREELANG_UNDER_TEST
treelang_init
# ignore any arguments after the command
set compiler [lindex $TREELANG_UNDER_TEST 0]
if ![is_remote host] {
set compiler_name [which $compiler]
} else {
set compiler_name $compiler
}
# verify that the compiler exists
if { $compiler_name != 0 } then {
set tmp [remote_exec host "$compiler -v"]
set status [lindex $tmp 0]
set output [lindex $tmp 1]
regexp " version \[^\n\r\]*" $output version
if { $status == 0 && [info exists version] } then {
clone_output "$compiler_name $version\n"
} else {
clone_output "Couldn't determine version of $compiler_name: $output\n"
}
} else {
# compiler does not exist (this should have already been detected)
warning "$compiler does not exist"
}
}
# treelang_init -- called at the start of each .exp script.
#
# There currently isn't much to do, but always using it allows us to
# make some enhancements without having to go back and rewrite the scripts.
#
set treelang_initialized 0
proc treelang_init { args } {
global tmpdir
global libdir
global gluefile wrap_flags
global treelang_initialized
global TREELANG_UNDER_TEST
global TOOL_EXECUTABLE
global treelang_libgcc_s_path
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
setenv LC_ALL C
setenv LANG C
if { $treelang_initialized == 1 } { return; }
if ![info exists TREELANG_UNDER_TEST] then {
if [info exists TOOL_EXECUTABLE] {
set TREELANG_UNDER_TEST $TOOL_EXECUTABLE
} else {
set TREELANG_UNDER_TEST [find_gcc]
}
}
if ![info exists tmpdir] then {
set tmpdir /tmp
}
treelang_maybe_build_wrapper "${tmpdir}/treelang-testglue.o"
set treelang_libgcc_s_path \
[gcc-set-multilib-library-path $TREELANG_UNDER_TEST]
}
proc treelang_target_compile { source dest type options } {
global rootme
global tmpdir
global gluefile wrap_flags
global srcdir
global TREELANG_UNDER_TEST
global TOOL_OPTIONS
global ld_library_path
global treelang_libgcc_s_path
set ld_library_path ".:${treelang_libgcc_s_path}"
set_ld_library_path_env_vars
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=$wrap_flags"
}
# TOOL_OPTIONS must come first, so that it doesn't override testcase
# specific options.
if [info exists TOOL_OPTIONS] {
set options [concat "{additional_flags=$TOOL_OPTIONS}" $options]
}
# If we have built libtreelang along with the compiler (which usually
# _is not_ the case on Mac OS X systems), point the test harness
# at it (and associated headers).
return [target_compile $source $dest $type $options]
}
#
# treelang_pass -- utility to record a testcase passed
#
proc treelang_pass { testcase cflags } {
if { "$cflags" == "" } {
pass "$testcase"
} else {
pass "$testcase, $cflags"
}
}
#
# treelang_fail -- utility to record a testcase failed
#
proc treelang_fail { testcase cflags } {
if { "$cflags" == "" } {
fail "$testcase"
} else {
fail "$testcase, $cflags"
}
}
#
# treelang_finish -- called at the end of every .exp script that calls treelang_init
#
# The purpose of this proc is to hide all quirks of the testing environment
# from the testsuites. It also exists to undo anything that treelang_init did
# (that needs undoing).
#
proc treelang_finish { } {
# The testing harness apparently requires this.
global errorInfo
if [info exists errorInfo] then {
unset errorInfo
}
# Might as well reset these (keeps our caller from wondering whether
# s/he has to or not).
global prms_id bug_id
set prms_id 0
set bug_id 0
}
proc treelang_exit { } {
global gluefile
if [info exists gluefile] {
file_on_build delete $gluefile
unset gluefile
}
}
# If this is an older version of dejagnu (without runtest_file_p),
# provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
# This can be deleted after next dejagnu release.
if { [info procs runtest_file_p] == "" } then {
proc runtest_file_p { runtests testcase } {
if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
return 1
} else {
return 0
}
}
return 1
}
}
# Provide a definition of this if missing (delete after next dejagnu release).
if { [info procs prune_warnings] == "" } then {
proc prune_warnings { text } {
return $text
}
}
# Utility used by mike-gcc.exp and c-torture.exp.
# Check the compiler(/assembler/linker) output for text indicating that
# the testcase should be marked as "unsupported".
#
# When dealing with a large number of tests, it's difficult to weed out the
# ones that are too big for a particular cpu (eg: 16 bit with a small amount
# of memory). There are various ways to deal with this. Here's one.
# Fortunately, all of the cases where this is likely to happen will be using
# gld so we can tell what the error text will look like.
proc ${tool}_check_unsupported_p { output } {
if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
return "memory full"
}
return ""
}
# Prune messages from treelang that aren't useful.
proc prune_treelang_output { text } {
#send_user "Before:$text\n"
regsub -all "(^|\n)\[^\n\]*: In (function|method) \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: At top level:\[^\n\]*" $text "" text
# It would be nice to avoid passing anything to treelang that would cause it to
# issue these messages (since ignoring them seems like a hack on our part),
# but that's too difficult in the general case. For example, sometimes
# you need to use -B to point treelang at crt0.o, but there are some targets
# that don't have crt0.o.
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text
#send_user "After:$text\n"
return $text
}

View file

@ -1,124 +0,0 @@
2005-08-06 James A. Morrison <phython@gcc.gnu.org>
* treetests.exp: Remove.
* a01gcco01runpgm: Move to...
* output/output-1.out: here.
* a01gcci01.c: Move to...
* output/output-1.c: here.
* a01gcci01.tree: Move to...
* output/output-1.tree: here.
* output/output.exp: New.
2005-07-23 James A. Morrison <phython@gcc.gnu.org>
* compile/var_defs.tree: Remove extra lines.
2005-07-19 James A. Morrison <phython@gcc.gnu.org>
* compile/var_defs.tree: Remove duplicate variable.
* compile/var_defs-2.tree: Add duplicate variable test.
2005-03-22 James A. Morrison <phython@gcc.gnu.org>
* compile/memory.tree: New test.
2005-02-26 James A. Morrison <phython@gcc.gnu.org>
* compile/var_defs: Add uninitialized variables.
2005-02-26 James A. Morrison <phython@gcc.gnu.org>
* compile/extrafunc.tree, compile/extravar.tree: New tests.
2005-02-26 James A. Morrison <phython@gcc.gnu.org>
* compile/unsigned.tree: New test.
2005-02-24 James A. Morrison <phython@gcc.gnu.org>
PR other/19896
* execute/execute.exp: New file.
* execute/funccall.tree, execute/funccall-2.tree, execute/initial.tree,
execute/main.tree, execute/static.tree: New tests.
2005-02-24 James A. Morrison <phython@gcc.gnu.org>
PR other/19897
* compile/exit.tree, compile/extref.tree, compile/function-1.tree,
compile/syntax-1.tree: New tests.
2004-10-02 James A. Morrison <phython@gcc.gnu.org>
* compile/autofunc.tree: New File.
* compile/badchar.tree: New File.
* compile/externvar.tree: New File.
* compile/mismatch.tree: New File.
* compile/noproto.tree: New File.
* compile/novar.tree: New File.
* compile/var_defs.tree: Add duplicate variable.
2004-07-31 James A. Morrison <phython@gcc.gnu.org>
* compile/vars_def.tree: New File.
* compile/badreturn.tree: New File.
2004-01-18 James A. Morrison <ja2morri@uwaterloo.ca>
* compile/compile.exp: New File.
* compile/tabs.tree: Test whether the front end
compiles code with tabs in it.
2003-02-25 Tim Josling <tej@melbpc.org.au>
* treetests.exp (run3): set options to force aggressive GC, to
ensure GC is all set up correct,
2002-05-07 Tim Josling <tej@melbpc.org.au>
* Makefile.in: Fix copyright
* a01gcci01.c: Ditto
* a01gcci01.tree: Ditto
* treetests.exp: Ditto
2002-04-13 Tim Josling <tej@melbpc.org.au>
* treetree.c (tree_code_create_function_initial)
Remove duplicate call to layout_decl
2001-12-02 Tim Josling <tej@melbpc.org.au>
* Make-lang.in
Ensure directory is built during install (installdirs dependency)
* lex.l
Work around poisoned malloc (undef IN_GCC)
Remove fake definition of tree.
* parse.y
Work around poisoned malloc (undef IN_GCC)
* tree1.c
New front end interface.
(top level) New structure lang_hooks.
(tree_post_options) Remove.
errorcount now a macro so do not define it.
current_nesting_level => work_nesting_level due to clash.
* treelang.h
errorcount now a macro so do not reference it.
* treetree.c
Replace NULL_PTR by NULL.
(tree_code_get_expression) Mark op3 unused.
Do not init builtins.
2001-06-11 Tim Josling <tej@melbpc.org.au>
* treelang.exp (global) remove COBOL specific code.
2001-05-24 Tim Josling <tej@melbpc.org.au>
Created this directory and its tests. All derived from the cobol
test swamp which was also all written by me.

View file

@ -1,28 +0,0 @@
# Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
#
# In other words, you are welcome to use, share and improve this program.
# You are forbidden to forbid anyone else to use, share and improve
# what you give them. Help stamp out software-hoarding!
#
#
all:
clean:
-rm -f *.o *.diff *~ *.bad core *.x
distclean: clean
-rm -f Makefile config.status

View file

@ -1,6 +0,0 @@
// { dg-do compile }
automatic int bar (); // { dg-error "automatic" }
bar () {
return -12;
}

View file

@ -1,2 +0,0 @@
// { dg-do compile }
static int bar = 1*; // { dg-error "Unrecognized" }

View file

@ -1,14 +0,0 @@
// { dg-do compile }
external_definition void bar ();
external_definition int gar (int arg0);
bar
{
return 0; // { dg-warning "return" }
}
gar
{
return; // { dg-error "return" }
}

View file

@ -1,30 +0,0 @@
# Tests for treelang; run from gcc/treelang/Make-lang.in => gcc/Makefile
# Copyright (C) 2004, 2007 by The Free Software Foundation
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
#
# In other words, you are welcome to use, share and improve this program.
# You are forbidden to forbid anyone else to use, share and improve
# what you give them. Help stamp out software-hoarding!
# Treelang tests that only need to compile.
# Load support procs.
load_lib treelang-dg.exp
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.tree]] "" ""
dg-finish

View file

@ -1,12 +0,0 @@
// { dg-do compile }
external_reference void exit (int code);
static int foo ();
foo
{
automatic int bar = +1;
bar = bar + +1;
exit (0); // Calling external references is currently broken.
return bar;
}

View file

@ -1,4 +0,0 @@
// { dg-do compile }
external_reference int bar = 0; // { dg-error "initial" }
static char barf = 1;

View file

@ -1,25 +0,0 @@
// { dg-do compile }
// { dg-options "-O2 -fdump-tree-optimized -Wunused-function" }
// Check to see that unused functions get removed at -O2 and
// above.
static int foo (int bar);
static int baz (int aaa);
external_definition int ext (int bbb);
foo
{
return bar;
}
baz // { dg-warning "defined but not used" }
{
return foo (aaa);
}
ext
{
return foo (bbb);
}
// { dg-final { scan-tree-dump-not "baz" "optimized" } }
// { dg-final { cleanup-tree-dump "optimized" } }

View file

@ -1,14 +0,0 @@
// { dg-do compile }
// { dg-options "-fdump-tree-optimized -O1 -Wunused-variable" }
external_definition int bar (int aaa, int ddd);
static int foo = -3; // { dg-warning "defined but not used" }
bar
{
automatic int ccc;
return aaa + ddd + +3;
}
// { dg-final { scan-tree-dump-not "ccc" "optimized" } }
// { dg-final { cleanup-tree-dump "optimized" } }

View file

@ -1,9 +0,0 @@
// { dg-do compile }
external_reference void abort ();
static int foo (int a);
foo
{
return a;
}

View file

@ -1,16 +0,0 @@
// { dg-do compile }
// { dg-options "-funit-at-a-time" }
external_definition int add (int arga, int argb);
external_definition char sub (char argc, char argd);
add
{
return arga + argb + +3;
}
sub
{
return argd - argc + +2;
}
// { dg-final { scan-assembler "add" } }
// { dg-final { scan-assembler "sub" } }

View file

@ -1,14 +0,0 @@
// { dg-do compile }
static int foo ();
static int bar (int a);
foo
{
return 1;
}
bar
{
a = a + foo ();
return a;
}

File diff suppressed because one or more lines are too long

View file

@ -1,8 +0,0 @@
// { dg-do compile }
static int bar ();
static void barf ();
bar {
barf (1); // { dg-error "mismatch" "barf" }
return -12;
}

View file

@ -1,5 +0,0 @@
// { dg-do compile }
foo // { dg-error "foo" "prototype" }
{
x = 3;
}

View file

@ -1,5 +0,0 @@
static void bar ();
bar {
x = 3; // { dg-error "x" "not defined" }
}

View file

@ -1,9 +0,0 @@
// { dg-do compile }
external_reference void exit(int); // { dg-error "(parse|syntax) error" }
static int foo (int a);
foo
{
return a;
}

View file

@ -1,11 +0,0 @@
// { dg-do compile }
external_definition int main(int argc);
main {
automatic int v1;
automatic int v2;
v1 = argc;
v2 = 3;
return v2;
}

View file

@ -1,20 +0,0 @@
// { dg-do compile }
// { dg-options "-fdump-tree-gimple" }
external_reference void abort ();
external_reference void exit (int status);
external_definition int main (int argc, int argv);
main
{
automatic unsigned int bar = 2147483649;
automatic unsigned int baz = 2147483649;
if (bar == baz) {
abort ();
} else {
exit (0);
}
return +1;
}
// { dg-final { scan-tree-dump-not "\\\(int\\\)" "gimple" } }
// { dg-final { cleanup-tree-dump "gimple" } }

View file

@ -1,20 +0,0 @@
// { dg-do compile }
external_definition int first_nonzero (int arg5, int arg6);
first_nonzero
{
automatic int y;
automatic int y; // { dg-error "Duplicate" }
if (arg5)
{
return arg5;
}
else
{
automatic int j;
j = arg6;
return j;
}
return arg6;
}

View file

@ -1,24 +0,0 @@
// { dg-do compile }
// { dg-options "-Wuninitialized -O" }
external_definition void boring (int arg0);
external_definition char condition (char arg1, char arg2);
boring
{
arg0 = +5 + +3; // Force 3 and 5 to be signed numbers.
arg0 = arg0 + +3;
}
condition
{
if (arg1)
{
automatic int i; // { dg-warning "was declared here" }
return i + 1; // { dg-warning "uninitialized" }
}
else
{
automatic int j; // { dg-warning "was declared here" }
return j; // { dg-warning "uninitialized" }
}
}

View file

@ -1,30 +0,0 @@
# Tests for treelang; run from gcc/treelang/Make-lang.in => gcc/Makefile
# Copyright (C) 2004, 2007 by The Free Software Foundation
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
#
# In other words, you are welcome to use, share and improve this program.
# You are forbidden to forbid anyone else to use, share and improve
# what you give them. Help stamp out software-hoarding!
# Treelang tests that only need to compile.
# Load support procs.
load_lib treelang-dg.exp
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.tree]] "" ""
dg-finish

View file

@ -1,28 +0,0 @@
// { dg-do run }
external_definition int main (int argc);
static int foo (int bba);
foo
{
automatic int bar;
bar = bba + +1;
return bar;
}
main
{
automatic int aaa = +3;
aaa = foo (argc);
if (aaa == +2)
{
return +0;
}
else
{
return +1;
}
}

View file

@ -1,33 +0,0 @@
// { dg-do run }
// Tests whether initializtion works properly.
external_reference void abort ();
external_reference void exit (int code);
external_definition int main ();
static int foo ();
foo
{
automatic int bar;
bar = +1;
bar = bar + +1;
return bar;
}
main
{
automatic int aaa;
aaa = foo ();
if (aaa == +2)
{
exit (0);
}
else
{
abort ();
}
return 0;
}

View file

@ -1,20 +0,0 @@
// { dg-do run }
// Tests whether initializtion works properly.
external_reference void abort ();
external_reference void exit (int code);
external_definition int main ();
main
{
automatic int aaa = +3;
if (aaa == +3)
{
exit (0);
}
else
{
abort ();
}
return 0;
}

View file

@ -1,14 +0,0 @@
// { dg-do run }
external_definition int main (int argc);
main
{
if (argc == 1)
{
return 0;
}
else
{
return argc;
}
}

View file

@ -1,32 +0,0 @@
// { dg-do run }
external_reference void abort ();
external_reference void exit (int code);
external_definition int main (int argc, int argv);
static int foo ();
foo
{
static int bar = +1;
bar = bar + +1;
return bar;
}
main
{
automatic int aaa = +3;
aaa = foo ();
aaa = foo ();
if (aaa == 3)
{
exit (0);
}
else
{
abort ();
}
return 0;
}

View file

@ -1,43 +0,0 @@
/* Driver for treelang test pgm */
/*
Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
*/
int add(int, int);
int subtract(int, int);
int first_nonzero(int, int);
extern int printf(char *template, ...);
int
main (int argc, char *argv[])
{
printf("2:%d\n", add(1,1));
printf("7:%d\n", add(3,4));
printf("-1:%d\n", subtract(3,4));
printf("1:%d\n", subtract(2,1));
printf("3:%d\n", first_nonzero(0,3));
printf("0:%d\n", first_nonzero(0,0));
printf("1:%d\n", first_nonzero(1,0));
printf("15:%d\n", double_plus_one(7));
return 0;
}

View file

@ -1,8 +0,0 @@
2:2
7:7
-1:-1
1:1
3:3
0:0
1:1
15:15

View file

@ -1,59 +0,0 @@
// -*- c -*- c mode in emacs
// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
// In other words, you are welcome to use, share and improve this program.
// You are forbidden to forbid anyone else to use, share and improve
// what you give them. Help stamp out software-hoarding!
external_definition int add(int arg1, int arg2);
external_definition int subtract(int arg3, int arg4);
external_definition int first_nonzero(int arg5, int arg6);
external_definition int double_plus_one(int arg7);
add
{
return arg1 + arg2;
}
subtract
{
return arg3 - arg4;
}
double_plus_one
{
automatic int aaa;
aaa=add(arg7, arg7);
aaa=add(aaa, aaa);
aaa=subtract(subtract(aaa, arg7), arg7) + 1;
return aaa;
}
first_nonzero
{
if (arg5)
{
return arg5;
}
else
{
}
return arg6;
}

View file

@ -1,58 +0,0 @@
proc test_treelang_output { testname srcfiles infile resfile args } {
set comp_output [treelang_target_compile $srcfiles $testname executable $args]
if { [treelang_check_compile $testname $args $testname $comp_output] == 0 } {
return 0;
}
verbose "Expected output is in $resfile"
set id [open $resfile r]
set expected ""
append expected [read $id]
close $id
set output ""
set output [exec $testname $infile]
regsub -all "\r" "$output" "" output
regsub "\n*$" $expected "" expected
regsub "\n*$" $output "" output
regsub "^\n*" $expected "" expected
regsub "^\n*" $output "" output
regsub -all "\[ \t\]\[ \t\]*" $expected " " expected
regsub -all "\[ \t\]*\n\n*" $expected "\n" expected
regsub -all "\[ \t\]\[ \t\]*" $output " " output
regsub -all "\[ \t\]*\n\n*" $output "\n" output
verbose "expected is $expected"
verbose "actual is $output"
if { $expected == $output } {
pass $testname
} else {
fail $testname
}
exec rm $testname
}
global srcdir subdir
catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.out] } outfiles
verbose "Output files are $outfiles"
set prefix ""
foreach x $outfiles {
regsub "\\.out$" $x "" prefix
set bname [file tail $prefix]
if [file exists ${prefix}.inp] {
set inpfile ${prefix}.inp
} else {
set inpfile ""
}
verbose "inpfile is $inpfile"
set srcfiles [lsort [glob -nocomplain ${prefix}.{c,tree}]]
verbose "source files are $srcfiles"
test_treelang_output "treelang/$bname" $srcfiles $inpfile $x ""
}
# Local Variables:
# tcl-indent-level:4
# End:

File diff suppressed because it is too large Load diff

View file

@ -1,324 +0,0 @@
# Top level makefile fragment for TREELANG For GCC. -*- makefile -*-
# Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
# 2006, 2007 Free Software Foundation, Inc.
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This file provides the language dependent support in the main Makefile.
# Each language makefile fragment must provide the following targets:
#
# foo.all.cross, foo.start.encap, foo.rest.encap,
# foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
# foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
# foo.mostlyclean, foo.clean, foo.distclean,
# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
#
# where `foo' is the name of the language.
#
# It should also provide rules for:
#
# - making any compiler driver (eg: gcc)
# - the compiler proper (eg: tree1)
# - define the names for selecting the language in LANGUAGES.
#
## note program-prefix and program-suffix options are not supported
## just program_transform_name which is a sed script to transform the
## names
TREELANGSED = sed
TREELANGSEDFLAGS = -n
GCC_EXTRAS = -B./ -B$(build_tooldir)/bin/ -isystem $(build_tooldir)/include
# ./xgcc is the just built compiler. See GCC_FOR_TARGET in the GCC Makefile.in.
# If this can't be found, you probably have not done a bootstrap of GCC,
# which you need to do.
# GCC_FOR_TREELANG = ./xgcc $(GCC_EXTRAS)
TREE_GENERATED = lex.c parse.c parse.h parse.output
# We need to use something other than treelang here because the directory
# is called treelang
TREE_EXES = gtreelang
#strict warnings for treelang
treelang-warn = $(STRICT_WARN)
# bison emits some unused static arrays (yytoknum)
treelang/parse.o-warn = -Wno-error
# flex produces 'no previous prototype' warnings
treelang/lex.o-warn = -Wno-error
#
# Define the names for selecting treelang in LANGUAGES.
.phony: treelang
treelang:treelang.done
treelang.done: gtreelang$(exeext) tree1$(exeext)
$(STAMP) treelang.done
# no preprocessor
# core compiler
tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/tree-convert.o \
treelang/lex.o treelang/parse.o \
$(BACKEND) $(LIBSDEPS) attribs.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
treelang/tree1.o treelang/treetree.o treelang/tree-convert.o \
treelang/lex.o treelang/parse.o \
$(BACKEND) $(LIBS) attribs.o $(GMPLIBS)
# Create the compiler driver treelang.
gtreelang$(exeext): $(GCC_OBJS) version.o prefix.o intl.o $(EXTRA_GCC_OBJS) \
$(LIBDEPS) treelang/spec.o
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ treelang/spec.o \
$(GCC_OBJS) version.o prefix.o intl.o $(EXTRA_GCC_OBJS) $(LIBS)
#
# Compiling object files from source files.
# object file makes
treelang/tree1.o: treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(FLAGS_H) toplev.h $(GGC_H) $(TREE_H) $(DIAGNOSTIC_H) treelang/treelang.h \
input.h treelang/treetree.h options.h opts.h \
treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h
treelang/treetree.o: treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) $(FLAGS_H) output.h $(RTL_H) $(GGC_H) toplev.h \
$(VARRAY_H) $(LANGHOOKS_DEF_H) langhooks.h treelang/treelang.h input.h \
treelang/treetree.h treelang/parse.h $(TARGET_H)
treelang/tree-convert.o: treelang/tree-convert.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(DIAGNOSTIC_H) $(TREE_H) $(FLAGS_H) toplev.h langhooks.h $(TM_H)
treelang/spec.o: treelang/spec.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(DIAGNOSTIC_H) $(TREE_H) $(FLAGS_H) toplev.h langhooks.h $(TM_H)
treelang/parse.o: treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(DIAGNOSTIC_H) treelang/treelang.h input.h treelang/treetree.h \
toplev.h
treelang/lex.o: treelang/lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(DIAGNOSTIC_H) $(TREE_H) treelang/treelang.h input.h \
treelang/parse.h toplev.h
# generated files the files from lex and yacc are put into the source
# directory in case someone wants to build but does not have
# lex/yacc
treelang.srcextra: treelang/parse.c treelang/parse.h treelang/lex.c
-cp -p $^ $(srcdir)/treelang
treelang/lex.c: treelang/lex.l
-$(FLEX) $(FLEXFLAGS) -o$@ $<
treelang/parse.c treelang/parse.h treelang/parse.output: treelang/parse.y
-$(BISON) $(BISONFLAGS) -v --defines --output=treelang/parse.c $<
# -v
#
# Build hooks:
treelang.all.cross:
_error_not_here_yet - havent even thought about it - it may even work
treelang.start.encap:
treelang.rest.encap:
treelang.man:
treelang.srcman:
treelang.tags: force
cd $(srcdir)/treelang; etags -o TAGS.sub *.y *.l *.c *.h; \
etags --include TAGS.sub --include ../TAGS.sub
treelang.info: doc/treelang.info
treelang.srcinfo: doc/treelang.info
-cp -p $^ $(srcdir)/doc
treelang.dvi: doc/treelang.dvi
TREELANG_PDFFILES = doc/treelang.pdf
treelang.pdf: $(TREELANG_PDFFILES)
TEXI_TREELANG_FILES = treelang/treelang.texi \
$(gcc_docdir)/include/gcc-common.texi \
$(gcc_docdir)/include/gpl.texi \
$(gcc_docdir)/include/fdl.texi \
$(gcc_docdir)/include/funding.texi \
gcc-vers.texi
doc/treelang.info: $(TEXI_TREELANG_FILES)
$(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir)/include -o $@ $<
doc/treelang.dvi: $(TEXI_TREELANG_FILES)
$(TEXI2DVI) -I $(abs_docdir)/include -o $@ $<
doc/treelang.pdf: $(TEXI_TREELANG_FILES)
$(TEXI2PDF) -I $(abs_docdir)/include -o $@ $<
treelang.html: $(build_htmldir)/treelang/index.html
$(build_htmldir)/treelang/index.html: $(TEXI_TREELANG_FILES)
$(mkinstalldirs) $(@D)
rm -f $(@D)/*
$(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/treelang -o $(@D) $<
#
# Install hooks:
# Install
.phony:treelang.install.common
.phony:treelang.install
treelang.install treelang.install.common treelang.install-common: treelang.install.common.done
treelang.install.common.done: installdirs treelang.done
for name in $(TREE_EXES); \
do \
if [ -f $$name ] ; then \
name2="`echo \`basename $$name\` | sed -e '$(program_transform_name)' `"; \
rm -f $(DESTDIR)$(bindir)/$$name2$(exeext); \
echo $(INSTALL_PROGRAM) $$name$(exeext) $(DESTDIR)$(bindir)/$$name2$(exeext); \
$(INSTALL_PROGRAM) $$name$(exeext) $(DESTDIR)$(bindir)/$$name2$(exeext); \
chmod a+x $(DESTDIR)$(bindir)/$$name2$(exeext); \
fi ; \
done
$(STAMP) treelang.install.common.done
# We might not be able to build the info files
treelang.install-info: $(DESTDIR)$(infodir)/treelang.info
treelang.install-pdf: $(TREELANG_PDFFILES)
@$(NORMAL_INSTALL)
test -z "$(pdfdir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
@list='$(TREELANG_PDFFILES)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(pdf__strip_dir) \
echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
$(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
done
treelang.install-man:
treelang.uninstall:
for name in $(TREE_EXES); \
do \
echo $$name; \
name2="`echo $$name | sed -e '$(program_transform_name)' `"; \
echo becomes $$name2; \
echo -rm -rf $(DESTDIR)$(bindir)/$$name2$(exeext); \
rm -rf $(DESTDIR)$(bindir)/$$name2$(exeext); \
done
-rm treelang.install.common.done
#
# Clean hooks:
# A lot of the ancillary files are deleted by the main makefile.
# We just have to delete files specific to us.
treelang.mostlyclean:
for name in $(TREE_EXES); \
do \
echo deleting $$name; \
if [ -f treelang/$$name$(exeext) ] ; then \
rm -f treelang/$$name$(exeext); \
fi ; \
done
-rm -f treelang/*$(objext)
-rm -f treelang/*$(coverageexts)
-rm treelang.done
treelang.clean: treelang.mostlyclean
treelang.distclean: treelang.clean
-rm -f treelang/config.status
-rm -f treelang/*.output
treelang.maintainer-clean: treelang.distclean
for name in $(TREE_GENERATED); \
do \
if [ -f $(srcdir)/treelang/$$name ] ; then \
echo deleting $(srcdir)/treelang/$$name; \
rm -f $(srcdir)/treelang/$$name; \
fi ; \
done
-rm -R $(srcdir)/treelang/*~
#
# Stage hooks:
# The main makefile has already created stage?/treelang.
treelang.stage1: stage1-start
-mv treelang/*$(objext) stage1/treelang
treelang.stage2: stage2-start
-mv treelang/*$(objext) stage2/treelang
treelang.stage3: stage3-start
-mv treelang/*$(objext) stage3/treelang
treelang.stage4: stage4-start
-mv treelang/*$(objext) stage4/treelang
treelang.stageprofile: stageprofile-start
-mv treelang/*$(objext) stageprofile/treelang
treelang.stagefeedback: stagefeedback-start
-mv treelang/*$(objext) stagefeedback/treelang
#
# Maintenance hooks:
# test hook
check-treelang: treelang.check
TESTSUITEDIR = testsuite
treelang.check: $(TESTSUITEDIR)/site.exp
-mkdir testsuite/treelang
# these three files are empty and it seems diff has trouble generating
# patch files for new empty files as required for cvs.
# STAMP does not cut it here as I need an empty file.
-rootme=`${PWD_COMMAND}`; export rootme; \
srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \
cd testsuite; \
EXPECT=${EXPECT} ; export EXPECT ; \
if [ -f $${rootme}/../expect/expect ] ; then \
TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \
export TCL_LIBRARY ; fi ; \
PATH=`cd ..;${PWD_COMMAND}`:$$PATH; export PATH; \
gcc_extras="-B`cd ..;${PWD_COMMAND}` -B`cd ..;${PWD_COMMAND}`/treelang"; export gcc_extras; \
$(RUNTEST) --tool treelang $(RUNTESTFLAGS)
# copy the output files from the current test to source ie say the new results are OK
treelang.check.fix: force
srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ;
-cp testsuite/treelang/*.out* t
-cp testsuite/treelang/*runpgm* t
-rm -f t/*nofilename
#
config.status: treelang/config-lang.in

View file

@ -1,19 +0,0 @@
This is a sample language front end for GCC.
This is a replacement for 'toy' which had potential copyright issues,
but more importantly it did not exercise very much of GCC. The intent
of this language is that it should provide a cookbook of language
elements that you can use in any language front end.
To this end, treelang is essentially an implementation of a subset of
the GCC back end 'tree' interface in syntax.
Thanks to Richard Kenner, Joachim Nadler and many others for helping
me to understand enough of GCC to do this.
Please note, the documentation is not a good model to use for GCC
front end documentation.
Tim Josling
19 June 2002

View file

@ -1,36 +0,0 @@
# Top level configure fragment for GNU C++.
# Copyright (C) 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# Configure looks for the existence of this file to auto-config each language.
# We define several parameters used by configure:
#
# language - name of language as it would appear in $(LANGUAGES)
# compilers - value to add to $(COMPILERS)
# diff_excludes - files to ignore when building diffs between two versions.
language="treelang"
compilers="tree1\$(exeext)"
diff_excludes="-x lex.c -x parse.c -x parse.h"
headers=
build_by_default="no"
gtfiles="\$(srcdir)/treelang/tree1.c \$(srcdir)/treelang/treetree.c \$(srcdir)/treelang/treelang.h"

View file

@ -1,38 +0,0 @@
/* Definitions for specs for TREELANG
The format of the specs file is documented in gcc.c
Copyright (C) 1995, 96-98, 1999, 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/*
This is the contribution to the `default_compilers' array in GCC.c for
treelang.
This file must compile with 'traditional', so no ANSI string concatenations
*/
{".tree", "@treelang", NULL, 0, 0},
{".TREE", "@treelang", NULL, 0, 0},
{".tre", "@treelang", NULL, 0, 0},
{".TRE", "@treelang", NULL, 0, 0},
{"@treelang",
"%{!E:tree1 %i %(cc1_options) %{J*} %{I*}\
%{!fsyntax-only:%(invoke_as)}}", NULL , 0, 0
},

View file

@ -1,42 +0,0 @@
; Options for the treelang front end.
; Copyright (C) 2003, 2007 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
; GCC is free software; you can redistribute it and/or modify it under
; the terms of the GNU General Public License as published by the Free
; Software Foundation; either version 3, or (at your option) any later
; version.
;
; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
; WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
; for more details.
;
; You should have received a copy of the GNU General Public License
; along with GCC; see the file COPYING3. If not see
; <http://www.gnu.org/licenses/>.
; See the GCC internals manual for a description of this file's format.
; Please try to keep this file in ASCII collating order.
Language
Treelang
flexer-trace
Treelang
Trace lexical analysis
fparser-trace
Treelang
Trace the parsing process
v
Treelang
y
Treelang
; This comment is to ensure we retain the blank line above.

View file

@ -1,292 +0,0 @@
/* -*- c -*- = mode for emacs editor
TREELANG lexical analysis
---------------------------------------------------------------------
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2007, 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
---------------------------------------------------------------------
Written by Tim Josling 1999-2001, based in part on other parts of
the GCC compiler. */
%{
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "input.h"
#include "tree.h"
/* Token defs. */
#include "treelang.h"
#include "parse.h"
#include "treetree.h"
#include "toplev.h"
extern int option_lexer_trace;
int yylex (void);
void update_yylval (int a);
static int next_tree_charno = 1;
static int lineno = 1;
static void update_lineno_charno (void);
static void dump_lex_value (int lexret);
#define SAVE_RETURN(a) {update_yylval (a); if (option_lexer_trace)\
{fprintf (stderr, "\nlexer returning"); dump_lex_value (a);} return a;}
#define NOT_RETURN(a) {update_yylval (a); if (option_lexer_trace)\
{fprintf (stderr, "\nlexer swallowing"); dump_lex_value (a);}}
%}
%option nostack
%option nounput
%option noyywrap
%option pointer
%option nodefault
%%
{
/* ??? Should really allocate only what we need. */
yylval = my_malloc (sizeof (struct prod_token_parm_item));
LINEMAP_POSITION_FOR_COLUMN (input_location, line_table,
next_tree_charno);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
}
[ \n\t]+ {
update_lineno_charno ();
NOT_RETURN (WHITESPACE);
}
"//".* {
/* Comment. */
update_lineno_charno ();
NOT_RETURN (COMMENT);
}
"{" {
update_lineno_charno ();
SAVE_RETURN (LEFT_BRACE);
}
"}" {
update_lineno_charno ();
SAVE_RETURN (RIGHT_BRACE);
}
"(" {
update_lineno_charno ();
SAVE_RETURN (LEFT_PARENTHESIS);
}
")" {
update_lineno_charno ();
SAVE_RETURN (RIGHT_PARENTHESIS);
}
"," {
update_lineno_charno ();
SAVE_RETURN (COMMA);
}
";" {
update_lineno_charno ();
SAVE_RETURN (SEMICOLON);
}
"+" {
update_lineno_charno ();
SAVE_RETURN (tl_PLUS);
}
"-" {
update_lineno_charno ();
SAVE_RETURN (tl_MINUS);
}
"=" {
update_lineno_charno ();
SAVE_RETURN (ASSIGN);
}
"==" {
update_lineno_charno ();
SAVE_RETURN (EQUALS);
}
[+-]?[0-9]+ {
update_lineno_charno ();
SAVE_RETURN (INTEGER);
}
"external_reference" {
update_lineno_charno ();
SAVE_RETURN (EXTERNAL_REFERENCE);
}
"external_definition" {
update_lineno_charno ();
SAVE_RETURN (EXTERNAL_DEFINITION);
}
"static" {
update_lineno_charno ();
SAVE_RETURN (STATIC);
}
"automatic" {
update_lineno_charno ();
SAVE_RETURN (AUTOMATIC);
}
"int" {
update_lineno_charno ();
SAVE_RETURN (INT);
}
"char" {
update_lineno_charno ();
SAVE_RETURN (CHAR);
}
"void" {
update_lineno_charno ();
SAVE_RETURN (VOID);
}
"unsigned" {
update_lineno_charno ();
SAVE_RETURN (UNSIGNED);
}
"return" {
update_lineno_charno ();
SAVE_RETURN (tl_RETURN);
}
"if" {
update_lineno_charno ();
SAVE_RETURN (IF);
}
"else" {
update_lineno_charno ();
SAVE_RETURN (ELSE);
}
[A-Za-z_]+[A-Za-z_0-9]* {
update_lineno_charno ();
update_yylval (NAME);
if (option_lexer_trace)
{
fprintf (stderr, "\nlexer returning");
dump_lex_value (NAME);
}
return NAME;
}
[^\n] {
update_lineno_charno ();
error ("%HUnrecognized character %qc.",
&((struct prod_token_parm_item *)yylval)->tp.tok.location,
yytext[0]);
}
%%
/*
Update line number (1-) and character number (1-). Call this
before processing the token. */
static void
update_lineno_charno (void)
{
/* Update the values we send to caller in case we sometimes don't
tell them about all the 'tokens' eg comments etc. */
int yyl;
LINEMAP_POSITION_FOR_COLUMN (input_location, line_table,
next_tree_charno);
((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
for ( yyl = 0; yyl < yyleng; ++yyl )
{
if ( yytext[yyl] == '\n' )
{
source_location s = linemap_line_start (line_table, ++lineno,
80);
input_location = s;
next_tree_charno = 1;
}
else
next_tree_charno++;
}
}
/* Fill in the fields of yylval - the value of the token. The token
type is A. */
void
update_yylval (int a)
{
struct prod_token_parm_item * tok;
tok = yylval;
tok->category = token_category;
tok->type = a;
tok->tp.tok.length = yyleng;
/* Have to copy yytext as it is just a ptr into the buffer at the
moment. */
tok->tp.tok.chars = (const unsigned char *) get_string (yytext, yyleng);
}
/* Trace the value LEXRET and the position and token details being
returned by the lexical analyser. */
static void
dump_lex_value (int lexret)
{
int ix;
fprintf (stderr, " %d l:%d c:%d ln:%d text=", lexret,
LOCATION_LINE (((struct prod_token_parm_item *)
yylval)->tp.tok.location),
((struct prod_token_parm_item *) yylval)->tp.tok.charno,
((struct prod_token_parm_item *) yylval)->tp.tok.length);
for (ix = 0; ix < yyleng; ix++)
{
fprintf (stderr, "%c", yytext[ix]);
}
fprintf (stderr, " in hex:");
for (ix = 0; ix < yyleng; ix++)
{
fprintf (stderr, " %2.2x", yytext[ix]);
}
fprintf (stderr, "\n");
}

View file

@ -1,988 +0,0 @@
/* -*- c -*- emacs mode c */
/* TREELANG Compiler parser.
---------------------------------------------------------------------
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
---------------------------------------------------------------------
Written by Tim Josling 1999-2001, based in part on other parts of
the GCC compiler. */
/* Grammar Conflicts
*****************
There are no conflicts in this grammar. Please keep it that way. */
%{
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "timevar.h"
#include "tree.h"
#include "treelang.h"
#include "treetree.h"
#include "toplev.h"
#define YYDEBUG 1
#define YYPRINT(file, type, value) print_token (file, type, value)
#define YYERROR_VERBOSE YES
/* My yylex routine used to intercept calls to flex generated code, to
record lex time. */
int yylex (void);
static inline int my_yylex (void);
/* Call lex, but ensure time is charged to TV_LEX. */
static inline int
my_yylex (void)
{
int res;
timevar_push (TV_LEX);
res = yylex ();
timevar_pop (TV_LEX);
return res;
}
#define yylex my_yylex
extern int option_parser_trace;
/* Local prototypes. */
static void yyerror (const char *error_message);
int yyparse (void);
void print_token (FILE *file, unsigned int type ATTRIBUTE_UNUSED,
YYSTYPE value);
static struct prod_token_parm_item *reverse_prod_list
(struct prod_token_parm_item *old_first);
static void ensure_not_void (unsigned int type,
struct prod_token_parm_item *name);
static int check_type_match (int type_num, struct prod_token_parm_item *exp);
static int get_common_type (struct prod_token_parm_item *type1,
struct prod_token_parm_item *type2);
static struct prod_token_parm_item *make_integer_constant
(struct prod_token_parm_item *value);
static struct prod_token_parm_item *make_plus_expression
(struct prod_token_parm_item *tok, struct prod_token_parm_item *op1,
struct prod_token_parm_item *op2, int type_code, int prod_code);
static void set_storage (struct prod_token_parm_item *prod);
/* File global variables. */
static struct prod_token_parm_item *current_function = NULL;
%}
/* Not %raw - seems to have bugs. */
%token_table
/* Punctuation. */
%token RIGHT_BRACE
%token LEFT_BRACE
%token RIGHT_SQUARE_BRACKET
%token LEFT_SQUARE_BRACKET
%token RIGHT_PARENTHESIS
%token LEFT_PARENTHESIS
%token SEMICOLON
%token ASTERISK
%token COMMA
%right EQUALS
%right ASSIGN
%left tl_PLUS
%left tl_MINUS
/* Literals. */
%token INTEGER
/* Keywords. */
%token IF
%token ELSE
%token tl_RETURN
%token CHAR
%token INT
%token UNSIGNED
%token VOID
%token TYPEDEF
%token NAME
%token STATIC
%token AUTOMATIC
%token EXTERNAL_DEFINITION
%token EXTERNAL_REFERENCE
/* Tokens not passed to parser. */
%token WHITESPACE
%token COMMENT
/* Pseudo tokens - productions. */
%token PROD_VARIABLE_NAME
%token PROD_TYPE_NAME
%token PROD_FUNCTION_NAME
%token PROD_INTEGER_CONSTANT
%token PROD_PLUS_EXPRESSION
%token PROD_MINUS_EXPRESSION
%token PROD_ASSIGN_EXPRESSION
%token PROD_VARIABLE_REFERENCE_EXPRESSION
%token PROD_PARAMETER
%token PROD_FUNCTION_INVOCATION
%expect 0
%%
file:
/* Nil. */ {
/* Nothing to do. */
}
|declarations {
/* Nothing to do. */
}
;
declarations:
declaration {
/* Nothing to do. */
}
| declarations declaration {
/* Nothing to do. */
}
;
declaration:
variable_def {
/* Nothing to do. */
}
|function_prototype {
/* Nothing to do. */
}
|function {
/* Nothing to do. */
}
;
variable_def:
storage typename NAME init_opt SEMICOLON {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $3;
prod = make_production (PROD_VARIABLE_NAME, tok);
SYMBOL_TABLE_NAME (prod) = tok;
EXPRESSION_TYPE (prod) = $2;
VAR_INIT (prod) = $4;
NUMERIC_TYPE (prod) =
NUMERIC_TYPE (( (struct prod_token_parm_item *)EXPRESSION_TYPE (prod)));
ensure_not_void (NUMERIC_TYPE (prod), tok);
if (insert_tree_name (prod))
{
YYERROR;
}
STORAGE_CLASS_TOKEN (prod) = $1;
set_storage (prod);
if (VAR_INIT (prod))
{
gcc_assert (((struct prod_token_parm_item *)
VAR_INIT (prod))->tp.pro.code);
if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE)
{
error("%Hexternal reference variable %q.*s has an initial value",
&tok->tp.tok.location, tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
VAR_INIT (prod) = NULL;
}
}
prod->tp.pro.code = tree_code_create_variable
(STORAGE_CLASS (prod),
((struct prod_token_parm_item *)SYMBOL_TABLE_NAME (prod))->tp.tok.chars,
((struct prod_token_parm_item *)SYMBOL_TABLE_NAME (prod))->tp.tok.length,
NUMERIC_TYPE (prod),
VAR_INIT (prod) ?
((struct prod_token_parm_item *)VAR_INIT (prod))->tp.pro.code : NULL,
tok->tp.tok.location);
gcc_assert (prod->tp.pro.code);
}
;
storage:
STATIC
|AUTOMATIC
|EXTERNAL_DEFINITION
|EXTERNAL_REFERENCE
;
parameter:
typename NAME {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
struct prod_token_parm_item *prod2;
tok = $2;
prod = make_production (PROD_VARIABLE_NAME, tok);
SYMBOL_TABLE_NAME (prod) = $2;
EXPRESSION_TYPE (prod) = $1;
NUMERIC_TYPE (prod) =
NUMERIC_TYPE (( (struct prod_token_parm_item *)EXPRESSION_TYPE (prod)));
ensure_not_void (NUMERIC_TYPE (prod), tok);
if (insert_tree_name (prod))
{
YYERROR;
}
prod2 = make_production (PROD_PARAMETER, tok);
VARIABLE (prod2) = prod;
$$ = prod2;
}
;
function_prototype:
storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLON {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
struct prod_token_parm_item *type;
struct prod_token_parm_item *first_parms;
struct prod_token_parm_item *last_parms;
struct prod_token_parm_item *this_parms;
struct prod_token_parm_item *this_parm;
struct prod_token_parm_item *this_parm_var;
tok = $3;
prod = make_production (PROD_FUNCTION_NAME, $3);
SYMBOL_TABLE_NAME (prod) = $3;
EXPRESSION_TYPE (prod) = $2;
NUMERIC_TYPE (prod) =
NUMERIC_TYPE (( (struct prod_token_parm_item *)EXPRESSION_TYPE (prod)));
PARAMETERS (prod) = reverse_prod_list ($5);
insert_tree_name (prod);
STORAGE_CLASS_TOKEN (prod) = $1;
set_storage (prod);
switch (STORAGE_CLASS (prod))
{
case STATIC_STORAGE:
case EXTERNAL_DEFINITION_STORAGE:
case EXTERNAL_REFERENCE_STORAGE:
break;
case AUTOMATIC_STORAGE:
error ("%Hfunction %q.*s cannot be automatic",
&tok->tp.tok.location, tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
break;
default:
gcc_unreachable ();
}
type = EXPRESSION_TYPE (prod);
/* Create a parameter list in a non-front end specific format. */
for (first_parms = NULL, last_parms = NULL, this_parm = PARAMETERS (prod);
this_parm;
this_parm = this_parm->tp.pro.next)
{
gcc_assert (this_parm->category == production_category);
this_parm_var = VARIABLE (this_parm);
gcc_assert (this_parm_var);
gcc_assert (this_parm_var->category == production_category);
gcc_assert (this_parm_var->tp.pro.main_token);
this_parms = my_malloc (sizeof (struct prod_token_parm_item));
this_parms->tp.par.variable_name =
this_parm_var->tp.pro.main_token->tp.tok.chars;
this_parms->category = parameter_category;
this_parms->type = NUMERIC_TYPE
(( (struct prod_token_parm_item *)EXPRESSION_TYPE (this_parm_var)));
if (last_parms)
{
last_parms->tp.par.next = this_parms;
last_parms = this_parms;
}
else
{
first_parms = this_parms;
last_parms = this_parms;
}
this_parms->tp.par.where_to_put_var_tree =
& (((struct prod_token_parm_item *)VARIABLE (this_parm))->tp.pro.code);
}
FIRST_PARMS (prod) = first_parms;
prod->tp.pro.code =
tree_code_create_function_prototype (tok->tp.tok.chars,
STORAGE_CLASS (prod),
NUMERIC_TYPE (type),
first_parms, tok->tp.tok.location);
#ifdef ENABLE_CHECKING
/* Check all the parameters have code. */
for (this_parm = PARAMETERS (prod);
this_parm;
this_parm = this_parm->tp.pro.next)
{
gcc_assert ((struct prod_token_parm_item *)VARIABLE (this_parm));
gcc_assert (((struct prod_token_parm_item *)
VARIABLE (this_parm))->tp.pro.code);
}
#endif
}
;
function:
NAME LEFT_BRACE {
struct prod_token_parm_item *proto;
struct prod_token_parm_item search_prod;
struct prod_token_parm_item *tok;
tok = $1;
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
search_prod.category = token_category;
current_function = proto = lookup_tree_name (&search_prod);
if (!proto)
{
error ("%Hno prototype found for %q.*s", &tok->tp.tok.location,
tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
}
gcc_assert (proto->tp.pro.code);
tree_code_create_function_initial (proto->tp.pro.code, tok->tp.tok.location);
}
variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item *tok;
tok = $1;
tree_code_create_function_wrapup (tok->tp.tok.location);
current_function = NULL;
}
;
variable_defs_opt:
/* Nil. */ {
$$ = 0;
}
|variable_defs {
$$ = $1;
}
;
statements_opt:
/* Nil. */ {
$$ = 0;
}
|statements {
$$ = $1;
}
;
variable_defs:
variable_def {
/* Nothing to do. */
}
|variable_defs variable_def {
/* Nothing to do. */
}
;
typename:
INT {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $1;
prod = make_production (PROD_TYPE_NAME, tok);
NUMERIC_TYPE (prod) = SIGNED_INT;
prod->tp.pro.code = tree_code_get_type (NUMERIC_TYPE (prod));
$$ = prod;
}
|UNSIGNED INT {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $1;
prod = make_production (PROD_TYPE_NAME, tok);
NUMERIC_TYPE (prod) = UNSIGNED_INT;
prod->tp.pro.code = tree_code_get_type (NUMERIC_TYPE (prod));
$$ = prod;
}
|CHAR {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $1;
prod = make_production (PROD_TYPE_NAME, tok);
NUMERIC_TYPE (prod) = SIGNED_CHAR;
prod->tp.pro.code = tree_code_get_type (NUMERIC_TYPE (prod));
$$ = prod;
}
|UNSIGNED CHAR {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $1;
prod = make_production (PROD_TYPE_NAME, tok);
NUMERIC_TYPE (prod) = UNSIGNED_CHAR;
prod->tp.pro.code = tree_code_get_type (NUMERIC_TYPE (prod));
$$ = prod;
}
|VOID {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = $1;
prod = make_production (PROD_TYPE_NAME, tok);
NUMERIC_TYPE (prod) = VOID_TYPE;
prod->tp.pro.code = tree_code_get_type (NUMERIC_TYPE (prod));
$$ = prod;
}
;
parameters_opt:
/* Nothing to do. */ {
$$ = 0;
}
| parameters {
$$ = $1;
}
;
parameters:
parameter {
/* Nothing to do. */
$$ = $1;
}
|parameters COMMA parameter {
struct prod_token_parm_item *prod1;
prod1 = $3;
prod1->tp.pro.next = $1; /* Insert in reverse order. */
$$ = prod1;
}
;
statements:
statement {
/* Nothing to do. */
}
|statements statement {
/* Nothing to do. */
}
;
statement:
expression SEMICOLON {
struct prod_token_parm_item *exp;
exp = $1;
tree_code_output_expression_statement (exp->tp.pro.code,
exp->tp.pro.main_token->tp.tok.location);
}
|return SEMICOLON {
/* Nothing to do. */
}
|if_statement {
/* Nothing to do. */
}
;
if_statement:
IF LEFT_PARENTHESIS expression RIGHT_PARENTHESIS {
struct prod_token_parm_item *tok;
struct prod_token_parm_item *exp;
tok = $1;
exp = $3;
ensure_not_void (NUMERIC_TYPE (exp), exp->tp.pro.main_token);
tree_code_if_start (exp->tp.pro.code, tok->tp.tok.location);
}
LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE {
/* Just let the statements flow. */
}
ELSE {
struct prod_token_parm_item *tok;
tok = $1;
tree_code_if_else (tok->tp.tok.location);
}
LEFT_BRACE variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item *tok;
tok = $1;
tree_code_if_end (tok->tp.tok.location);
}
;
return:
tl_RETURN expression_opt {
struct prod_token_parm_item *type_prod;
struct prod_token_parm_item *ret_tok = $1;
struct prod_token_parm_item *exp = $2;
type_prod = EXPRESSION_TYPE (current_function);
if (NUMERIC_TYPE (type_prod) == VOID_TYPE)
if (exp == NULL)
tree_code_generate_return (type_prod->tp.pro.code, NULL);
else
{
warning (0, "%Hredundant expression in return",
&ret_tok->tp.tok.location);
tree_code_generate_return (type_prod->tp.pro.code, NULL);
}
else
if (exp == NULL)
error ("%Hexpression missing in return", &ret_tok->tp.tok.location);
else
{
/* Check same type. */
if (check_type_match (NUMERIC_TYPE (type_prod), exp))
{
gcc_assert (type_prod->tp.pro.code);
gcc_assert (exp->tp.pro.code);
/* Generate the code. */
tree_code_generate_return (type_prod->tp.pro.code,
exp->tp.pro.code);
}
}
}
;
expression_opt:
/* Nil. */ {
$$ = 0;
}
|expression {
struct prod_token_parm_item *exp;
exp = $1;
gcc_assert (exp->tp.pro.code);
$$ = $1;
}
;
expression:
INTEGER {
$$ = make_integer_constant ($1);
}
|variable_ref {
$$ = $1;
}
|expression tl_PLUS expression {
struct prod_token_parm_item *tok = $2;
struct prod_token_parm_item *op1 = $1;
struct prod_token_parm_item *op2 = $3;
int type_code = get_common_type (op1, op2);
if (!type_code)
YYERROR;
$$ = make_plus_expression (tok, op1, op2, type_code, EXP_PLUS);
}
|expression tl_MINUS expression %prec tl_PLUS {
struct prod_token_parm_item *tok = $2;
struct prod_token_parm_item *op1 = $1;
struct prod_token_parm_item *op2 = $3;
int type_code = get_common_type (op1, op2);
if (!type_code)
YYERROR;
$$ = make_plus_expression (tok, op1, op2, type_code, EXP_MINUS);
}
|expression EQUALS expression {
struct prod_token_parm_item *tok = $2;
struct prod_token_parm_item *op1 = $1;
struct prod_token_parm_item *op2 = $3;
int type_code = NUMERIC_TYPE (op1);
if (!type_code)
YYERROR;
$$ = make_plus_expression
(tok, op1, op2, type_code, EXP_EQUALS);
}
|variable_ref ASSIGN expression {
struct prod_token_parm_item *tok = $2;
struct prod_token_parm_item *op1 = $1;
struct prod_token_parm_item *op2 = $3;
int type_code = NUMERIC_TYPE (op1);
if (!type_code)
YYERROR;
$$ = make_plus_expression
(tok, op1, op2, type_code, EXP_ASSIGN);
}
|function_invocation {
$$ = $1;
}
;
function_invocation:
NAME LEFT_PARENTHESIS expressions_with_commas_opt RIGHT_PARENTHESIS {
struct prod_token_parm_item *prod;
struct prod_token_parm_item *tok;
struct prod_token_parm_item search_prod;
struct prod_token_parm_item *proto;
struct prod_token_parm_item *exp;
struct prod_token_parm_item *exp_proto;
struct prod_token_parm_item *var;
int exp_proto_count;
int exp_count;
tree parms;
tree type;
tok = $1;
prod = make_production (PROD_FUNCTION_INVOCATION, tok);
SYMBOL_TABLE_NAME (prod) = tok;
PARAMETERS (prod) = reverse_prod_list ($3);
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
search_prod.category = token_category;
proto = lookup_tree_name (&search_prod);
if (!proto)
{
error ("%Hfunction prototype not found for %q.*s",
&tok->tp.tok.location, tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
}
EXPRESSION_TYPE (prod) = EXPRESSION_TYPE (proto);
NUMERIC_TYPE (prod) = NUMERIC_TYPE (proto);
/* Count the expressions and ensure they match the prototype. */
for (exp_proto_count = 0, exp_proto = PARAMETERS (proto);
exp_proto; exp_proto = exp_proto->tp.pro.next)
exp_proto_count++;
for (exp_count = 0, exp = PARAMETERS (prod); exp; exp = exp->tp.pro.next)
exp_count++;
if (exp_count != exp_proto_count)
{
error ("%Hexpression count mismatch %q.*s with prototype",
&tok->tp.tok.location, tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
}
parms = tree_code_init_parameters ();
for (exp_proto = PARAMETERS (proto), exp = PARAMETERS (prod);
exp_proto;
exp = exp->tp.pro.next, exp_proto = exp_proto->tp.pro.next)
{
gcc_assert (exp);
gcc_assert (exp_proto);
gcc_assert (exp->tp.pro.code);
var = VARIABLE (exp_proto);
gcc_assert (var);
gcc_assert (var->tp.pro.code);
parms = tree_code_add_parameter (parms, var->tp.pro.code,
exp->tp.pro.code);
}
type = tree_code_get_type (NUMERIC_TYPE (prod));
prod->tp.pro.code = tree_code_get_expression (EXP_FUNCTION_INVOCATION, type,
proto->tp.pro.code,
nreverse (parms),
NULL, tok->tp.tok.location);
$$ = prod;
}
;
expressions_with_commas_opt:
/* Nil. */ {
$$ = 0
}
|expressions_with_commas { $$ = $1 }
;
expressions_with_commas:
expression {
struct prod_token_parm_item *exp;
exp = $1;
ensure_not_void (NUMERIC_TYPE (exp), exp->tp.pro.main_token);
$$ = $1;
}
|expressions_with_commas COMMA expression {
struct prod_token_parm_item *exp;
exp = $3;
ensure_not_void (NUMERIC_TYPE (exp), exp->tp.pro.main_token);
exp->tp.pro.next = $1; /* Reverse order. */
$$ = exp;
}
;
variable_ref:
NAME {
struct prod_token_parm_item search_prod;
struct prod_token_parm_item *prod;
struct prod_token_parm_item *symbol_table_entry;
struct prod_token_parm_item *tok;
tree type;
tok = $1;
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
search_prod.category = token_category;
symbol_table_entry = lookup_tree_name (&search_prod);
if (!symbol_table_entry)
{
error ("%Hvariable %q.*s not defined",
&tok->tp.tok.location, tok->tp.tok.length, tok->tp.tok.chars);
YYERROR;
}
prod = make_production (PROD_VARIABLE_REFERENCE_EXPRESSION, tok);
NUMERIC_TYPE (prod) = NUMERIC_TYPE (symbol_table_entry);
type = tree_code_get_type (NUMERIC_TYPE (prod));
if (!NUMERIC_TYPE (prod))
YYERROR;
OP1 (prod) = $1;
prod->tp.pro.code =
tree_code_get_expression (EXP_REFERENCE, type,
symbol_table_entry->tp.pro.code, NULL, NULL,
tok->tp.tok.location);
$$ = prod;
}
;
init_opt:
/* Nil. */ {
$$ = 0;
}
|init {
/* Pass the initialization value up. */
$$ = $1;
};
init:
ASSIGN init_element {
$$ = $2;
}
;
init_element:
INTEGER {
$$ = make_integer_constant ($1);
}
;
%%
/* Print a token VALUE to file FILE. Ignore TYPE which is the token
type. */
void
print_token (FILE *file, unsigned int type ATTRIBUTE_UNUSED, YYSTYPE value)
{
struct prod_token_parm_item *tok;
unsigned int ix;
tok = value;
fprintf (file, "%d \"", LOCATION_LINE (tok->tp.tok.location));
for (ix = 0; ix < tok->tp.tok.length; ix++)
fprintf (file, "%c", tok->tp.tok.chars[ix]);
fprintf (file, "\"");
}
/* Output a message ERROR_MESSAGE from the parser. */
static void
yyerror (const char *error_message)
{
struct prod_token_parm_item *tok;
tok = yylval;
if (tok)
error ("%H%s", &tok->tp.tok.location, error_message);
else
error ("%s", error_message);
}
/* Reverse the order of a token list, linked by parse_next, old first
token is OLD_FIRST. */
static struct prod_token_parm_item*
reverse_prod_list (struct prod_token_parm_item *old_first)
{
struct prod_token_parm_item *current;
struct prod_token_parm_item *next;
struct prod_token_parm_item *prev = NULL;
current = old_first;
prev = NULL;
while (current)
{
gcc_assert (current->category == production_category);
next = current->tp.pro.next;
current->tp.pro.next = prev;
prev = current;
current = next;
}
return prev;
}
/* Ensure TYPE is not VOID. Use NAME as the token for the error location. */
static void
ensure_not_void (unsigned int type, struct prod_token_parm_item* name)
{
if (type == VOID_TYPE)
error ("%Htype must not be void in this context",
&name->tp.tok.location);
}
/* Check TYPE1 and TYPE2 which are integral types. Return the lowest
common type (min is signed int). */
static int
get_common_type (struct prod_token_parm_item *type1,
struct prod_token_parm_item *type2)
{
if (NUMERIC_TYPE (type1) == UNSIGNED_INT)
return UNSIGNED_INT;
if (NUMERIC_TYPE (type2) == UNSIGNED_INT)
return UNSIGNED_INT;
return SIGNED_INT;
}
/* Check type (TYPE_NUM) and expression (EXP) match. Return the 1 if
OK else 0. Must be exact match - same name unless it is an
integral type. */
static int
check_type_match (int type_num, struct prod_token_parm_item *exp)
{
switch (type_num)
{
case SIGNED_INT:
case UNSIGNED_INT:
case SIGNED_CHAR:
case UNSIGNED_CHAR:
switch (NUMERIC_TYPE (exp))
{
case SIGNED_INT:
case UNSIGNED_INT:
case SIGNED_CHAR:
case UNSIGNED_CHAR:
return 1;
case VOID_TYPE:
default:
gcc_unreachable ();
}
break;
case VOID_TYPE:
default:
gcc_unreachable ();
}
}
/* Make a production for an integer constant VALUE. */
static struct prod_token_parm_item *
make_integer_constant (struct prod_token_parm_item* value)
{
struct prod_token_parm_item *tok;
struct prod_token_parm_item *prod;
tok = value;
prod = make_production (PROD_INTEGER_CONSTANT, tok);
if ((tok->tp.tok.chars[0] == (unsigned char)'-')
|| (tok->tp.tok.chars[0] == (unsigned char)'+'))
NUMERIC_TYPE (prod) = SIGNED_INT;
else
NUMERIC_TYPE (prod) = UNSIGNED_INT;
prod->tp.pro.code = tree_code_get_integer_value (tok->tp.tok.chars,
tok->tp.tok.length);
return prod;
}
/* Build a PROD_PLUS_EXPRESSION. This is uses for PLUS, MINUS, ASSIGN
and EQUALS expressions. */
static struct prod_token_parm_item *
make_plus_expression (struct prod_token_parm_item *tok,
struct prod_token_parm_item *op1,
struct prod_token_parm_item *op2,
int type_code, int prod_code)
{
struct prod_token_parm_item *prod;
tree type;
ensure_not_void (NUMERIC_TYPE (op1), op1->tp.pro.main_token);
ensure_not_void (NUMERIC_TYPE (op2), op2->tp.pro.main_token);
prod = make_production (PROD_PLUS_EXPRESSION, tok);
NUMERIC_TYPE (prod) = type_code;
type = tree_code_get_type (type_code);
gcc_assert (type);
OP1 (prod) = op1;
OP2 (prod) = op2;
prod->tp.pro.code = tree_code_get_expression (prod_code, type,
op1->tp.pro.code,
op2->tp.pro.code, NULL,
tok->tp.tok.location);
return prod;
}
/* Set STORAGE_CLASS in PROD according to CLASS_TOKEN. */
static void
set_storage (struct prod_token_parm_item *prod)
{
struct prod_token_parm_item *stg_class;
stg_class = STORAGE_CLASS_TOKEN (prod);
switch (stg_class->type)
{
case STATIC:
STORAGE_CLASS (prod) = STATIC_STORAGE;
break;
case AUTOMATIC:
STORAGE_CLASS (prod) = AUTOMATIC_STORAGE;
break;
case EXTERNAL_DEFINITION:
STORAGE_CLASS (prod) = EXTERNAL_DEFINITION_STORAGE;
break;
case EXTERNAL_REFERENCE:
STORAGE_CLASS (prod) = EXTERNAL_REFERENCE_STORAGE;
break;
default:
gcc_unreachable ();
}
}
/* Set parse trace. */
void
treelang_debug (void)
{
if (option_parser_trace)
yydebug = 1;
}
#ifdef __XGETTEXT__
/* Depending on the version of Bison used to compile this grammar,
it may issue generic diagnostics spelled "syntax error" or
"parse error". To prevent this from changing the translation
template randomly, we list all the variants of this particular
diagnostic here. Translators: there is no fine distinction
between diagnostics with "syntax error" in them, and diagnostics
with "parse error" in them. It's okay to give them both the same
translation. */
const char d1[] = N_("syntax error");
const char d2[] = N_("parse error");
const char d3[] = N_("syntax error; also virtual memory exhausted");
const char d4[] = N_("parse error; also virtual memory exhausted");
const char d5[] = N_("syntax error: cannot back up");
const char d6[] = N_("parse error: cannot back up");
#endif

View file

@ -1,60 +0,0 @@
/* Specific flags and argument handling of the Treelang front-end.
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "gcc.h"
#include "coretypes.h"
#include "tm.h"
void
lang_specific_driver (int *in_argc, const char *const **in_argv,
int *in_added_libraries ATTRIBUTE_UNUSED)
{
int argc = *in_argc, i;
const char *const *argv = *in_argv;
for (i = 1; i < argc; ++i)
{
if (!strcmp (argv[i], "-fversion")) /* Really --version!! */
{
printf ("\
GNU Treelang (GCC %s)\n\
Copyright (C) 2006 Free Software Foundation, Inc.\n\
\n\
GNU Treelang comes with NO WARRANTY, to the extent permitted by law.\n\
You may redistribute copies of GNU Treelang\n\
under the terms of the GNU General Public License.\n\
For more information about these matters, see the file named COPYING\n\
", version_string);
exit (0);
}
}
}
/* Called before linking. Returns 0 on success and -1 on failure. */
int
lang_specific_pre_link (void) /* Not used for Treelang. */
{
return 0;
}
/* Number of extra output files that lang_specific_pre_link may generate. */
int lang_specific_extra_outfiles = 0; /* Not used for Treelang. */

View file

@ -1,107 +0,0 @@
/* Language-level data type conversion for Treelang.
This is a very slightly modified copy of c-convert.c.
Copyright (C) 1987, 1988, 1991, 1998, 2002, 2003, 2007
Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* This file contains the functions for converting C expressions
to different data types. The only entry point is `convert'.
Every language front end must have a `convert' function
but what kind of conversions it does will depend on the language. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "diagnostic.h"
#include "tree.h"
#include "flags.h"
#include "convert.h"
#include "toplev.h"
#include "langhooks.h"
/* Change of width--truncation and extension of integers or reals--
is represented with NOP_EXPR. Proper functioning of many things
assumes that no other conversions can be NOP_EXPRs.
Conversion between integer and pointer is represented with CONVERT_EXPR.
Converting integer to real uses FLOAT_EXPR
and real to integer uses FIX_TRUNC_EXPR.
Here is a list of all the functions that assume that widening and
narrowing is always done with a NOP_EXPR:
In convert.c, convert_to_integer.
In c-typeck.c, build_binary_op (boolean ops), and
c_common_truthvalue_conversion.
In expr.c: expand_expr, for operands of a MULT_EXPR.
In fold-const.c: fold.
In tree.c: get_narrower and get_unwidened. */
/* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value
is always TYPE. This function implements all reasonable
conversions; callers should filter out those that are
not permitted by the language being compiled. */
tree
convert (tree type, tree expr)
{
tree e = expr;
enum tree_code code = TREE_CODE (type);
if (type == TREE_TYPE (expr)
|| TREE_CODE (expr) == ERROR_MARK
|| code == ERROR_MARK || TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
return expr;
if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)))
return fold_build1 (NOP_EXPR, type, expr);
if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
return error_mark_node;
if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE)
{
error ("void value not ignored as it ought to be");
return error_mark_node;
}
if (code == VOID_TYPE)
return build1 (CONVERT_EXPR, type, e);
if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
return fold (convert_to_integer (type, e));
if (code == BOOLEAN_TYPE)
{
tree t = expr;
/* If it returns a NOP_EXPR, we must fold it here to avoid
infinite recursion between fold () and convert (). */
if (TREE_CODE (t) == NOP_EXPR)
return fold_build1 (NOP_EXPR, type, TREE_OPERAND (t, 0));
else
return fold_build1 (NOP_EXPR, type, t);
}
if (code == POINTER_TYPE || code == REFERENCE_TYPE)
return fold (convert_to_pointer (type, e));
if (code == REAL_TYPE)
return fold (convert_to_real (type, e));
if (code == COMPLEX_TYPE)
return fold (convert_to_complex (type, e));
if (code == VECTOR_TYPE)
return fold (convert_to_vector (type, e));
error ("conversion to non-scalar type requested");
return error_mark_node;
}

View file

@ -1,309 +0,0 @@
/* TREELANG Compiler almost main (tree1)
Called by GCC's toplev.c
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
2007, 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not, see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
---------------------------------------------------------------------------
Written by Tim Josling 1999, 2000, 2001, based in part on other
parts of the GCC compiler. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "flags.h"
#include "toplev.h"
#include "version.h"
#include "ggc.h"
#include "tree.h"
#include "cgraph.h"
#include "diagnostic.h"
#include "treelang.h"
#include "treetree.h"
#include "opts.h"
#include "options.h"
extern int yyparse (void);
/* Linked list of symbols - all must be unique in treelang. */
static GTY(()) struct prod_token_parm_item *symbol_table = NULL;
/* Language for usage for messages. */
const char *const language_string = "TREELANG - sample front end for GCC ";
/* Local prototypes. */
void version (void);
/* Global variables. */
extern struct cbl_tree_struct_parse_tree_top* parse_tree_top;
/*
Options.
*/
/* Trace the parser. */
unsigned int option_parser_trace = 0;
/* Trace the lexical analysis. */
unsigned int option_lexer_trace = 0;
/* Warning levels. */
/* Local variables. */
/* This is 1 if we have output the version string. */
static int version_done = 0;
/* Variable nesting level. */
static unsigned int work_nesting_level = 0;
/* Prepare to handle switches. */
unsigned int
treelang_init_options (unsigned int argc ATTRIBUTE_UNUSED,
const char **argv ATTRIBUTE_UNUSED)
{
return CL_Treelang;
}
/* Process a switch - called by opts.c. */
int
treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED,
int value)
{
enum opt_code code = (enum opt_code) scode;
switch (code)
{
case OPT_v:
if (!version_done)
{
fputs (language_string, stdout);
fputs (pkgversion_string, stdout);
fputs (version_string, stdout);
fputs ("\n", stdout);
version_done = 1;
}
break;
case OPT_y:
option_lexer_trace = 1;
option_parser_trace = 1;
break;
case OPT_fparser_trace:
option_parser_trace = value;
break;
case OPT_flexer_trace:
option_lexer_trace = value;
break;
default:
gcc_unreachable ();
}
return 1;
}
/* Language dependent parser setup. */
bool
treelang_init (void)
{
linemap_add (line_table, LC_ENTER, false, main_input_filename, 1);
/* This error will not happen from GCC as it will always create a
fake input file. */
if (!input_filename || input_filename[0] == ' ' || !input_filename[0])
{
if (!version_done)
{
fprintf (stderr, "No input file specified, try --help for help\n");
exit (1);
}
return false;
}
yyin = fopen (input_filename, "r");
if (!yyin)
{
fprintf (stderr, "Unable to open input file %s\n", input_filename);
exit (1);
}
linemap_add (line_table, LC_RENAME, false, "<built-in>", 1);
linemap_line_start (line_table, 0, 1);
/* Init decls, etc. */
treelang_init_decl_processing ();
return true;
}
/* Language dependent wrapup. */
void
treelang_finish (void)
{
fclose (yyin);
}
/* Parse a file. Debug flag doesn't seem to work. */
void
treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
{
source_location s;
linemap_add (line_table, LC_RENAME, false, main_input_filename, 1);
s = linemap_line_start (line_table, 1, 80);
input_location = s;
treelang_debug ();
yyparse ();
cgraph_finalize_compilation_unit ();
linemap_add (line_table, LC_LEAVE, false, NULL, 0);
cgraph_optimize ();
}
/* Allocate SIZE bytes and clear them. Not to be used for strings
which must go in stringpool. */
void *
my_malloc (size_t size)
{
void *mem;
mem = ggc_alloc (size);
if (!mem)
{
fprintf (stderr, "\nOut of memory\n");
abort ();
}
memset (mem, 0, size);
return mem;
}
/* Look up a name in PROD->SYMBOL_TABLE_NAME in the symbol table;
return the symbol table entry from the symbol table if found there,
else 0. */
struct prod_token_parm_item*
lookup_tree_name (struct prod_token_parm_item *prod)
{
struct prod_token_parm_item *this;
struct prod_token_parm_item *this_tok;
struct prod_token_parm_item *tok;
sanity_check (prod);
tok = SYMBOL_TABLE_NAME (prod);
sanity_check (tok);
for (this = symbol_table; this; this = this->tp.pro.next)
{
sanity_check (this);
this_tok = this->tp.pro.main_token;
sanity_check (this_tok);
if (tok->tp.tok.length != this_tok->tp.tok.length)
continue;
if (memcmp (tok->tp.tok.chars, this_tok->tp.tok.chars,
this_tok->tp.tok.length))
continue;
if (option_parser_trace)
fprintf (stderr, "Found symbol %s (%i:%i) as %i \n",
tok->tp.tok.chars, LOCATION_LINE (tok->tp.tok.location),
tok->tp.tok.charno, NUMERIC_TYPE (this));
return this;
}
if (option_parser_trace)
fprintf (stderr, "Not found symbol %s (%i:%i) as %i \n",
tok->tp.tok.chars, LOCATION_LINE (tok->tp.tok.location),
tok->tp.tok.charno, tok->type);
return NULL;
}
/* Insert name PROD into the symbol table. Return 1 if duplicate, 0 if OK. */
int
insert_tree_name (struct prod_token_parm_item *prod)
{
struct prod_token_parm_item *tok;
tok = SYMBOL_TABLE_NAME (prod);
sanity_check (prod);
if (lookup_tree_name (prod))
{
error ("%HDuplicate name %q.*s.", &tok->tp.tok.location,
tok->tp.tok.length, tok->tp.tok.chars);
return 1;
}
prod->tp.pro.next = symbol_table;
NESTING_LEVEL (prod) = work_nesting_level;
symbol_table = prod;
return 0;
}
/* Create a struct productions of type TYPE, main token MAIN_TOK. */
struct prod_token_parm_item *
make_production (int type, struct prod_token_parm_item *main_tok)
{
struct prod_token_parm_item *prod;
prod = my_malloc (sizeof (struct prod_token_parm_item));
prod->category = production_category;
prod->type = type;
prod->tp.pro.main_token = main_tok;
return prod;
}
/* Abort if ITEM is not a valid structure, based on 'category'. */
void
sanity_check (struct prod_token_parm_item *item)
{
switch (item->category)
{
case token_category:
case production_category:
case parameter_category:
break;
default:
gcc_unreachable ();
}
}
/* New garbage collection regime see gty.texi. */
#include "gt-treelang-tree1.h"
/*#include "gt-treelang-treelang.h"*/
#include "gtype-treelang.h"

View file

@ -1,152 +0,0 @@
/* TREELANG Compiler common definitions (treelang.h)
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
---------------------------------------------------------------------------
Written by Tim Josling 1999, 2000, 2001, based in part on other
parts of the GCC compiler. */
#include "input.h"
/* Parse structure type. */
enum category_enum
{ /* These values less likely to be there by chance unlike 0/1,
make checks more meaningful */
token_category = 111,
production_category = 222,
parameter_category = 333
};
/* Input file FILE. */
extern FILE* yyin;
/* Forward references to satisfy mutually recursive definitions. */
struct token_part;
struct production_part;
struct prod_token_parm_item;
typedef struct prod_token_parm_item item;
/* A token from the input file. */
struct token_part GTY(())
{
location_t location;
unsigned int charno;
unsigned int length; /* The value. */
const unsigned char *chars;
};
/* Definitions for fields in production. */
#define NESTING_LEVEL(a) a->tp.pro.info[0] /* Level used for variable definitions. */
/* Numeric type used in type definitions and expressions. */
#define NUMERIC_TYPE(a) a->tp.pro.info[1]
#define SUB_COUNT 5
#define SYMBOL_TABLE_NAME(a) (a->tp.pro.sub[0]) /* Name token. */
#define EXPRESSION_TYPE(a) (a->tp.pro.sub[1]) /* Type identifier. */
#define OP1(a) (a->tp.pro.sub[2]) /* Exp operand1. */
#define PARAMETERS(a) (a->tp.pro.sub[2]) /* Function parameters. */
#define VARIABLE(a) (a->tp.pro.sub[2]) /* Parameter variable ptr. */
#define VAR_INIT(a) (a->tp.pro.sub[2]) /* Variable init. */
#define OP2(a) (a->tp.pro.sub[3]) /* Exp operand2. */
/* Function parameters linked via struct tree_parameter_list. */
#define FIRST_PARMS(a) (a->tp.pro.sub[3])
#define OP3(a) (a->tp.pro.sub[4]) /* Exp operand3. */
#define STORAGE_CLASS_TOKEN(a) (a->tp.pro.sub[4]) /* Storage class token. */
#define STORAGE_CLASS(a) a->tp.pro.flag1 /* Values in treetree.h. */
struct production_part GTY(())
{
struct prod_token_parm_item *main_token; /* Main token for error msgs; variable name token. */
unsigned int info[2]; /* Extra information. */
struct prod_token_parm_item *sub[SUB_COUNT]; /* Sub productions or tokens. */
tree code; /* Back end hook for this item. */
struct prod_token_parm_item *next; /* Next in chains of various types. */
unsigned int flag1:2;
unsigned int flag2:1;
unsigned int flag3:1;
unsigned int flag4:1;
unsigned int flag5:1;
unsigned int flag6:1;
unsigned int flag7:1;
};
/* Storage modes. */
#define STATIC_STORAGE 0
#define AUTOMATIC_STORAGE 1
#define EXTERNAL_REFERENCE_STORAGE 2
#define EXTERNAL_DEFINITION_STORAGE 3
/* Numeric types. */
#define SIGNED_CHAR 1
#define UNSIGNED_CHAR 2
#define SIGNED_INT 3
#define UNSIGNED_INT 4
#define VOID_TYPE 5
/* Expression types. */
#define EXP_PLUS 0 /* Addition expression. */
#define EXP_REFERENCE 1 /* Variable reference. */
#define EXP_ASSIGN 2 /* Assignment. */
#define EXP_FUNCTION_INVOCATION 3 /* Call function. */
#define EXP_MINUS 4 /* Subtraction. */
#define EXP_EQUALS 5 /* Equality test. */
/* Parameter list passed to back end. */
struct parameter_part GTY(())
{
struct prod_token_parm_item *next; /* Next entry. */
const unsigned char *variable_name; /* Name. */
tree * GTY ((skip)) where_to_put_var_tree; /* Where to save decl. */
};
/* A production or a token. */
struct prod_token_parm_item GTY(())
{
enum category_enum category; /* Token or production. */
unsigned int type; /* Token or production type. */
union t_or_p
{
struct token_part GTY((tag ("token_category"))) tok;
struct production_part GTY((tag ("production_category"))) pro;
struct parameter_part GTY((tag ("parameter_category"))) par;
} GTY((desc ("((item *)&%1)->category"))) tp;
};
/* For parser. Alternatively you can define it using %union (bison) or
union. */
#define YYSTYPE void *
void *my_malloc (size_t size);
int insert_tree_name (struct prod_token_parm_item *prod);
struct prod_token_parm_item *lookup_tree_name (struct prod_token_parm_item *prod);
struct prod_token_parm_item *make_production (int type, struct prod_token_parm_item *main_tok);
void mark_production_used (struct prod_token_parm_item *pp);
void mark_token_used (struct prod_token_parm_item *tt);
void treelang_debug (void);
void sanity_check (struct prod_token_parm_item *item);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,66 +0,0 @@
/* TREELANG Compiler definitions for interfacing to treetree.c
(compiler back end interface).
Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding!
---------------------------------------------------------------------------
Written by Tim Josling 1999, 2000, 2001, based in part on other
parts of the GCC compiler. */
tree tree_code_init_parameters (void);
tree tree_code_add_parameter (tree list, tree proto_exp, tree exp);
tree tree_code_get_integer_value (const unsigned char *chars, unsigned int length);
void tree_code_generate_return (tree type, tree exp);
void tree_ggc_storage_always_used (void *m);
tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1,
tree op2, tree op3, location_t loc);
tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
void tree_code_create_function_initial (tree prev_saved,
location_t loc);
void tree_code_create_function_wrapup (location_t loc);
tree tree_code_create_function_prototype (const unsigned char *chars,
unsigned int storage_class,
unsigned int ret_type,
struct prod_token_parm_item* parms,
location_t loc);
tree tree_code_create_variable (unsigned int storage_class,
const unsigned char *chars,
unsigned int length,
unsigned int expression_type,
tree init,
location_t loc);
void tree_code_output_expression_statement (tree code,
location_t loc);
void tree_code_if_start (tree exp, location_t loc);
void tree_code_if_else (location_t loc);
void tree_code_if_end (location_t loc);
tree tree_code_get_type (int type_num);
void treelang_init_decl_processing (void);
void treelang_finish (void);
bool treelang_init (void);
unsigned int treelang_init_options (unsigned int, const char **);
int treelang_handle_option (size_t scode, const char *arg, int value);
void treelang_parse_file (int debug_flag);
void push_var_level (void);
void pop_var_level (void);
const char* get_string (const char *s, size_t l);