parent
d4f114adcc
commit
dc6adca82f
5 changed files with 317 additions and 99 deletions
@ -0,0 +1,92 @@ |
||||
# Microsoft Developer Studio Project File - Name="stb" - Package Owner=<4> |
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00 |
||||
# ** DO NOT EDIT ** |
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103 |
||||
|
||||
CFG=stb - 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 "stb.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 "stb.mak" CFG="stb - Win32 Debug" |
||||
!MESSAGE |
||||
!MESSAGE Possible choices for configuration are: |
||||
!MESSAGE |
||||
!MESSAGE "stb - Win32 Release" (based on "Win32 (x86) Console Application") |
||||
!MESSAGE "stb - 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)" == "stb - 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" |
||||
# 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 /G6 /MT /W3 /GX /Z7 /O2 /Ob2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /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 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 |
||||
|
||||
!ELSEIF "$(CFG)" == "stb - 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" |
||||
# 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 "_MBCS" /FR /FD /GZ /c |
||||
# SUBTRACT CPP /YX |
||||
# 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 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 /incremental:no /debug /machine:I386 /pdbtype:sept |
||||
# SUBTRACT LINK32 /force |
||||
|
||||
!ENDIF |
||||
|
||||
# Begin Target |
||||
|
||||
# Name "stb - Win32 Release" |
||||
# Name "stb - Win32 Debug" |
||||
# Begin Source File |
||||
|
||||
SOURCE=.\stb.c |
||||
# End Source File |
||||
# End Target |
||||
# End Project |
@ -0,0 +1,44 @@ |
||||
Microsoft Developer Studio Workspace File, Format Version 6.00 |
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! |
||||
|
||||
############################################################################### |
||||
|
||||
Project: "stb"=.\stb.dsp - Package Owner=<4> |
||||
|
||||
Package=<5> |
||||
{{{ |
||||
}}} |
||||
|
||||
Package=<4> |
||||
{{{ |
||||
Begin Project Dependency |
||||
Project_Dep_Name stb_cpp |
||||
End Project Dependency |
||||
}}} |
||||
|
||||
############################################################################### |
||||
|
||||
Project: "stb_cpp"=.\stb_cpp.dsp - Package Owner=<4> |
||||
|
||||
Package=<5> |
||||
{{{ |
||||
}}} |
||||
|
||||
Package=<4> |
||||
{{{ |
||||
}}} |
||||
|
||||
############################################################################### |
||||
|
||||
Global: |
||||
|
||||
Package=<5> |
||||
{{{ |
||||
}}} |
||||
|
||||
Package=<3> |
||||
{{{ |
||||
}}} |
||||
|
||||
############################################################################### |
||||
|
@ -0,0 +1,83 @@ |
||||
#define WIN32_MEAN_AND_LEAN |
||||
#define WIN32_LEAN_AND_MEAN |
||||
//#include <windows.h>
|
||||
#include <conio.h> |
||||
#define STB_STUA |
||||
#define STB_DEFINE |
||||
#define STB_NPTR |
||||
#define STB_ONLY |
||||
#include "stb.h" |
||||
//#include "stb_file.h"
|
||||
|
||||
int count; |
||||
void c(int truth, char *error) |
||||
{ |
||||
if (!truth) { |
||||
fprintf(stderr, "Test failed: %s\n", error); |
||||
++count; |
||||
} |
||||
} |
||||
|
||||
char *expects(stb_matcher *m, char *s, int result, int len, char *str) |
||||
{ |
||||
int res2,len2=0; |
||||
res2 = stb_lex(m, s, &len2); |
||||
c(result == res2 && len == len2, str); |
||||
return s + len; |
||||
} |
||||
|
||||
void test_lex(void) |
||||
{ |
||||
stb_matcher *m = stb_lex_matcher(); |
||||
// tok_en5 .3 20.1 20. .20 .1
|
||||
char *s = "tok_en5.3 20.1 20. .20.1"; |
||||
|
||||
stb_lex_item(m, "[a-zA-Z_][a-zA-Z0-9_]*", 1 ); |
||||
stb_lex_item(m, "[0-9]*\\.?[0-9]*" , 2 ); |
||||
stb_lex_item(m, "[\r\n\t ]+" , 3 ); |
||||
stb_lex_item(m, "." , -99 ); |
||||
s=expects(m,s,1,7, "stb_lex 1"); |
||||
s=expects(m,s,2,2, "stb_lex 2"); |
||||
s=expects(m,s,3,1, "stb_lex 3"); |
||||
s=expects(m,s,2,4, "stb_lex 4"); |
||||
s=expects(m,s,3,1, "stb_lex 5"); |
||||
s=expects(m,s,2,3, "stb_lex 6"); |
||||
s=expects(m,s,3,1, "stb_lex 7"); |
||||
s=expects(m,s,2,3, "stb_lex 8"); |
||||
s=expects(m,s,2,2, "stb_lex 9"); |
||||
s=expects(m,s,0,0, "stb_lex 10"); |
||||
stb_matcher_free(m); |
||||
} |
||||
|
||||
int main(int argc, char **argv) |
||||
{ |
||||
char *p; |
||||
p = "abcdefghijklmnopqrstuvwxyz"; |
||||
c(stb_ischar('c', p), "stb_ischar 1"); |
||||
c(stb_ischar('x', p), "stb_ischar 2"); |
||||
c(!stb_ischar('#', p), "stb_ischar 3"); |
||||
c(!stb_ischar('X', p), "stb_ischar 4"); |
||||
p = "0123456789"; |
||||
c(!stb_ischar('c', p), "stb_ischar 5"); |
||||
c(!stb_ischar('x', p), "stb_ischar 6"); |
||||
c(!stb_ischar('#', p), "stb_ischar 7"); |
||||
c(!stb_ischar('X', p), "stb_ischar 8"); |
||||
p = "#####"; |
||||
c(!stb_ischar('c', p), "stb_ischar a"); |
||||
c(!stb_ischar('x', p), "stb_ischar b"); |
||||
c(stb_ischar('#', p), "stb_ischar c"); |
||||
c(!stb_ischar('X', p), "stb_ischar d"); |
||||
p = "xXyY"; |
||||
c(!stb_ischar('c', p), "stb_ischar e"); |
||||
c(stb_ischar('x', p), "stb_ischar f"); |
||||
c(!stb_ischar('#', p), "stb_ischar g"); |
||||
c(stb_ischar('X', p), "stb_ischar h"); |
||||
|
||||
test_lex(); |
||||
|
||||
if (count) { |
||||
_getch(); |
||||
} |
||||
return 0; |
||||
} |
||||
|
@ -0,0 +1,88 @@ |
||||
# Microsoft Developer Studio Project File - Name="stb_cpp" - Package Owner=<4> |
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00 |
||||
# ** DO NOT EDIT ** |
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103 |
||||
|
||||
CFG=stb_cpp - 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 "stb_cpp.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 "stb_cpp.mak" CFG="stb_cpp - Win32 Debug" |
||||
!MESSAGE |
||||
!MESSAGE Possible choices for configuration are: |
||||
!MESSAGE |
||||
!MESSAGE "stb_cpp - Win32 Release" (based on "Win32 (x86) Console Application") |
||||
!MESSAGE "stb_cpp - 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)" == "stb_cpp - 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" |
||||
# PROP Intermediate_Dir "Release" |
||||
# PROP Target_Dir "" |
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c |
||||
# ADD CPP /nologo /W3 /GX /O2 /I ".." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /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 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 |
||||
|
||||
!ELSEIF "$(CFG)" == "stb_cpp - 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" |
||||
# PROP Intermediate_Dir "Debug" |
||||
# 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 "_MBCS" /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 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 |
||||
|
||||
!ENDIF |
||||
|
||||
# Begin Target |
||||
|
||||
# Name "stb_cpp - Win32 Release" |
||||
# Name "stb_cpp - Win32 Debug" |
||||
# Begin Source File |
||||
|
||||
SOURCE=.\stb_cpp.cpp |
||||
# End Source File |
||||
# End Target |
||||
# End Project |
Loading…
Reference in New Issue