A bit more code towards building a babel fish translator for markdown.
This commit is contained in:
parent
fa4966261d
commit
51ea60fe31
|
@ -45,9 +45,10 @@
|
||||||
9D406AC4264A2AD400747EE9 /* babelfish_defs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_defs.h; sourceTree = "<group>"; };
|
9D406AC4264A2AD400747EE9 /* babelfish_defs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_defs.h; sourceTree = "<group>"; };
|
||||||
9D406ACB264A2B5800747EE9 /* babelfish_rez.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_rez.h; sourceTree = "<group>"; };
|
9D406ACB264A2B5800747EE9 /* babelfish_rez.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_rez.h; sourceTree = "<group>"; };
|
||||||
9D406ACD264A2BD300747EE9 /* markdown.rez */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.rez; path = markdown.rez; sourceTree = "<group>"; };
|
9D406ACD264A2BD300747EE9 /* markdown.rez */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.rez; path = markdown.rez; sourceTree = "<group>"; };
|
||||||
9D406AD8264C50E400747EE9 /* init.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.c; };
|
9D406AD8264C50E400747EE9 /* request.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = request.c; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.c; };
|
||||||
9D406AD9264C50F700747EE9 /* filter.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = filter.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
9D406AD9264C50F700747EE9 /* filter.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = filter.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||||
9D406B2D2652155B00747EE9 /* babelfish_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_types.h; sourceTree = "<group>"; };
|
9D406B2D2652155B00747EE9 /* babelfish_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = babelfish_types.h; sourceTree = "<group>"; };
|
||||||
|
9D406B312652D2C800747EE9 /* init.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = init.s; sourceTree = "<group>"; };
|
||||||
9D6532E42626240800105D50 /* md2teach */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = md2teach; sourceTree = BUILT_PRODUCTS_DIR; };
|
9D6532E42626240800105D50 /* md2teach */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = md2teach; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9D6532EA2626240800105D50 /* doNotBuild */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = doNotBuild; sourceTree = BUILT_PRODUCTS_DIR; };
|
9D6532EA2626240800105D50 /* doNotBuild */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = doNotBuild; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9D6532EC2626240800105D50 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
9D6532EC2626240800105D50 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||||
|
@ -111,7 +112,8 @@
|
||||||
9D406ACB264A2B5800747EE9 /* babelfish_rez.h */,
|
9D406ACB264A2B5800747EE9 /* babelfish_rez.h */,
|
||||||
9D406B2D2652155B00747EE9 /* babelfish_types.h */,
|
9D406B2D2652155B00747EE9 /* babelfish_types.h */,
|
||||||
9D406ACD264A2BD300747EE9 /* markdown.rez */,
|
9D406ACD264A2BD300747EE9 /* markdown.rez */,
|
||||||
9D406AD8264C50E400747EE9 /* init.c */,
|
9D406AD8264C50E400747EE9 /* request.c */,
|
||||||
|
9D406B312652D2C800747EE9 /* init.s */,
|
||||||
9D406AD9264C50F700747EE9 /* filter.s */,
|
9D406AD9264C50F700747EE9 /* filter.s */,
|
||||||
);
|
);
|
||||||
path = babelfish;
|
path = babelfish;
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
<key>Binary.xcscheme_^#shared#^_</key>
|
<key>Binary.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>2</integer>
|
<integer>1</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>doNotBuild.xcscheme_^#shared#^_</key>
|
<key>doNotBuild.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>1</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>md2teach.xcscheme_^#shared#^_</key>
|
<key>md2teach.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
|
|
@ -185,8 +185,8 @@ $(OBJDIR)/babelfish/markdown.r: $(FILTERTARGET) $(INITTARGET)
|
||||||
$(FILTERTARGET): $(OBJDIR)/babelfish/filter.ROOT
|
$(FILTERTARGET): $(OBJDIR)/babelfish/filter.ROOT
|
||||||
cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/filter keep="$(abspath $@)"
|
cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/filter keep="$(abspath $@)"
|
||||||
|
|
||||||
$(INITTARGET): $(OBJDIR)/babelfish/init.root $(OBJDIR)/md4c.a
|
$(INITTARGET): $(OBJDIR)/babelfish/init.ROOT $(OBJDIR)/babelfish/request.a $(OBJDIR)/md4c.a
|
||||||
cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/init keep="$(abspath $@)"
|
cd $(OBJDIR); $(LINK) $(LDFLAGS) babelfish/init babelfish/request keep="$(abspath $@)" || rm "$(abspath $@)"
|
||||||
|
|
||||||
$(TARGETDIR)/Markdown: $(OBJDIR)/babelfish/markdown.r
|
$(TARGETDIR)/Markdown: $(OBJDIR)/babelfish/markdown.r
|
||||||
$(MKDIR) $(TARGETDIR)
|
$(MKDIR) $(TARGETDIR)
|
||||||
|
|
|
@ -46,4 +46,15 @@
|
||||||
#define TrShutDown 0x9102
|
#define TrShutDown 0x9102
|
||||||
#define TrRead 0x9103
|
#define TrRead 0x9103
|
||||||
|
|
||||||
|
#define bfContinue 0
|
||||||
|
#define bfDone 0x8000
|
||||||
|
#define bfUserAbort 0x8001
|
||||||
|
#define bfBadFileErr 0x8002
|
||||||
|
#define bfReadErr 0x8003
|
||||||
|
#define bfWriteErr 0x8004
|
||||||
|
#define bfMemErr 0x8005
|
||||||
|
|
||||||
|
#define bfTextGetSettings 1
|
||||||
|
#define bfTextBody 8
|
||||||
|
|
||||||
#endif /* define _GUARD_PROJECTmd2teach_FILEbabelfish_defs_ */
|
#endif /* define _GUARD_PROJECTmd2teach_FILEbabelfish_defs_ */
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef struct TrTransferRecord
|
||||||
Word currentTherm;
|
Word currentTherm;
|
||||||
char * msgPtr;
|
char * msgPtr;
|
||||||
TrDataRecord * dataRecordPtr;
|
TrDataRecord * dataRecordPtr;
|
||||||
char * filePathPtr; /* C string*/
|
GSString255 * filePathPtr;
|
||||||
char * fileNamePtr; /* P string */
|
char * fileNamePtr; /* P string */
|
||||||
} TrTransferRecord;
|
} TrTransferRecord;
|
||||||
|
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
* init.c
|
|
||||||
* md2teach
|
|
||||||
*
|
|
||||||
* Created by Jeremy Rand on 2021-05-12.
|
|
||||||
* Copyright (c) 2021 Jeremy Rand. All rights reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Locator.h>
|
|
||||||
#include <Memory.h>
|
|
||||||
|
|
||||||
#include "babelfish/babelfish_defs.h"
|
|
||||||
#include "babelfish/babelfish_types.h"
|
|
||||||
#include "md4c.h"
|
|
||||||
|
|
||||||
|
|
||||||
#pragma memorymodel 1
|
|
||||||
#pragma rtl
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t myUserId;
|
|
||||||
|
|
||||||
|
|
||||||
void DoStartUp(TrStartUpDataIn * dataIn, TrStartUpDataOut * dataOut)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DoShutDown(TrShutDownDataIn * dataIn, TrShutDownDataOut * dataOut)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DoRead(TrReadDataIn * dataIn, TrReadDataOut * dataOut)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma databank 1
|
|
||||||
#pragma toolparms 1
|
|
||||||
|
|
||||||
pascal unsigned MyRequestProc(uint16_t request, uint32_t dataIn, uint32_t dataOut)
|
|
||||||
{
|
|
||||||
switch (request) {
|
|
||||||
case TrStartUp:
|
|
||||||
DoStartUp((TrStartUpDataIn *)dataIn, (TrStartUpDataOut *)dataOut);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TrShutDown:
|
|
||||||
DoShutDown((TrShutDownDataIn *)dataIn, (TrShutDownDataOut *)dataOut);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TrRead:
|
|
||||||
DoRead((TrReadDataIn *)dataIn, (TrReadDataOut *)dataOut);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma toolparms 0
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
static char myName[48];
|
|
||||||
|
|
||||||
myUserId = MMStartUp();
|
|
||||||
sprintf(myName, "Babelfish~Jeremy~MarkdownTrans%04x", myUserId);
|
|
||||||
AcceptRequests(myName, myUserId, MyRequestProc);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma databank 0
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
;
|
||||||
|
; init.s
|
||||||
|
; md2teach
|
||||||
|
;
|
||||||
|
; Created by Jeremy Rand on 2021-05-17.
|
||||||
|
;
|
||||||
|
;
|
||||||
|
|
||||||
|
mcopy init.macros
|
||||||
|
case on
|
||||||
|
keep init
|
||||||
|
|
||||||
|
init start
|
||||||
|
|
||||||
|
phb
|
||||||
|
phk
|
||||||
|
plb
|
||||||
|
|
||||||
|
|
||||||
|
jsl setup
|
||||||
|
|
||||||
|
plb
|
||||||
|
|
||||||
|
rtl
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* init.c
|
||||||
|
* md2teach
|
||||||
|
*
|
||||||
|
* Created by Jeremy Rand on 2021-05-12.
|
||||||
|
* Copyright (c) 2021 Jeremy Rand. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <font.h>
|
||||||
|
#include <locator.h>
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
|
#include "babelfish/babelfish_defs.h"
|
||||||
|
#include "babelfish/babelfish_types.h"
|
||||||
|
#include "md4c.h"
|
||||||
|
|
||||||
|
|
||||||
|
#pragma memorymodel 1
|
||||||
|
|
||||||
|
|
||||||
|
static uint16_t myUserId;
|
||||||
|
static TrTextDataRecord textRecord;
|
||||||
|
|
||||||
|
|
||||||
|
void DoStartUp(TrStartUpDataIn * dataIn, TrStartUpDataOut * dataOut)
|
||||||
|
{
|
||||||
|
static recvCount = 0;
|
||||||
|
TrTransferRecord * xferRecPtr = dataIn->xferRecPtr;
|
||||||
|
|
||||||
|
asm {
|
||||||
|
stz |lb1
|
||||||
|
lb1: nop
|
||||||
|
nop
|
||||||
|
};
|
||||||
|
|
||||||
|
xferRecPtr->dataKinds[0] = TrFormatText;
|
||||||
|
xferRecPtr->dataKinds[1] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[2] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[3] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[4] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[5] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[6] = TrFormatNone;
|
||||||
|
xferRecPtr->dataKinds[7] = TrFormatNone;
|
||||||
|
xferRecPtr->fullTherm = 512;
|
||||||
|
xferRecPtr->currentTherm = 0;
|
||||||
|
xferRecPtr->dataRecordPtr = (TrDataRecord *)&textRecord;
|
||||||
|
|
||||||
|
textRecord.parmCount = 10;
|
||||||
|
textRecord.actionCode = bfTextGetSettings;
|
||||||
|
textRecord.responseCode = 0;
|
||||||
|
textRecord.textStreamLength = 0;
|
||||||
|
textRecord.textStreamPtr = NULL;
|
||||||
|
textRecord.textStreamHandle = NULL;
|
||||||
|
textRecord.familyId = helvetica;
|
||||||
|
textRecord.fontSize = 12;
|
||||||
|
textRecord.foreColor = 0x0000;
|
||||||
|
textRecord.backColor = 0xffff;
|
||||||
|
textRecord.position = 0;
|
||||||
|
|
||||||
|
recvCount++;
|
||||||
|
dataOut->recvCount = recvCount;
|
||||||
|
dataOut->trResult = bfContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DoShutDown(TrShutDownDataIn * dataIn, TrShutDownDataOut * dataOut)
|
||||||
|
{
|
||||||
|
static recvCount = 0;
|
||||||
|
|
||||||
|
recvCount++;
|
||||||
|
dataOut->recvCount = recvCount;
|
||||||
|
dataOut->trResult = bfContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DoRead(TrReadDataIn * dataIn, TrReadDataOut * dataOut)
|
||||||
|
{
|
||||||
|
static recvCount = 0;
|
||||||
|
|
||||||
|
recvCount++;
|
||||||
|
dataOut->recvCount = recvCount;
|
||||||
|
dataOut->trResult = bfContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma databank 1
|
||||||
|
#pragma toolparms 1
|
||||||
|
|
||||||
|
pascal unsigned MyRequestProc(uint16_t request, uint32_t dataIn, uint32_t dataOut)
|
||||||
|
{
|
||||||
|
switch (request) {
|
||||||
|
case TrStartUp:
|
||||||
|
DoStartUp((TrStartUpDataIn *)dataIn, (TrStartUpDataOut *)dataOut);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TrShutDown:
|
||||||
|
DoShutDown((TrShutDownDataIn *)dataIn, (TrShutDownDataOut *)dataOut);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TrRead:
|
||||||
|
DoRead((TrReadDataIn *)dataIn, (TrReadDataOut *)dataOut);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma toolparms 0
|
||||||
|
#pragma databank 0
|
||||||
|
|
||||||
|
void setup(void)
|
||||||
|
{
|
||||||
|
static char myName[48];
|
||||||
|
|
||||||
|
myUserId = MMStartUp();
|
||||||
|
sprintf(myName+1, "Babelfish~Jeremy~MarkdownTrans%04x", myUserId);
|
||||||
|
*myName = strlen(myName+1);
|
||||||
|
|
||||||
|
AcceptRequests(myName, myUserId, MyRequestProc);
|
||||||
|
|
||||||
|
// return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue