Module fusion.core.parsers.source

Compile FusionScript AST to Lua code

Functions

parser:new () Initialize a parser state
parser:transform (node) Transform a node using the registered handler.
parser:l (line) Add indent to a line of text.
parser:transform_expression_list (node) Convert an expression_list field to a transformed list of expressions.
parser:transform_variable_list (node) Convert a variable_list to a transformed list of variable names.
parser:transform_class_function (node) Convert a function field in a class to a lambda table assignment.
parser.compile (in_values, output_stream) Convert an iterator returning FusionScript chunks to Lua code.
parser.read_file (file) Read FusionScript code from a file and return output.
parser.load_file (file) Load FusionScript code from a file and return a function to run the code.
parser.do_file (file) Load and run FusionScript code from a file
parser.search_for (module_name) Find a module in the package path and return relevant information.
parser.inject_loader () Inject parser.search_for into the require() searchers list.


Functions

parser:new ()
Initialize a parser state
parser:transform (node)
Transform a node using the registered handler.

Parameters:

parser:l (line)
Add indent to a line of text.

Parameters:

parser:transform_expression_list (node)
Convert an expression_list field to a transformed list of expressions.

Parameters:

parser:transform_variable_list (node)
Convert a variable_list to a transformed list of variable names.

Parameters:

parser:transform_class_function (node)
Convert a function field in a class to a lambda table assignment.

Parameters:

parser.compile (in_values, output_stream)
Convert an iterator returning FusionScript chunks to Lua code. Do not use this function directly to compile code.

Parameters:

  • in_values table Table of values to compile
  • output_stream function Repeatedly called with generated code
parser.read_file (file)
Read FusionScript code from a file and return output.

Parameters:

  • file string File to read input from

Returns:

    string Lua code
parser.load_file (file)
Load FusionScript code from a file and return a function to run the code.

Parameters:

Returns:

    function Loaded FusionScript code
parser.do_file (file)
Load and run FusionScript code from a file

Parameters:

parser.search_for (module_name)
Find a module in the package path and return relevant information. Returns nil and an error message if not found. Do not use this function by itself; use parser.inject_loader().

Parameters:

Returns:

  1. function Closure to return loaded module
  2. string Path to loaded file
parser.inject_loader ()
Inject parser.search_for into the require() searchers list.

Returns:

    boolean False if loader already found

Usage:

    parser.inject_loader(); print(require("test_module"))
     -- Attempts to load a FusionScript test_module package
generated by LDoc 1.4.6 Last updated 2016-12-25 00:12:26