stevenjohnstone / lua-grammar

ANTLRv4 lexer and parser grammars for Lua
1 stars 0 forks source link

ANTLRv4 Lua parser and lexer grammars

Modified https://github.com/antlr/grammars-v4/tree/master/lua:

Usage

As for other ANTLRv4 grammars:

antlr4 LuaLexer.g4 LuaParser.g4

Railroad Diagrams

See the grammar in the form of railroad diagrams here.

Examples

Generating a Callgraph

The following is a callgraph for inspect.lua:

callgraph.

On Linux with clang, graphviz and antlr4 installed:

cd examples/cpp/dot
make

Then

 wget -q https://raw.githubusercontent.com/kikito/inspect.lua/master/inspect.lua -O -|./callgraph |dot -T png -o inspect.png

Dependency graph

The following is an attempt at a dependency graph for Luarocks, as installed on my system:

dependency

On Linux with clang, graphviz and antlr4 installed:

cd examples/cpp/deps
make

Then

./deps /usr/bin/luarocks | neato -T png -o deps.png