hafriedlander / php-peg

PEG (parsing expression grammar) compiler for PHP
Other
191 stars 53 forks source link

Escape single quotes #37

Open dgadmin opened 7 years ago

dgadmin commented 7 years ago

Hello!

Single quotes in a literal would cause the PEG to crash with:

PHP Parse error:  syntax error, unexpected '';' (T_ENCAPSED_AND_WHITESPACE), expecting ';'

This happens because the literal gets eval()ed to check if it's a single character.

This patch escapes the quotes, and the parser gets generated correctly.