-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaAst.lua
More file actions
23 lines (21 loc) · 898 Bytes
/
Copy pathLuaAst.lua
File metadata and controls
23 lines (21 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local Lexer = require("Lexer")
local Parser = require("Parser")
--- A facade for tokenizing input text and parsing it into an AST.
--- @param input string The input text to parse.
--- @param tokens { [integer]: string, [string]: true | fun(self): string } The tokens to use for parsing.
--- @param topLevel Parsable The top-level parser to use. This should ideally consume the entire input, including the ending eof token.
local function parse(input, tokens, topLevel)
local lexer = Lexer:new(tokens)
local parser = Parser:new(lexer:lex(input))
return parser:accept(topLevel)
end
return {
parse = parse,
tokenCombinators = require("tokenCombinators"),
charCombinators = require("charCombinators"),
charSets = require("charSets"),
Ast = require("Ast"),
Deferred = require("Deferred"),
expression = require("expression"),
literal = require("literal"),
}