Add LPeg 0.10

0.11 has a bug that makes it crash on MoonScript, and 0.12 is much slower.

LPeg isn't packaged as a C library and consists of a whopping two files
so just compile it as part of Aegisub.
This commit is contained in:
Thomas Goyne 2013-04-29 20:37:47 -07:00
parent 34be32d570
commit 99d74e18b3
6 changed files with 2456 additions and 3 deletions

View file

@ -200,6 +200,7 @@
<ClInclude Include="$(SrcDir)include\aegisub\video_provider.h" />
<ClInclude Include="$(SrcDir)initial_line_state.h" />
<ClInclude Include="$(SrcDir)kana_table.h" />
<ClInclude Include="$(SrcDir)lpeg.h" />
<ClInclude Include="$(SrcDir)main.h" />
<ClInclude Include="$(SrcDir)mkv_wrap.h" />
<ClInclude Include="$(SrcDir)options.h" />
@ -394,6 +395,10 @@
<ClCompile Include="$(SrcDir)hotkey_data_view_model.cpp" />
<ClCompile Include="$(SrcDir)initial_line_state.cpp" />
<ClCompile Include="$(SrcDir)kana_table.cpp" />
<ClCompile Include="$(SrcDir)lpeg.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<ForcedIncludeFiles></ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="$(SrcDir)main.cpp" />
<ClCompile Include="$(SrcDir)menu.cpp" />
<ClCompile Include="$(SrcDir)mkv_wrap.cpp" />

View file

@ -690,6 +690,9 @@
<ClInclude Include="$(SrcDir)auto4_lua_utils.h">
<Filter>Automation\Lua</Filter>
</ClInclude>
<ClInclude Include="$(SrcDir)lpeg.h">
<Filter>Automation\Lua</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SrcDir)ass_dialogue.cpp">
@ -1241,6 +1244,9 @@
<ClCompile Include="$(SrcDir)auto4_regex.cpp">
<Filter>Automation\Lua</Filter>
</ClCompile>
<ClCompile Include="$(SrcDir)lpeg.c">
<Filter>Automation\Lua</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="$(SrcDir)res.rc">

View file

@ -200,6 +200,7 @@ SRC += \
hotkey_data_view_model.cpp \
initial_line_state.cpp \
kana_table.cpp \
lpeg.c \
main.cpp \
menu.cpp \
mkv_wrap.cpp \

View file

@ -193,6 +193,8 @@ namespace {
}
}
extern "C" int luaopen_lpeg (lua_State *L);
namespace Automation4 {
int regex_init(lua_State *L);
@ -220,12 +222,13 @@ namespace Automation4 {
// register standard libs
push_value(L, luaopen_base); lua_call(L, 0, 0);
push_value(L, luaopen_io); lua_call(L, 0, 0);
push_value(L, luaopen_lpeg); lua_call(L, 0, 0);
push_value(L, luaopen_math); lua_call(L, 0, 0);
push_value(L, luaopen_os); lua_call(L, 0, 0);
push_value(L, luaopen_package); lua_call(L, 0, 0);
push_value(L, luaopen_string); lua_call(L, 0, 0);
push_value(L, luaopen_table); lua_call(L, 0, 0);
push_value(L, luaopen_math); lua_call(L, 0, 0);
push_value(L, luaopen_io); lua_call(L, 0, 0);
push_value(L, luaopen_os); lua_call(L, 0, 0);
_stackcheck.check_stack(0);
// dofile and loadfile are replaced with include

2400
aegisub/src/lpeg.c Normal file

File diff suppressed because it is too large Load diff

38
aegisub/src/lpeg.h Normal file
View file

@ -0,0 +1,38 @@
/*
** $Id: lpeg.h,v 1.1 2009/12/23 16:15:36 roberto Exp $
** LPeg - PEG pattern matching for Lua
** Copyright 2009, Lua.org & PUC-Rio (see 'lpeg.html' for license)
** written by Roberto Ierusalimschy
*/
#ifndef lpeg_h
#define lpeg_h
#include "lua.h"
#define KEYNEWPATT "lpeg.newpf"
/*
** type of extension functions that define new "patterns" for LPEG
** It should return the new current position or NULL if match fails
*/
typedef const char *(*PattFunc) (const char *s, /* current position */
const char *e, /* string end */
const char *o, /* string start */
const void *ud); /* user data */
/*
** function to create new patterns based on 'PattFunc' functions.
** This function is available at *registry[KEYNEWPATT]. (Notice
** the extra indirection; the userdata at the registry points to
** a variable that points to the function. In ANSI C a void* cannot
** point to a function.)
*/
typedef void (*Newpf) (lua_State *L,
PattFunc f, /* pattern */
const void *ud, /* (user) data to be passed to 'f' */
size_t l); /* size of data to be passed to 'f' */
#endif