diff --git a/lib/hafriedlander/Peg/Compiler/Token/Literal.php b/lib/hafriedlander/Peg/Compiler/Token/Literal.php index c97a60a..101be06 100644 --- a/lib/hafriedlander/Peg/Compiler/Token/Literal.php +++ b/lib/hafriedlander/Peg/Compiler/Token/Literal.php @@ -6,7 +6,9 @@ class Literal extends Expressionable { function __construct( $value ) { - parent::__construct( 'literal', "'" . substr($value,1,-1) . "'" ); + // escape single quotes + $escaped_value = str_replace('\'', '\\\'', substr($value,1,-1)); + parent::__construct( 'literal', "'" . $escaped_value . "'" ); } function match_code( $value ) {