src/codegen/Api.php
static function generateParserFromGrammar(
        string $grammarFilePath,
        string $parserName="MyParser",
        string $namespace="",
        Output $output=null,
        string $pathToHeaderComment="")
    {
        $parser = new MetaGrammarParser();

        $ast = !empty($grammarFilePath) ?
            $parser->parseFile($grammarFilePath) :
            $parser->parseStdin();

        if ($ast !== false) {

            $generator = new CodeGenerator($parserName, $namespace);
            $generator->setHeaderCommentFile($pathToHeaderComment);
            $generator->generate($ast, $output);

            return [true, ""];

        } else {

            return [false, $parser->error()];

        }
    }
static function generateParserFromGrammar(
        string $grammarFilePath,
        string $parserName="MyParser",
        string $namespace="",
        Output $output=null,
        string $pathToHeaderComment="")
    {
        $parser = new MetaGrammarParser();

        $ast = !empty($grammarFilePath) ?
            $parser->parseFile($grammarFilePath) :
            $parser->parseStdin();

        if ($ast !== false) {

            $generator = new CodeGenerator($parserName, $namespace);
            $generator->setHeaderCommentFile($pathToHeaderComment);
            $generator->generate($ast, $output);

            return [true, ""];

        } else {

            return [false, $parser->error()];

        }
    }
Generate a parser from a grammar definition

@param string $grammarFilePath path of grammar file
@param string $parserName name of parser class
@param string $namespace namespace of parser class
@param Output $output output to be written to
@param string $pathToHeaderComment path to file that contains header comment
@return mixed[] [true, ""] in case of success, [false, <error_message>] in error cases