home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
gnat-2.06-src.tgz
/
tar.out
/
fsf
/
gnat
/
ada
/
xsinfo.spt
< prev
next >
Wrap
Text File
|
1996-09-28
|
6KB
|
152 lines
*-----------------------------------------------------------------------------
*- --
*- G N A T --
*- --
*- COMPILER UTILITIES --
*- --
*- X S I N F O --
*- --
*- $Revision: 1.13 $ --
*- --
*- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved --
*- --
*- GNAT is free software; you can redistribute it and/or modify it under --
*- terms of the GNU General Public License as published by the Free Soft- --
*- ware Foundation; either version 2, or (at your option) any later ver- --
*- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
*- OUT 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 distributed with GNAT; see file COPYING. If not, write --
*- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
*- --
*-----------------------------------------------------------------------------
* Program to construct C header file a-sinfo.h (C version of sinfo.ads spec,
* for use by Gigi, contains all definitions and access functions, but does not
* contain set procedures, since Gigi is not allowed to modify the GNAT tree)
*
* Input files:
*
* sinfo.ads Spec of Sinfo package
*
* Output files:
*
* a-sinfo.h Corresponding c header file
*
* Note: this program assumes that sinfo.ads has passed the error checks which
* are carried out by the csinfo utility, so it does not duplicate these checks
*
* An optional argument allows the specification of an output file name to
* override the default a-sinfo.h file name for the generated output file.
"$Revision: 1.13 $" "$Rev" "ision: " break(' ') $ xsinforev
arg = trim(host(1))
arg = ident(arg, "0") trim(host(0))
ofile = ident(arg) 'a-sinfo.h'
ofile = differ(arg) arg
lineno = 0
&stlimit = -1
input(.in,1,'sinfo.ads')
output(.out,2,ofile)
&anchor = 1
wsp = span(' ' char(9)) | ''
* Get sinfo rev and write header to output file
slp line = in
ident(line) :s(start)
line breakx('$') '$Rev' 'ision: ' break(' ') $ sinforev :s(vsn)
line '-- S p e c ' =
. '-- C Header File '
line '--' = '/*'
line rtab(2) $ a '--' = a '*/'
out = line :(slp)
vsn out = '/* Generated by xsinfo revision ' xsinforev
. ' using */'
out = '/* sinfo.ads revision ' sinforev
. ' */' :(slp)
start
* Get non-comment non-blank line
define('getline()a,b') :(n1)
getline getline = trim(in) :f(err)
ident(getline) :s(getline)
lineno = lineno + 1
getline wsp $ a '--' = :f(return)
getline span(' ') 'End functions (note' :s(freturn)f(getline)
n1 line = getline() :f(err)
line 'with' :s(n2)
out = line :(n1)
n2 line = getline() :f(err)
line "package" :f(n2)
n3 line = getline() :f(err)
line wsp $ a "type Node_Kind is" :s(n4)
out = line :(n3)
n4 out =
NKV = 0
n5 line = getline() :f(err)
line wsp $ a 'N_' break(',)') $ name
. len(1) $ term :s(n6)
out = line :(n5)
n6 out = a '#define N_' name ' ' NKV
NKV = NKV + 1
ident(term,',') :s(n5)
out =
out = a '#define Number_Node_Kinds ' NKV
n7 line = getline() :f(err)
line wsp $ a 'subtype ' break(' ') $ N :s(n8)
line wsp $ a 'function' :s(n10)
out = line :(n7)
n8 out = a 'SUBTYPE (' N ', Node_Kind, '
line = getline()
* normal case
line wsp break(' ') $ N1
. ' .. ' break(';') $ N2 :f(n8a)
out = a ' ' N1 ', ' N2 ')' :(n7)
* continuation case
n8a line wsp break(' ') $ N1 " .." rpos(0) :f(err)
getline() span(' ') break(";") $ N2 :f(err)
out = a ' ' N1 ','
out = a ' ' N2 ')' :(n7)
n9 line = getline() :f(n13)
n10 line wsp $ a 'function ' rem $ Name :s(n11)
out = line :(n9)
n11 line = getline()
line
. wsp '(N : '
. break(')') $ arg
. ') return ' break(';') $ rtn
. ';' wsp '--' wsp rem $ comment :f(err)
out = a 'INLINE ' rpad(rtn,9)
. ' ' rpad(Name,30)
. ' (' arg ' N)'
out = a ' '
. '{ return ' comment ' (N); }' :(n9)
n13 out =
end