@friday-friday/luast-util-from-luaparse
v0.3.0
Published
Convert legacy luaparse AST to luast format
Maintainers
Readme
luast-util-from-luaparse
Convert legacy luaparse AST to luast format.
What is this?
This package converts the PascalCase AST emitted by luaparse's legacy mode
(e.g. Chunk, LocalStatement, Identifier) into the camelCase,
unist-compliant luast format (e.g. root, localStatement,
identifier). It also converts position data to the unist position format
(1-indexed columns).
Install
npm install @friday-friday/luast-util-from-luaparseUse
import luaparse from '@friday-friday/luaparse'
import {fromLuaparse} from '@friday-friday/luast-util-from-luaparse'
// Parse in legacy mode
const legacy = luaparse.parse('local x = 1', {
locations: true,
ranges: true
})
// Convert to luast
const tree = fromLuaparse(legacy)
// tree.type === 'root'
// tree.body[0].type === 'localStatement'API
fromLuaparse(legacy)
Convert a legacy luaparse AST node (typically a Chunk) into a luast Root.
Parameters:
legacy— the legacy AST object fromluaparse.parse()
Returns: a luast Root node
Related
@friday-friday/luast— tree specification and types@friday-friday/luast-util-visit— tree visitor@friday-friday/luaparse— Lua parser
