home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
ML
/
TEST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-06
|
1KB
|
86 lines
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "lib.h"
#include "ml.h"
static void StreamInit( void );
static int StreamOutput( int, int, DataStruct* );
void main( argc, argv )
int argc ;
char *argv[] ;
{
int i ;
int pdebug = FALSE, edebug = FALSE ;
MLInit();
ParseInit();
StreamInit();
for( i = 1 ; i < argc ; i++ )
{
if ( argv[i][0] == '-' )
{
switch( argv[i][1] )
{
case 'P':
case 'p':
pdebug = TRUE ;
break ;
case 'E':
case 'e':
edebug = TRUE ;
break ;
}
DebugMode( pdebug, edebug );
}
else
{
/* 構文解析 */
printf( "open %s\n", argv[i] );
ParseSentenseAll( argv[i] );
}
}
#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 ;
}