Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lpeg an optional dependency #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/LuLPeg"]
path = thirdparty/LuLPeg
url = https://github.com/pygy/LuLPeg
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ interfaces, and modules.
# Requirements for running the compiler

lua >= 5.1

## Optional Requirements

lpeg >= 0.12

If lpeg is not found via `require "lpeg"`, then [LuLPeg](https://github.com/pygy/LuLPeg) will be used instead.

# Usage

$ tlc [options] [filename]
Expand All @@ -23,6 +28,10 @@ interfaces, and modules.
-p print the AST
-v print current version

# Checkout

git clone --recursive https://github.com/andremm/typedlua

# License

Released under the MIT License (MIT)
Expand Down
1 change: 1 addition & 0 deletions thirdparty/LuLPeg
Submodule LuLPeg added at c457b2
3 changes: 2 additions & 1 deletion typedlua/tllexer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This module implements Typed Lua lexer

local tllexer = {}

local lpeg = require "lpeg"
local success, lpeg = pcall(require, "lpeg")
lpeg = success and lpeg or require "thirdparty/lulpeg/lulpeg":register(not _ENV and _G)
lpeg.locale(lpeg)

local function getffp (s, i, t)
Expand Down
3 changes: 2 additions & 1 deletion typedlua/tlparser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This module implements Typed Lua parser

local tlparser = {}

local lpeg = require "lpeg"
local success, lpeg = pcall(require, "lpeg")
lpeg = success and lpeg or require "thirdparty/lulpeg/lulpeg":register(not _ENV and _G)
lpeg.locale(lpeg)

local tlast = require "typedlua.tlast"
Expand Down