Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Segmentation fault executeing cli.php #23

Open
xa72 opened this issue Jan 24, 2013 · 2 comments
Open

PHP Segmentation fault executeing cli.php #23

xa72 opened this issue Jan 24, 2013 · 2 comments

Comments

@xa72
Copy link

xa72 commented Jan 24, 2013

Hi, I got a php5-Segmentation fault when I run cli.php with the BooleanParser.peg.inc_new (https://gist.github.com/4623645), with BooleanParser.peg.inc (https://gist.github.com/4623616) everything works. Any Idea what this may be? The difference is really small and I'm unsure, if this is due to a wrong Syntax or a PHP-Error.
Any help apreciated...

@MiguelDomingues
Copy link

I belive that the problem is related to the regex expression used to create the parser.
I found a workaround by using the substr functions.
In the following answer from stackoverflow there are some hints that might help: http://stackoverflow.com/a/7627962/4503525

I've come up with the following code (it's not pretty but it is working):

$syntax = file_get_contents('syntax.peg');

$parser = substr($syntax, strpos($syntax, '/*!*'));
$parser = substr($parser, 0, strpos($parser, '*/'));

$lenMatch = strlen($parser)+2;

$parserName = substr($parser, 5, strpos($parser, "\n"));

$parser = substr($parser, strpos($parser, "\n")+1);

$res = hafriedlander\Peg\Compiler::create_parser(array(
        1=> '', // Here should be the indentation, make sure you do not have any indentation before /*!*
        2=> $parserName,
        3=> $parser,
    ));

$start = substr($syntax, 0, strpos($syntax, '/*!*'));
$end   = substr($syntax, strlen($start)+$lenMatch);

$res  = $start.$res.$end;

file_put_contents($parserName.".php", $res);

@gysi
Copy link

gysi commented Jun 11, 2015

@MiguelDomingues thank you very much! worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants