home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
ML
/
TEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-08
|
2KB
|
113 lines
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <stdio.h>
#include <dos.h>
#include <assert.h>
extern "C" {
#include "lib.h"
#include "matrix.h"
#include "ml.h"
void test();
static void StreamInit();
static int StreamOutput( int, int, DataStruct* );
};
#include "message.h"
static TMessageWindow *MessageOut ;
class TMyApp : public TApplication {
public:
TMyApp() : TApplication() {}
protected:
BOOL isidle ;
void InitMainWindow();
BOOL IdleAction( long );
};
void TMyApp::InitMainWindow()
{
isidle = TRUE ;
MessageOut = new TMessageWindow( "message window", 100 );
SetMainWindow( MessageOut->GetWindowPtr() );
}
BOOL TMyApp::IdleAction( long /* idleCount */ )
{
#if 1
if ( isidle )
{
test();
isidle = FALSE ;
}
#endif
return FALSE ;
}
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
if ( LibraryInit() < 0 )
return -1 ;
return TMyApp().Run();
}
void test()
{
int pdebug = FALSE, edebug = FALSE ;
MLInit();
ParseInit();
StreamInit();
DebugMode( pdebug, edebug );
wprintf( "open %s\n", "test.ml" );
ParseSentenseAll( "test.ml" );
#if 1
/* 実行 */
ExecInit();
ExecSentenseAll();
ExecExit();
#endif
ParseExit();
}
DataStruct StreamOut ;
int StreamClassID ;
static void StreamInit()
{
StreamClassID = NewClass( "Stream", 0 );
StreamOut.type = TYPE_OBJECT ;
StreamOut.od.ptr = ObjectAlloc( 0, StreamClassID );
NewConst( "cout", &StreamOut );
NewOperator( StreamClassID, OPE_LSFT, StreamOutput );
}
static int StreamOutput( ident, args, buf )
int ident ;
int args ;
DataStruct *buf ;
{
assert( args == 2 );
ident = FunctionName( "print" );
assert( ident > 0 );
CallFunction( ident, 1, buf+1 );
StackPush( &buf[0] );
return RETURN_RETURN ;
}