Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Pray to God, but keep rowing to shore. -- Russian Proverb


devel / comp.lang.misc / Re: Language-independent format for master config

SubjectAuthor
o Language-independent format for master configluserdroog

1
Re: Language-independent format for master config

<36066340-f569-4697-a7f5-0f012b194567n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9875&group=comp.lang.misc#9875

  copy link   Newsgroups: comp.lang.misc
X-Received: by 2002:a05:620a:28cc:: with SMTP id l12mr5041901qkp.48.1640357821403;
Fri, 24 Dec 2021 06:57:01 -0800 (PST)
X-Received: by 2002:ac8:46d8:: with SMTP id h24mr1856405qto.348.1640357821196;
Fri, 24 Dec 2021 06:57:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.misc
Date: Fri, 24 Dec 2021 06:57:01 -0800 (PST)
In-Reply-To: <spqcpo$9vl$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=97.87.183.68; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 97.87.183.68
References: <spo8f9$oa7$1@dont-email.me> <spprti$5n4$1@dont-email.me> <spqcpo$9vl$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <36066340-f569-4697-a7f5-0f012b194567n@googlegroups.com>
Subject: Re: Language-independent format for master config
From: mijo...@yahoo.com (luserdroog)
Injection-Date: Fri, 24 Dec 2021 14:57:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 81
 by: luserdroog - Fri, 24 Dec 2021 14:57 UTC

On Monday, December 20, 2021 at 10:59:38 AM UTC-6, James Harris wrote:
> On 20/12/2021 12:11, Bart wrote:
> > On 19/12/2021 21:33, James Harris wrote:
> >> We've previously discussed the potential benefits of having a master
> >> configuration which can be used to generate types, constants,
> >> structures, declarations etc for more than one programming language so
> >> that each language gets the same info.
> >>
> >> As it happens, I find myself in that position now. I need assembly and
> >> my own language to cooperate using some common definitions so ISTM the
> >> right approach to have a master set of definitions and use it to
> >> create declarations and the like both for the assembler and for my
> >> compiler.
> >>
> >> Before I jump in and devise something new ... do you know of any
> >> format and tools which exist already?
> >>
> >> Or since my needs will probably be very limited could it be simpler to
> >> avoid a comprehensive and bulky package and just to make up something
> >> from scratch? And IYO what should be in it?
> >
> >
> > I don't recall that discussion.
> >
> > It sounds like you're thinking of a special language just for
> > declarations, which transpiles to multiple targets.
> I don't know that it would be a 'language' but preferably something much
> simpler. For example, the master file might have a couple of constants,
> one typed and one not typed.
>
> constant int32 LIMIT 906
> constant BLOCKSIZE 512
>
> That would result in assembly something like
>
> LIMIT dd 906
> BLOCKSIZE equ 512
>
> and in C something like
>
> int32_t LIMIT = 906;
> #define BLOCKSIZE 512
>
> IOW the typed one would reserve storage whereas the other would not, and
> there could be an arbitrary number of each. For C, LIMIT and BLOCKSIZE
> would likely be written into a header and after being imported could be
> used in other C code as normal.
>
> (There's possibly a const qualification that should be added to the
> LIMIT but I don't know where.)

This seems simple enough to just code up in your favorite scripting language.
Being a weirdo, here's how I'd do it using PostScript.

%!
/mydefs [
{(int32_t)(LIMIT)(906)data}
{(BLOCKSIZE)(512)constant}
] def
/print-C {
<<
/data { 3 -1 roll print( )print exch print( = )print print(;\n)print }
/constant { (#define )print exch print( )print print(\n)print }
>> begin
{exec}forall
end
} def
/print-ASM {
<<
/data { exch print( dd )print print(\n)print pop }
/constant { exch print( equ )print print(\n)print }
>> begin
{exec}forall
end
} def

%Usage:
% mydefs print-C
% mydefs print-ASM
%from command line:
% gsnd -q mydefs.ps -c "mydefs print-C"
% gsnd -q mydefs.ps -c "mydefs print-ASM"

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor