Skip to content

Commit 41d2431

Browse files
aatxevegorov-rbx
andauthored
Add a luau library with support for parsing. (#32)
* add infra for queijo luau library * initial cut of parsing expressions * added an example to test the expression parsing * clean up setupState a bit * add missing source files, i got got by the gitignore * clean up somewhat * partial statement support * the rest of statements * little fixups * AstName is 1 entry. Co-authored-by: vegorov-rbx <[email protected]> * move pretty print script to std * clean up pp a bit more * fix horrible formatting * rename tableRef to seen * oops * spaces, not tabs * more, ick * some serialization for function AST nodes * de-indent sorting function --------- Co-authored-by: vegorov-rbx <[email protected]>
1 parent f152df2 commit 41d2431

File tree

9 files changed

+1381
-8
lines changed

9 files changed

+1381
-8
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
/crash-*
1111
/default.prof*
1212
/fuzz-*
13-
/luau
14-
/luau-tests
15-
/luau-analyze
16-
/luau-compile
1713
__pycache__
1814
.cache
1915
.clangd

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ project(Queijo LANGUAGES CXX C)
99

1010
add_library(Queijo.Runtime STATIC)
1111
add_library(Queijo.Fs STATIC)
12+
add_library(Queijo.Luau STATIC)
1213
add_library(Queijo.Net STATIC)
1314
add_library(Queijo.Task STATIC)
1415

@@ -57,21 +58,25 @@ include(Sources.cmake)
5758

5859
target_compile_features(Queijo.Runtime PUBLIC cxx_std_17)
5960
target_compile_features(Queijo.Fs PUBLIC cxx_std_17)
61+
target_compile_features(Queijo.Luau PUBLIC cxx_std_17)
6062
target_compile_features(Queijo.Net PUBLIC cxx_std_17)
6163
target_compile_features(Queijo.Task PUBLIC cxx_std_17)
6264
target_include_directories(Queijo.Runtime PUBLIC runtime/include ${LIBUV_INCLUDE_DIR})
6365
target_include_directories(Queijo.Fs PUBLIC fs/include ${LIBUV_INCLUDE_DIR})
66+
target_include_directories(Queijo.Luau PUBLIC luau/include ${LIBUV_INCLUDE_DIR})
6467
target_include_directories(Queijo.Net PUBLIC net/include ${LIBUV_INCLUDE_DIR})
6568
target_include_directories(Queijo.Task PUBLIC task/include ${LIBUV_INCLUDE_DIR})
6669

6770
target_link_libraries(Queijo.Runtime PRIVATE Luau.VM uv_a)
6871
target_link_libraries(Queijo.Fs PRIVATE Queijo.Runtime Luau.VM uv_a)
72+
target_link_libraries(Queijo.Luau PRIVATE Queijo.Runtime Luau.VM uv_a Luau.Analysis Luau.Ast)
6973
target_link_libraries(Queijo.Net PRIVATE Queijo.Runtime Luau.VM uv_a ${WOLFSSL_LIBRARY} libcurl)
7074
target_link_libraries(Queijo.Task PRIVATE Queijo.Runtime Luau.VM uv_a)
71-
target_link_libraries(Queijo.CLI PRIVATE Luau.CLI.lib Luau.Compiler Luau.Config Luau.CodeGen Luau.Analysis Luau.VM Queijo.Runtime Queijo.Fs Queijo.Net Queijo.Task)
75+
target_link_libraries(Queijo.CLI PRIVATE Luau.CLI.lib Luau.Compiler Luau.Config Luau.CodeGen Luau.Analysis Luau.VM Queijo.Runtime Queijo.Fs Queijo.Luau Queijo.Net Queijo.Task)
7276

7377
target_compile_options(Queijo.Runtime PRIVATE ${QUEIJO_OPTIONS})
7478
target_compile_options(Queijo.Fs PRIVATE ${QUEIJO_OPTIONS})
79+
target_compile_options(Queijo.Luau PRIVATE ${QUEIJO_OPTIONS})
7580
target_compile_options(Queijo.Net PRIVATE ${QUEIJO_OPTIONS})
7681
target_compile_options(Queijo.Task PRIVATE ${QUEIJO_OPTIONS})
7782
target_compile_options(Queijo.CLI PRIVATE ${QUEIJO_OPTIONS})

Sources.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ target_sources(Queijo.Fs PRIVATE
1212
fs/src/fs.cpp
1313
)
1414

15+
target_sources(Queijo.Luau PRIVATE
16+
luau/include/queijo/luau.h
17+
18+
luau/src/luau.cpp
19+
)
20+
1521
target_sources(Queijo.Net PRIVATE
1622
net/include/queijo/net.h
1723

cli/queijo.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
#include "lua.h"
88
#include "lualib.h"
99

10-
#include "queijo/net.h"
1110
#include "queijo/fs.h"
11+
#include "queijo/net.h"
12+
#include "queijo/luau.h"
1213
#include "queijo/ref.h"
1314
#include "queijo/runtime.h"
1415

@@ -57,10 +58,13 @@ lua_State* setupState(Runtime& runtime)
5758
// register the builtin tables
5859
luaL_openlibs(L);
5960

61+
luaopen_fs(L);
62+
lua_pop(L, 1);
63+
6064
luaopen_net(L);
6165
lua_pop(L, 1);
6266

63-
luaopen_fs(L);
67+
luaopen_luau(L);
6468
lua_pop(L, 1);
6569

6670
static const luaL_Reg funcs[] = {

examples/parsing.luau

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
local pretty = require("@std/pp")
2+
local foo = luau.parseexpr("{} + 2")
3+
print(pretty(foo))

extern/luau/Ast/include/Luau/Parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class Parser
6262
ParseOptions options = ParseOptions()
6363
);
6464

65-
private:
65+
// FIXME(queijo): temporary change, we should expose a few more methods here ultimately
66+
//private:
6667
struct Name;
6768
struct Binding;
6869

luau/include/queijo/luau.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
struct lua_State;
4+
5+
int luaopen_luau(lua_State* L);

0 commit comments

Comments
 (0)