[TUHS] Software written in B
Sebastien F4GRX
f4grx at f4grx.net
Mon Jun 19 20:18:45 AEST 2023
Hi,
Sorry for my previous message, my analysis is wrong.
The return value is still a typo, but this expression should not pose a
problem, the AST shows that the postinc has priority, uses a legit
lvalue, which result is multiplied by zero.
This was probably not intended but syntactically correct.
I have added better error identification and now I see that my problem
is in exp(s)
nextarg()[0] is refused.
because nextarg() is not a lvalue, as expected by the indexing operation.
I need to update my code generator so that any expression left of an
index is accepted (and used as an address).
Sebastien
Le 19/06/2023 à 11:52, Sebastien F4GRX a écrit :
> Hello,
>
>
> my own compiler choked on if.b and mail.b because of this invalid
> expression in nxtarg:
>
> if(ap>ac) return(0*ap++);
>
>
> I believe it should instead read:
>
> if(ap>ac) return 0;
>
>
> What do you think about this?
>
>
> PS: The original code gives this AST which shows how my compiler
> interprets this source :
>
> function name nxtarg
> . env: ref to function nxtarg
> . env: ref to function main
> . compound stmt
> . . env: extern ap
> . . env: extern ac
> . . env: extern argv
> . . env: ref to function nxtarg
> . . env: ref to function main
> . . if test
> . . . operation: GT
> . . . . extern declaration ap
> . . . . extern declaration ac
> . . then stmt
> . . . return stmt
> . . . . operation: MUL
> . . . . . value: 0
> . . . . . operation: POSTINC
> . . . . . . extern declaration ap
> . . return stmt
> . . . [LVALUE] operation: INDEX
> . . . . extern declaration argv
> . . . . operation: POSTINC
> . . . . . extern declaration ap
>
> Sebastien
>
>
> Le 17/06/2023 à 10:19, Angelo Papenhoff a écrit :
>> Update: I'm now done with the first pass of this.
>> I reversed all the programs and successfully ran them through my
>> compiler (i haven't assembled or linked anything though).
>> http://squoze.net/B/programs/
>>
>> To check for correctness, the files should of course be compiled,
>> assembled and linked again. Unfortunately my compiler currently
>> does not generate quite the same code as the original one. I will
>> have to work on this.
>> Most importantly & and | are only bitwise operators in the version
>> of B that compiled these programs, but some other differences (like
>> the fixup chain and the way strings are stored) exist too.
>>
>> It would be nice to have a fully working B system on v1/v2 UNIX again,
>> with everything built from source, we can even reconstruct different
>> versions of the runtime (and perhaps standard library). So far the
>> PDP-11 version of my B system has only run on v6 and 2.11BSD.
>>
>> best,
>> aap
>>
>> On 14/06/23, Angelo Papenhoff wrote:
>>> I will hopefully continue with this in the next time (if, goto, mail
>>> and
>>> glob are left).
More information about the TUHS
mailing list