# [ANNOUNCE] Scanner to be based on re2c

- Thread: https://externals.io/message/36151
- Original archive: https://news-web.php.net/php.internals/36151
- Started by Marcus Boerger on 2008-03-16T21:29:35+00:00
- Messages: 14
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #36151 — Marcus Boerger — 2008-03-16T21:29:35+00:00

URL: https://externals.io/message/36151#36151

Hello Internals,

  as of today PHP 5.3 uses a scanner based on re2c >= 0.13.3 (latest dev
version) instead of the outdated flex version we required so far. This in
particular means:

a) You need to get re2c 0.13.3 - when working on the language/ini scanner

b) You no longer need flex to build PHP 5.3

c) HEAD does not yet use re2c,  this will be done withint the next days

d) ATM --enable-zend-multibyte is not supported - We will add the
   functionality without the need for the switch within the next weeks

e) You need to run ./buildconf next time you do a cvs checkout of PHP_5_3

In case you are interested at a full patch:
http://php.net/~helly/php-re2c-5.3-20080316.diff.txt

In case you like to get more involved:
http://blog.somabo.de/2008/02/php-on-re2c.html

Care to help?

Write tests that use --enable-zend-multibyte or define how multibyte
support should work.

Best regards,
 Marcus, Scott, Nuno

---

## #36157 — Edward Z. Yang — 2008-03-16T22:25:34+00:00

URL: https://externals.io/message/36151#36157 · In reply to: #36151

Here is a patch that appears to fix the Windows build:
http://www.thewritingpot.com/patches/php-re2c-windows.patch
I made re2c required; if pre-generated files are supplied, however, we
might be able to get away without it.

I also had to download re2c binaries from
http://sourceforge.net/project/showfiles.php?group_id=96864 and put them
in my path. Whoever's maintaining zip.zip will want to update it.

It appears Visual C++ 2005 Express does not support gotos to variable
labels (it does support vanilla gotos out of the box, however). So I
didn't bother porting the goto check code. Someone might want to do that
later if we start supporting other compilers.

Zend-related source files appear to have compiled successfully; re2c
didn't give any output and exited with error code 0 (I assume it worked).

-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]

---

## #36159 — Edward Z. Yang — 2008-03-16T22:29:46+00:00

URL: https://externals.io/message/36151#36159 · In reply to: #36157

Edward Z. Yang wrote:
> Here is a patch [snip]

Marcus beat me to it. :-)

-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]

---

## #36160 — Marcus Boerger — 2008-03-16T22:35:03+00:00

URL: https://externals.io/message/36151#36160 · In reply to: #36157

Hello Edward,

Sunday, March 16, 2008, 11:25:34 PM, you wrote:

> Here is a patch that appears to fix the Windows build:
> http://www.thewritingpot.com/patches/php-re2c-windows.patch
> I made re2c required; if pre-generated files are supplied, however, we
> might be able to get away without it.

I think we need to have the windows build maintainers decide how they would
like to handle this. One thing we haven't decided on is how to deal with
checkin of re2c generated files. In fact we need them to be done without -g
flag. So when someone commots who has -g detection on, he must regenerate
the file without that. Another option is to always generate both versions
and then select the correc one form the build system.

> I also had to download re2c binaries from
> http://sourceforge.net/project/showfiles.php?group_id=96864 and put them
> in my path. Whoever's maintaining zip.zip will want to update it.

> It appears Visual C++ 2005 Express does not support gotos to variable
> labels (it does support vanilla gotos out of the box, however). So I
> didn't bother porting the goto check code. Someone might want to do that
> later if we start supporting other compilers.

> Zend-related source files appear to have compiled successfully; re2c
> didn't give any output and exited with error code 0 (I assume it worked).

Sounds right. Re2c does not output anything besides the generated files,
when successfull.


Best regards,
 Marcus

---

## #36161 — Edward Z. Yang — 2008-03-17T00:17:53+00:00

URL: https://externals.io/message/36151#36161 · In reply to: #36160

Marcus Boerger wrote:
> Another option is to always generate both versions
> and then select the correc one form the build system.

+1

-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]

---

## #36169 — Stanislav Malyshev — 2008-03-17T16:46:02+00:00

URL: https://externals.io/message/36151#36169 · In reply to: #36151

Hi!

Windows build is broken right now. When trying to build, I get:


\cygwin\bin\bison.exe --output=Zend/zend_ini_parser.c -v -d -p ini_ 
Zend/zend_ini_parser.y
"\cygwin\bin\re2c.exe" "" --case-inverted -cbdFt 
Zend\zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c 
Zend\zend_ini_scanner.l
usage: re2c [-bcdDefFghisvVw1] [-o file] file

-? -h  --help           Display this info.
etc. all the help of re2c
NMAKE : fatal error U1077: '\cygwin\bin\re2c.exe' : return code '0x2'
Stop.

This seems to be because of RE2C_FLAGS defined as "". If I set this 
definition as empty, another error happens:

"\cygwin\bin\re2c.exe"  --case-inverted -cbdFt 
Zend\zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c 
Zend\zend_ini_scanner.l
         "\cygwin\bin\re2c.exe"  --case-inverted -cbdFt 
/zend_language_scanner_defs.h -oZend\zend_language_scanner.c 
/zend_language_scanner.l
re2c: error: cannot open /zend_language_scanner.l
NMAKE : fatal error U1077: '\cygwin\bin\re2c.exe' : return code '0x1'
Stop.

Please fix both.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36170 — Scott MacVicar — 2008-03-17T17:08:24+00:00

URL: https://externals.io/message/36151#36170 · In reply to: #36169

It should be fixed now.

Scott

Stanislav Malyshev wrote:
> Hi!
> 
> Windows build is broken right now. When trying to build, I get:
> 
> 
> \cygwin\bin\bison.exe --output=Zend/zend_ini_parser.c -v -d -p ini_ 
> Zend/zend_ini_parser.y
> "\cygwin\bin\re2c.exe" "" --case-inverted -cbdFt 
> Zend\zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c 
> Zend\zend_ini_scanner.l
> usage: re2c [-bcdDefFghisvVw1] [-o file] file
> 
> -? -h  --help           Display this info.
> etc. all the help of re2c
> NMAKE : fatal error U1077: '\cygwin\bin\re2c.exe' : return code '0x2'
> Stop.
> 
> This seems to be because of RE2C_FLAGS defined as "". If I set this 
> definition as empty, another error happens:
> 
> "\cygwin\bin\re2c.exe"  --case-inverted -cbdFt 
> Zend\zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c 
> Zend\zend_ini_scanner.l
>         "\cygwin\bin\re2c.exe"  --case-inverted -cbdFt 
> /zend_language_scanner_defs.h -oZend\zend_language_scanner.c 
> /zend_language_scanner.l
> re2c: error: cannot open /zend_language_scanner.l
> NMAKE : fatal error U1077: '\cygwin\bin\re2c.exe' : return code '0x1'
> Stop.
> 
> Please fix both.

---

## #36171 — Stanislav Malyshev — 2008-03-17T17:11:57+00:00

URL: https://externals.io/message/36151#36171 · In reply to: #36170

> It should be fixed now.

First issue is still there (now it does RE2CFLAGS=null) but the second 
one is gone.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36174 — Steph Fox — 2008-03-17T17:17:32+00:00

URL: https://externals.io/message/36151#36174 · In reply to: #36170

Interesting. I did a clean checkout when Stas' message came through and 
can't reproduce the problem here.

Stas, is yours a cygwin-reliant exe?

- Steph

> It should be fixed now.
>
> Scott
>
> Stanislav Malyshev wrote:
> > […]

---

## #36176 — Stanislav Malyshev — 2008-03-17T17:21:32+00:00

URL: https://externals.io/message/36151#36176 · In reply to: #36174

> Interesting. I did a clean checkout when Stas' message came through and 
> can't reproduce the problem here.
> 
> Stas, is yours a cygwin-reliant exe?

Erm, not sure what you mean here. I downloaded re2c.exe from sourceforge 
release, did checkput of 5.3, buildconf and configure. Since configure 
now produces RE2C_FLAGS=null in makefile, build failed. After removing 
that line, build worked.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36179 — Steph Fox — 2008-03-17T17:28:57+00:00

URL: https://externals.io/message/36151#36179 · In reply to: #36176

> > […]
> 
> Erm, not sure what you mean here.

I meant 'does it rely on cygwin1.dll or is it native'?

> I downloaded re2c.exe from sourceforge 
> release, did checkput of 5.3, buildconf and configure. Since configure 
> now produces RE2C_FLAGS=null in makefile, build failed. After removing 
> that line, build worked.

Mine worked from scratch... I'm not sure which is weirder :)

- Steph

---

## #36180 — Stanislav Malyshev — 2008-03-17T17:34:09+00:00

URL: https://externals.io/message/36151#36180 · In reply to: #36179

> I meant 'does it rely on cygwin1.dll or is it native'?

No idea, whatever the person who put it on sourceforge built.

> > […]
> 
> Mine worked from scratch... I'm not sure which is weirder :)

Nevermind, I fixed it.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36181 — Steph Fox — 2008-03-17T17:40:20+00:00

URL: https://externals.io/message/36151#36181 · In reply to: #36180

Hi Stas,


> > […]
>
> No idea, whatever the person who put it on sourceforge built.

If people are distributing binaries that rely on the cygwin runtime they 
usually say something about it somewhere, so I'll assume not in in this 
case. I just asked because the path was listed as C:\cygwin\bin\re2c.exe in 
your original post.
>
> > […]
>
> Nevermind, I fixed it.

yes... but given that mine worked in the first place, the question is 
whether your (and Scott's) fixes will work here, which means I now need to 
check out 5_3 and try again. Sorry, it's going to have to be after I finish 
work for the day, taken up too much time already.

- Steph

---

## #36183 — Steph Fox — 2008-03-17T22:39:44+00:00

URL: https://externals.io/message/36151#36183 · In reply to: #36181

> > […]
>
> yes... but given that mine worked in the first place, the question is 
> whether your (and Scott's) fixes will work here, which means I now need to 
> check out 5_3 and try again. Sorry, it's going to have to be after I 
> finish work for the day, taken up too much time already.

*talking to myself... again*

Just confirming that the build still appears to work fine on my box 
following today's changes (i.e. re2c generates files that are not empty, the 
resulting PHP binary returns version info on request etc etc).

So you didn't break it :)

- Steph
