Example #1
0
function parse_lime_grammar($path)
{
    /*
    This is a good function to read because it teaches you how to interface
    	with a Lime parser. I've tried to isolate out the bits that aren't
    	instructive in that regard.
    */
    if (!class_exists('lime_metaparser')) {
        lime_bootstrap();
    }
    $parse_engine = new parse_engine(new lime_metaparser());
    $scanner = new voodoo_scanner($path);
    try {
        # The result of parsing a Lime grammar is a Lime object.
        $lime = $scanner->feed($parse_engine);
        # Calling its build_parser() method gets the output PHP code.
        return $lime->build_parser();
    } catch (parse_error $e) {
        die($e->getMessage() . " in {$path} line {$scanner->lineno}.\n");
    }
}
Example #2
0
/**
 * This is a good function to read because it teaches you how to interface
 * with a Lime parser. I've tried to isolate out the bits that aren't
 * instructive in that regard.
 */
function parse_lime_grammar($path)
{
    if (!class_exists('lime_metaparser', false)) {
        lime_bootstrap();
    }
    $parse_engine = new parse_engine(new lime_metaparser());
    $scanner = new voodoo_scanner($path);
    try {
        // The result of parsing a Lime grammar is a Lime object.
        $lime = $scanner->feed($parse_engine);
        // Calling its build_parser() method gets the output PHP code.
        return $lime->build_parser();
    } catch (parse_error $e) {
        die($e->getMessage() . " in {$path} line {$scanner->lineno}." . PHP_EOL);
    }
}