This commit is contained in:
2008-03-21 03:49:53 +00:00
parent f9c7b599d4
commit b52f039c69
358 changed files with 6823 additions and 6288 deletions

436
ase/cmd/lsp/aselsp.vcproj Normal file
View File

@ -0,0 +1,436 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="aselsp"
ProjectGUID="{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
RootNamespace="aselsp"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../../debug/bin/aselsp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aselsp.lib asecmn.lib aseutl.lib"
OutputFile="$(OutDir)\aselsp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\debug\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../../debug/bin/aselsp.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\../../debug/bin/aselsp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aselsp.lib asecmn.lib aseutl.lib"
OutputFile="$(OutDir)\aselsp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\debug\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../../debug/bin/aselsp.pdb"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\../../release/bin/aselsp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aselsp.lib asecmn.lib aseutl.lib"
OutputFile="$(OutDir)\aselsp.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\release\lib"
ProgramDatabaseFile=".\../../release/bin/aselsp.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\../../release/bin/aselsp.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aselsp.lib asecmn.lib aseutl.lib"
OutputFile="$(OutDir)\aselsp.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\release\lib"
ProgramDatabaseFile=".\../../release/bin/aselsp.pdb"
SubSystem="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="lsp.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

102
ase/cmd/lsp/asetestlsp.dsp Normal file
View File

@ -0,0 +1,102 @@
# Microsoft Developer Studio Project File - Name="asetestlsp" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=asetestlsp - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "asetestlsp.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "asetestlsp.mak" CFG="asetestlsp - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "asetestlsp - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "asetestlsp - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "asetestlsp - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../release/bin"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 aselsp.lib asecmn.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /machine:I386 /out:"../../release/bin/aselsp.exe" /libpath:"../../release/lib"
!ELSEIF "$(CFG)" == "asetestlsp - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../debug/bin"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 aselsp.lib asecmn.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../debug/bin/aselsp.exe" /pdbtype:sept /libpath:"../../debug/lib"
!ENDIF
# Begin Target
# Name "asetestlsp - Win32 Release"
# Name "asetestlsp - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\lsp.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

13
ase/cmd/lsp/descrip.mms Normal file
View File

@ -0,0 +1,13 @@
#
# OpenVMS MMS/MMK
#
objects = lsp.obj
CFLAGS = /include="../../.."
#CFLAGS = /pointer_size=long /include="../../.."
aselsp.exe : $(objects)
link /executable=aselsp.exe $(objects),[-.-.lsp]aselsp/library
lsp.obj depends_on lsp.c

455
ase/cmd/lsp/lsp.c Normal file
View File

@ -0,0 +1,455 @@
/*
* $Id: lsp.c,v 1.5 2007/05/16 09:15:14 bacon Exp $
*/
#include <ase/lsp/lsp.h>
#include <ase/utl/ctype.h>
#include <ase/utl/stdio.h>
#include <ase/utl/main.h>
#include <ase/utl/getopt.h>
#include <ase/cmn/mem.h>
#include <ase/cmn/str.h>
#include <string.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#include <tchar.h>
#endif
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
#if defined(__linux) && defined(_DEBUG)
#include <mcheck.h>
#endif
#ifndef NDEBUG
void ase_assert_abort (void)
{
abort ();
}
void ase_assert_printf (const ase_char_t* fmt, ...)
{
va_list ap;
#ifdef _WIN32
int n;
ase_char_t buf[1024];
#endif
va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
#if defined(_MSC_VER) && (_MSC_VER<1400)
MessageBox (NULL, buf,
ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
#else
MessageBox (NULL, buf,
ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR);
#endif
#else
ase_vprintf (fmt, ap);
#endif
va_end (ap);
}
#endif
static ase_ssize_t get_input (
int cmd, void* arg, ase_char_t* data, ase_size_t size)
{
switch (cmd)
{
case ASE_LSP_IO_OPEN:
case ASE_LSP_IO_CLOSE:
return 0;
case ASE_LSP_IO_READ:
{
/*
if (ase_fgets (data, size, stdin) == ASE_NULL)
{
if (ferror(stdin)) return -1;
return 0;
}
return ase_lsp_strlen(data);
*/
ase_cint_t c;
if (size <= 0) return -1;
c = ase_fgetc (stdin);
if (c == ASE_CHAR_EOF)
{
if (ferror(stdin)) return -1;
return 0;
}
data[0] = c;
return 1;
}
}
return -1;
}
static ase_ssize_t put_output (
int cmd, void* arg, ase_char_t* data, ase_size_t size)
{
switch (cmd)
{
case ASE_LSP_IO_OPEN:
case ASE_LSP_IO_CLOSE:
return 0;
case ASE_LSP_IO_WRITE:
{
int n = ase_fprintf (
stdout, ASE_T("%.*s"), size, data);
if (n < 0) return -1;
return size;
}
}
return -1;
}
#ifdef _WIN32
typedef struct prmfns_data_t prmfns_data_t;
struct prmfns_data_t
{
HANDLE heap;
};
#endif
static void* custom_lsp_malloc (void* custom, ase_size_t n)
{
#ifdef _WIN32
return HeapAlloc (((prmfns_data_t*)custom)->heap, 0, n);
#else
return malloc (n);
#endif
}
static void* custom_lsp_realloc (void* custom, void* ptr, ase_size_t n)
{
#ifdef _WIN32
/* HeapReAlloc behaves differently from realloc */
if (ptr == NULL)
return HeapAlloc (((prmfns_data_t*)custom)->heap, 0, n);
else
return HeapReAlloc (((prmfns_data_t*)custom)->heap, 0, ptr, n);
#else
return realloc (ptr, n);
#endif
}
static void custom_lsp_free (void* custom, void* ptr)
{
#ifdef _WIN32
HeapFree (((prmfns_data_t*)custom)->heap, 0, ptr);
#else
free (ptr);
#endif
}
static ase_bool_t custom_lsp_isupper (void* custom, ase_cint_t c)
{
return ase_isupper (c);
}
static ase_bool_t custom_lsp_islower (void* custom, ase_cint_t c)
{
return ase_islower (c);
}
static ase_bool_t custom_lsp_isalpha (void* custom, ase_cint_t c)
{
return ase_isalpha (c);
}
static ase_bool_t custom_lsp_isdigit (void* custom, ase_cint_t c)
{
return ase_isdigit (c);
}
static ase_bool_t custom_lsp_isxdigit (void* custom, ase_cint_t c)
{
return ase_isxdigit (c);
}
static ase_bool_t custom_lsp_isalnum (void* custom, ase_cint_t c)
{
return ase_isalnum (c);
}
static ase_bool_t custom_lsp_isspace (void* custom, ase_cint_t c)
{
return ase_isspace (c);
}
static ase_bool_t custom_lsp_isprint (void* custom, ase_cint_t c)
{
return ase_isprint (c);
}
static ase_bool_t custom_lsp_isgraph (void* custom, ase_cint_t c)
{
return ase_isgraph (c);
}
static ase_bool_t custom_lsp_iscntrl (void* custom, ase_cint_t c)
{
return ase_iscntrl (c);
}
static ase_bool_t custom_lsp_ispunct (void* custom, ase_cint_t c)
{
return ase_ispunct (c);
}
static ase_cint_t custom_lsp_toupper (void* custom, ase_cint_t c)
{
return ase_toupper (c);
}
static ase_cint_t custom_lsp_tolower (void* custom, ase_cint_t c)
{
return ase_tolower (c);
}
static int custom_lsp_sprintf (
void* custom, ase_char_t* buf, ase_size_t size,
const ase_char_t* fmt, ...)
{
int n;
va_list ap;
va_start (ap, fmt);
n = ase_vsprintf (buf, size, fmt, ap);
va_end (ap);
return n;
}
static void custom_lsp_dprintf (void* custom, const ase_char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
ase_vfprintf (stderr, fmt, ap);
va_end (ap);
}
static int opt_memsize = 1000;
static int opt_meminc = 1000;
static void print_usage (const ase_char_t* argv0)
{
ase_fprintf (ASE_STDERR,
ASE_T("Usage: %s [options]\n"), argv0);
ase_fprintf (ASE_STDERR,
ASE_T(" -h print this message\n"));
ase_fprintf (ASE_STDERR,
ASE_T(" -m integer number of memory cells\n"));
ase_fprintf (ASE_STDERR,
ASE_T(" -i integer number of memory cell increments\n"));
}
static int handle_args (int argc, ase_char_t* argv[])
{
ase_opt_t opt;
ase_cint_t c;
ase_memset (&opt, 0, ASE_SIZEOF(opt));
opt.str = ASE_T("m:i:");
while ((c = ase_getopt (argc, argv, &opt)) != ASE_CHAR_EOF)
{
switch (c)
{
case ASE_T('h'):
print_usage (argv[0]);
return -1;
case ASE_T('m'):
opt_memsize = ase_strtoi(opt.arg);
break;
case ASE_T('i'):
opt_meminc = ase_strtoi(opt.arg);
break;
case ASE_T('?'):
ase_fprintf (ASE_STDERR, ASE_T("Error: illegal option - %c\n"), opt.opt);
print_usage (argv[0]);
return -1;
case ASE_T(':'):
ase_fprintf (ASE_STDERR, ASE_T("Error: missing argument for %c\n"), opt.opt);
print_usage (argv[0]);
return -1;
}
}
if (opt.ind < argc)
{
ase_printf (ASE_T("Error: redundant argument - %s\n"), argv[opt.ind]);
print_usage (argv[0]);
return -1;
}
if (opt_memsize <= 0)
{
ase_printf (ASE_T("Error: invalid memory size given\n"));
return -1;
}
return 0;
}
int lsp_main (int argc, ase_char_t* argv[])
{
ase_lsp_t* lsp;
ase_lsp_obj_t* obj;
ase_lsp_prmfns_t prmfns;
#ifdef _WIN32
prmfns_data_t prmfns_data;
#endif
if (handle_args (argc, argv) == -1) return -1;
ase_memset (&prmfns, 0, ASE_SIZEOF(prmfns));
prmfns.mmgr.malloc = custom_lsp_malloc;
prmfns.mmgr.realloc = custom_lsp_realloc;
prmfns.mmgr.free = custom_lsp_free;
#ifdef _WIN32
prmfns_data.heap = HeapCreate (0, 1000000, 1000000);
if (prmfns_data.heap == NULL)
{
ase_printf (ASE_T("Error: cannot create an lsp heap\n"));
return -1;
}
prmfns.mmgr.custom_data = &prmfns_data;
#else
prmfns.mmgr.custom_data = ASE_NULL;
#endif
prmfns.ccls.is_upper = custom_lsp_isupper;
prmfns.ccls.is_lower = custom_lsp_islower;
prmfns.ccls.is_alpha = custom_lsp_isalpha;
prmfns.ccls.is_digit = custom_lsp_isdigit;
prmfns.ccls.is_xdigit = custom_lsp_isxdigit;
prmfns.ccls.is_alnum = custom_lsp_isalnum;
prmfns.ccls.is_space = custom_lsp_isspace;
prmfns.ccls.is_print = custom_lsp_isprint;
prmfns.ccls.is_graph = custom_lsp_isgraph;
prmfns.ccls.is_cntrl = custom_lsp_iscntrl;
prmfns.ccls.is_punct = custom_lsp_ispunct;
prmfns.ccls.to_upper = custom_lsp_toupper;
prmfns.ccls.to_lower = custom_lsp_tolower;
prmfns.ccls.custom_data = ASE_NULL;
prmfns.misc.sprintf = custom_lsp_sprintf;
prmfns.misc.dprintf = custom_lsp_dprintf;
prmfns.misc.custom_data = ASE_NULL;
lsp = ase_lsp_open (&prmfns, opt_memsize, opt_meminc);
if (lsp == ASE_NULL)
{
#ifdef _WIN32
HeapDestroy (prmfns_data.heap);
#endif
ase_printf (ASE_T("Error: cannot create a lsp instance\n"));
return -1;
}
ase_printf (ASE_T("ASELSP 0.0001\n"));
ase_lsp_attinput (lsp, get_input, ASE_NULL);
ase_lsp_attoutput (lsp, put_output, ASE_NULL);
while (1)
{
ase_printf (ASE_T("ASELSP $ "));
fflush (stdout);
obj = ase_lsp_read (lsp);
if (obj == ASE_NULL)
{
int errnum;
const ase_char_t* errmsg;
ase_lsp_geterror (lsp, &errnum, &errmsg);
if (errnum != ASE_LSP_EEND &&
errnum != ASE_LSP_EEXIT)
{
ase_printf (
ASE_T("error in read: [%d] %s\n"),
errnum, errmsg);
}
/* TODO: change the following check */
if (errnum < ASE_LSP_ESYNTAX) break;
continue;
}
if ((obj = ase_lsp_eval (lsp, obj)) != ASE_NULL)
{
ase_lsp_print (lsp, obj);
ase_printf (ASE_T("\n"));
}
else
{
int errnum;
const ase_char_t* errmsg;
ase_lsp_geterror (lsp, &errnum, &errmsg);
if (errnum == ASE_LSP_EEXIT) break;
ase_printf (
ASE_T("error in eval: [%d] %s\n"),
errnum, errmsg);
}
}
ase_lsp_close (lsp);
#ifdef _WIN32
HeapDestroy (prmfns_data.heap);
#endif
return 0;
}
int ase_main (int argc, ase_achar_t* argv[])
{
int n;
#if defined(__linux) && defined(_DEBUG)
mtrace ();
#endif
n = ase_runmain (argc, argv, lsp_main);
#if defined(__linux) && defined(_DEBUG)
muntrace ();
#endif
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
_CrtDumpMemoryLeaks ();
wprintf (L"Press ENTER to quit\n");
getchar ();
#endif
return n;
}

23
ase/cmd/lsp/makefile.in Normal file
View File

@ -0,0 +1,23 @@
#
# $Id: makefile.in,v 1.3 2007/04/30 08:32:50 bacon Exp $
#
CC = @CC@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/@BUILDMODE@/lib
LIBS = @LIBS@ -laselsp -lasecmn -laseutl -lm
MODE = @BUILDMODE@
OUT_DIR = ../../$(MODE)/bin
all: $(OUT_DIR)/aselsp
$(OUT_DIR)/aselsp: $(OUT_DIR) lsp.c
$(CC) $(CFLAGS) -o $@ lsp.c $(LDFLAGS) $(LIBS)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
clean:
rm -rf $(OUT_DIR)/aselsp

View File

@ -0,0 +1,19 @@
CC = bcc32
LD = ilink32
CFLAGS = -I..\..\..
LDFLAGS = -L..\..\cmn -L..\..\lsp -L..\..\utl
LIBS = import32.lib cw32mt.lib asecmn.lib aselsp.lib aseutl.lib
STARTUP = c0x32w.obj
all: aselsp
aselsp: lsp.obj
$(LD) $(LDFLAGS) $(STARTUP) lsp.obj,$@.exe,,$(LIBS),,
clean:
del $(OBJS) *.obj $(OUT)
.SUFFIXES: .c .obj
.c.obj:
$(CC) $(CFLAGS) -c $<

View File

@ -0,0 +1,17 @@
CC = cl
CFLAGS = /nologo /MT /GX /W3 /GR- -I..\..\..
LDFLAGS = /libpath:..\..\cmn /libpath:..\..\lsp /libpath:..\..\utl
LIBS = asecmn.lib aselsp.lib aseutl.lib user32.lib
all: aselsp
aselsp: lsp.obj
link /nologo /out:$@.exe $(LDFLAGS) $(LIBS) lsp.obj
clean:
del $(OBJS) *.obj lsp.exe
.SUFFIXES: .c .obj
.c.obj:
$(CC) /c $(CFLAGS) $<

21
ase/cmd/lsp/t1.lsp Normal file
View File

@ -0,0 +1,21 @@
(setq x (lambda (x) (car x)))
((lambda (x) (+ x 99)) (x '(10 20 30)))
((lambda (x) ((lambda (y) (+ y 1)) x)) 10)
; lisp....
((lambda (x) ((macro (y) (+ y 1)) x)) 10)
;;;;;;;
(setq init-rand (macro (seed) (lambda () (setq seed (+ seed 1)))))
(setq init-rand (lambda (seed) (lambda () (setq seed (+ seed 1)))))
(setq rand (init-rand 1))
(rand)
(defun init-rand (seed) (lambda () (setq seed (+ seed 1))))
(defun rand () (init-rand 1))
(rand)

170
ase/cmd/lsp/t2.lsp Normal file
View File

@ -0,0 +1,170 @@
;(setq x (lambda (x) (+ x 20 30 40)))
(defun x(x) (+ x 20 30 40))
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 100)
(x 200)
(x 200)
(x 200)
(x 200)
(x 200)

8
ase/cmd/lsp/t3.lsp Normal file
View File

@ -0,0 +1,8 @@
; test while
(setq x 10)
(setq y 10)
(while (< x 100) (setq y (+ x y)) (setq x (+ x 1)))
x
y

7
ase/cmd/lsp/t4.lsp Normal file
View File

@ -0,0 +1,7 @@
;Compute the factorial of N.
(defun factorial (N)
(if (= N 1)
1
(* N (factorial (- N 1)))))
(factorial 10)

8
ase/cmd/lsp/t5.lsp Normal file
View File

@ -0,0 +1,8 @@
; Compute the N'th Fibonacci number.
(defun fibonacci (N)
;(if (or (zerop N) (= N 1))
(if (or (= N 0) (= N 1))
1
(+ (fibonacci (- N 1)) (fibonacci (- N 2)))))
(fibonacci 5)

9
ase/cmd/lsp/t6.lsp Normal file
View File

@ -0,0 +1,9 @@
(setq x '(a b c))
(setq y '(x y z))
(setcar x y)
(setcar y x)
x
y

4
ase/cmd/lsp/t7.lsp Normal file
View File

@ -0,0 +1,4 @@
(setq a '(1 2 3))
(cons a (cons a 10))
(setq xx (cons a (cons a 10)))