lex_by_file( FileName ) :-
get_input_from_file( FileName, TokenList ),
lex( TokenList, OutputList ),
%write_output( OutputList ), !.
maplist(writeln,OutputList),!.
%% atom_number(atom, number)
lex([],[]).
lex(['int' | T], ['TYPE: int' | R]) :- lex(T, R).
lex(['bool' | T], ['TYPE: bool'] | R) :- lex(T, R).
lex([',' | T], ['COMMA: ,'] | R) :- lex(T, R).
lex([X | T], [X | R]) :- lex(T, R).
bGV4X2J5X2ZpbGUoIEZpbGVOYW1lICkgOi0KCWdldF9pbnB1dF9mcm9tX2ZpbGUoIEZpbGVOYW1lLCBUb2tlbkxpc3QgKSwKCWxleCggVG9rZW5MaXN0LCBPdXRwdXRMaXN0ICksCgkld3JpdGVfb3V0cHV0KCBPdXRwdXRMaXN0ICksICEuCgltYXBsaXN0KHdyaXRlbG4sT3V0cHV0TGlzdCksIS4KCiUlIGF0b21fbnVtYmVyKGF0b20sIG51bWJlcikKbGV4KFtdLFtdKS4KbGV4KFsnaW50JyB8IFRdLCBbJ1RZUEU6IGludCcgfCBSXSkgOi0gIGxleChULCBSKS4KbGV4KFsnYm9vbCcgfCBUXSwgWydUWVBFOiBib29sJ10gfCBSKSA6LSBsZXgoVCwgUikuCmxleChbJywnIHwgVF0sIFsnQ09NTUE6ICwnXSB8IFIpIDotIGxleChULCBSKS4KbGV4KFtYIHwgVF0sIFtYIHwgUl0pIDotIGxleChULCBSKS4K
CiNpbmNsdWRlICZsdDtzdGRpby5oJmd0OwojaW5jbHVkZSAmbHQ7c3RyaW5nLmgmZ3Q7Cgp2b2lkIGdlbmVyYXRlVGhyZWVBZGRyZXNzQ29kZShjaGFyICpleHByZXNzaW9uKSB7CiAgICBjaGFyICp0b2tlbjsKICAgIHRva2VuID0gc3RydG9rKGV4cHJlc3Npb24sICZxdW90OyAmcXVvdDspOwogICAgd2hpbGUgKHRva2VuICE9IE5VTEwpIHsKICAgICAgICBpZiAoc3RyY21wKHRva2VuLCAmcXVvdDsrJnF1b3Q7KSA9PSAwIHx8IHN0cmNtcCh0b2tlbiwgJnF1b3Q7LSZxdW90OykgPT0gMCkgewogICAgICAgICAgICBjaGFyICpvcGVyYW5kMSA9IHN0cnRvayhOVUxMLCAmcXVvdDsgJnF1b3Q7KTsKICAgICAgICAgICAgY2hhciAqb3BlcmFuZDIgPSBzdHJ0b2soTlVMTCwgJnF1b3Q7ICZxdW90Oyk7CiAgICAgICAgICAgIHByaW50ZigmcXVvdDt0MCA9ICVzICVjICVzXG4mcXVvdDssIG9wZXJhbmQxLCB0b2tlblswXSwgb3BlcmFuZDIpOwogICAgICAgIH0KICAgICAgICB0b2tlbiA9IHN0cnRvayhOVUxMLCAmcXVvdDsgJnF1b3Q7KTsKICAgIH0KfQoKaW50IG1haW4oKSB7CiAgICBjaGFyIGV4cHJlc3Npb25bMTAwXTsKICAgIHByaW50ZigmcXVvdDtFbnRlciBhbiBhcml0aG1ldGljIGV4cHJlc3Npb246ICZxdW90Oyk7CiAgICBmZ2V0cyhleHByZXNzaW9uLCBzaXplb2YoZXhwcmVzc2lvbiksIHN0ZGluKTsKICAgIGdlbmVyYXRlVGhyZWVBZGRyZXNzQ29kZShleHByZXNzaW9uKTsKICAgIHJldHVybiAwOwp9CmBgYA==
#include <stdio.h>
#include <string.h>
void generateThreeAddressCode(char *expression) {
char *token;
token = strtok(expression, " ");
while (token != NULL) {
if (strcmp(token, "+") == 0 || strcmp(token, "-") == 0) {
char *operand1 = strtok(NULL, " ");
char *operand2 = strtok(NULL, " ");
printf("t0 = %s %c %s\n", operand1, token[0], operand2);
}
token = strtok(NULL, " ");
}
}
int main() {
char expression[100];
printf("Enter an arithmetic expression: ");
fgets(expression, sizeof(expression), stdin);
generateThreeAddressCode(expression);
return 0;
}
```