Page MenuHomePhabricator

XHPAST no longer parses heredocs and can't build on OS X (Bison 2.3)
Closed, ResolvedPublic

Description

xhpast can't parse HEREDOC after rPHU610ca9eb. See that commit for some discussion. Repro is:

  • Check out that commit.
  • Rebuild xhpast.
  • Run arc unit --everything.

The commit itself failed to build. I've reverted it in rPHU645da2b1.

The fix is likely straightforward, but I can't build xhpast locally on OSX anymore to verify it. I'm using the stock version of flex/bison which are distributed with XCode.

$ bison --version
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

First issue is that this version of bison does not support -Wall:

epriestley@orbital ~/dev/libphutil/support/xhpast $ make cleanall
rm -f xhpast parser.yacc.output libxhpast.a *.o
rm -f scanner.lex.hpp scanner.lex.cpp parser.yacc.hpp parser.yacc.cpp
rm -f node_names.hpp parser_nodes.php
epriestley@orbital ~/dev/libphutil/support/xhpast $ make
flex -CFr --header-file=scanner.lex.hpp --outfile=scanner.lex.cpp scanner.l
bison --verbose -Wall --defines=parser.yacc.hpp --output=parser.yacc.cpp parser.y
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison: invalid option -- W
Try `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison --help' for more information.
make: *** [parser.yacc.hpp] Error 1

After removing -Wall, I get this:

$ make
bison --verbose --defines=parser.yacc.hpp --output=parser.yacc.cpp parser.y
parser.y:60.14-21: syntax error, unexpected string, expecting =
make: *** [parser.yacc.hpp] Error 1

This line is:

%name-prefix "xhpast"

Replacing it with this fixes the warning:

%name-prefix = "xhpast"

...although that fix seems very odd. Then I get this:

$ make
bison --verbose --defines=parser.yacc.hpp --output=parser.yacc.cpp parser.y
parser.y:67.1-11: invalid directive: `%precedence'
parser.y:67.13-21: syntax error, unexpected identifier
make: *** [parser.yacc.hpp] Error 1

It looks like %precedence is new in Bison 3-ish. This change came from D13974.

I think the value of supporting stock bison on OSX is greater than the value of fixing warnings in Bison 3, if that's all D13974 accomplishes.

If we need bison 3, we should version test in make and exit with a better error.

Event Timeline

epriestley renamed this task from xhpast no longer parses heredocs and can't build on OS X to xhpast no longer parses heredocs and can't build on OS X (Bison 2.3).
epriestley raised the priority of this task from to Normal.
epriestley updated the task description. (Show Details)
epriestley added subscribers: epriestley, joshuaspence.
joshuaspence renamed this task from xhpast no longer parses heredocs and can't build on OS X (Bison 2.3) to XHPAST no longer parses heredocs and can't build on OS X (Bison 2.3).Nov 10 2015, 7:28 PM
joshuaspence added a project: XHPAST.
epriestley renamed this task from XHPAST no longer parses heredocs and can't build on OS X (Bison 2.3) to XHPAST no longer parses heredocs and can't build on OS X (Bison 2.3).Apr 7 2020, 9:03 PM