xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

String parsing of escapes broken #41

Closed thekid closed 6 years ago

thekid commented 6 years ago
$ cat escape.php
<?php

print('\\\'');

# Executes in PHP
$ cat escape.php | xp -e
\'

# But doesn't in XP compiler:
$ xp compile escape.php
<?php Uncaught exception: Exception lang.FormatException (Unclosed string literal starting at line 3)
  at lang.ast.Tokens::getIterator() [line 0 of StackTraceElement.class.php]
  at Generator::next() [line 1411 of Parse.class.php]
  at lang.ast.Parse::advance() [line 1277 of Parse.class.php]
  at lang.ast.Parse::expression(0) [line 1307 of Parse.class.php]
  at lang.ast.Parse::statement() [line 1286 of Parse.class.php]
  at lang.ast.Parse::top() [line 796 of Emitter.class.php]
  at lang.ast.Emitter::emit(Generator{}) [line 79 of CompileRunner.class.php]
  at xp.compiler.CompileRunner::main(array[1]) [line 374 of class-main.php]
thekid commented 6 years ago

With this fix, the compiler can now compile itself!

image