bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PHP support


From: Tim Landscheidt
Subject: PHP support
Date: Sun, 30 Oct 2011 02:25:25 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi,

I hope this list is the right place for this.

  In the past few weeks, I started working on "%language
PHP". You can browse the code at
<URI:https://github.com/scfc/bison-php> (bison's "master" is
"upstream").

  I generated a Java parser, then manually converted it to
PHP and used the diff to find the macros that needed tweak-
ing. So I was (and still am) totally oblivious to the inner
workings of Bison - please forgive my ignorance.

  The code is far from mature, but it is able to generate a
small "calculator" (cf. examples/php/calc/calc.{y,php}) with
two exceptions (cf. examples/php/calc/calc-fixed.php):

1. Calc::__construct reads (b4_lex_param_call):

   |   public function __construct ($is)
   |   {

   |     $this->yylexer = new YYLexer(is);

   |   }

   But the second "is" should be a "$is". I tried some
   variants of "$$" and patsubst at different places, but
   unfortunately, m4's levels of quoting have always exceed-
   ed my imagination :-).

2. The $yytname_'s definition reads
   (b4_typed_parser_table_define):

   |   private $yytname_ = array(
   |   "$end", "error", "$undefined", "NUM", "'-'", "'+'", "'*'", "'/'", "'^'",
   |   "'\\n'", "'('", "')'", "$accept", "input", "line", "exp", null
   |     );

   The "$id"s have to be escaped either as "\$id" or "'$id'"
   (probably also an issue for Perl). In the current form,
   this is a syntax error for PHP.

Any help with those issues and all other comments and feed-
back are highly appreciated!

Thanks in advance,
Tim




reply via email to

[Prev in Thread] Current Thread [Next in Thread]