Skip to content

Bison : clean up #5138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Bison : clean up #5138

wants to merge 2 commits into from

Conversation

akimd
Copy link
Contributor

@akimd akimd commented Feb 1, 2020

Clean up the generation of the parsers

Prefer %define api.value.type to #define YYSTYPE, so that Bison know the type.

Use %code requires to declare what is needed to define the api.value.type (that code is output in the generated header before the generated definition of YYSTYPE).

Prefer %define api.prefix inside the grammar file to -p outside, as anyway the functions defined in the file actually use this prefix.

Bison: enable all the warnings and fix them

First, fix 5547d36: the definition of YFLAGS was not passed into the Makefile: AC_SUBST does not suffice, we need PHP_SUBST_OLD. While at it, allow to pass variable and value at the same time.

Then pass -Wall to bison, rather than only -Wempty-rules.

Use %precedence where associativity is useless.

Remove useless %precedence.

@akimd akimd force-pushed the bison-cleanup branch 2 times, most recently from ef3264a to 781f020 Compare February 1, 2020 07:09
Prefer '%define api.value.type' to '#define YYSTYPE', so that Bison
know the type.

Use '%code requires' to declare what is needed to define the api.value.type
(that code is output in the generated header before the generated
definition of YYSTYPE).

Prefer '%define api.prefix' inside the grammar file to '-p' outside,
as anyway the functions defined in the file actually use this prefix.

Prefer `%param` to both `%parse-param` and `%lex-param`.
First, fix 5547d36: the definition of
YFLAGS was not passed into the Makefile: AC_SUBST does not suffice, we
need PHP_SUBST_OLD.  While at it, allow to pass variable and value at
the same time.

Then pass -Wall to bison, rather than only -Wempty-rules.

Use %precedence where associativity is useless.

Remove useless %precedence.
kocsismate pushed a commit to kocsismate/php-src that referenced this pull request Feb 1, 2020
First, fix 5547d36: the definition of
YFLAGS was not passed into the Makefile: AC_SUBST does not suffice, we
need PHP_SUBST_OLD.  While at it, allow to pass variable and value at
the same time.

Then pass -Wall to bison, rather than only -Wempty-rules.

Use %precedence where associativity is useless.

Remove useless %precedence.
phpGH-5138
@php-pulls php-pulls closed this in 4cbffd8 Feb 1, 2020
@exussum12
Copy link
Contributor

I think this is causing issues. Im getting this now https://hastebin.com/agicesirej.rb running make clean doesnt seem to resolve it

@akimd akimd deleted the bison-cleanup branch February 2, 2020 06:59
@akimd
Copy link
Contributor Author

akimd commented Feb 2, 2020

Hi @exussum12. I am unable to reproduce it (and I don't see how these changes can cause what you reported, but we do agree they could). Did you have the problem with a build from scratch, or from an existing build directory?

@exussum12
Copy link
Contributor

From scratch.

The file being complained about was auto generated.

I was building on Ubuntu 19.10 If that helps

@akimd
Copy link
Contributor Author

akimd commented Feb 2, 2020

AFAICT this error message:

/home/scott/code/php-src/ext/tokenizer/tokenizer_data.c:51:45: error: ‘T_COALESCE_EQUAL’ undeclared (first use in this function); did you mean ‘T_COALESCE’?
   51 |  REGISTER_LONG_CONSTANT("T_COALESCE_EQUAL", T_COALESCE_EQUAL, CONST_CS | CONST_PERSISTENT);
      |                                             ^~~~~~~~~~~~~~~~

is consistent with the expected content of that file (ext/tokenizer/tokenizer_data.c). So I guess the problem is that Zend/zend_language_parser.h, which is expected to define T_COALESCE_EQUAL, does not.

Here's a piece of the file I have in my tree (with T_COALESCE_EQUAL), what's yours? Also, what build system do you use? Regular ./configure && make?

/* Token type.  */
#ifndef ZENDTOKENTYPE
# define ZENDTOKENTYPE
  enum zendtokentype
  {
    END = 0,
    PREC_ARROW_FUNCTION = 258,
    T_INCLUDE = 259,
    T_INCLUDE_ONCE = 260,
    T_REQUIRE = 261,
    T_REQUIRE_ONCE = 262,
    T_LOGICAL_OR = 263,
    T_LOGICAL_XOR = 264,
    T_LOGICAL_AND = 265,
    T_PRINT = 266,
    T_YIELD = 267,
    T_DOUBLE_ARROW = 268,
    T_YIELD_FROM = 269,
    T_PLUS_EQUAL = 270,
    T_MINUS_EQUAL = 271,
    T_MUL_EQUAL = 272,
    T_DIV_EQUAL = 273,
    T_CONCAT_EQUAL = 274,
    T_MOD_EQUAL = 275,
    T_AND_EQUAL = 276,
    T_OR_EQUAL = 277,
    T_XOR_EQUAL = 278,
    T_SL_EQUAL = 279,
    T_SR_EQUAL = 280,
    T_POW_EQUAL = 281,
    T_COALESCE_EQUAL = 282,
    T_COALESCE = 283,
    T_BOOLEAN_OR = 284,
    T_BOOLEAN_AND = 285,
    T_IS_EQUAL = 286,
    T_IS_NOT_EQUAL = 287,
    T_IS_IDENTICAL = 288,
    T_IS_NOT_IDENTICAL = 289,
    T_SPACESHIP = 290,
    T_IS_SMALLER_OR_EQUAL = 291,
    T_IS_GREATER_OR_EQUAL = 292,
    T_SL = 293,
    T_SR = 294,
    T_INSTANCEOF = 295,
    T_INT_CAST = 296,
    T_DOUBLE_CAST = 297,
    T_STRING_CAST = 298,
    T_ARRAY_CAST = 299,
    T_OBJECT_CAST = 300,
    T_BOOL_CAST = 301,
    T_UNSET_CAST = 302,
    T_POW = 303,
    T_CLONE = 304,
    T_NOELSE = 305,
    T_ELSEIF = 306,
    T_ELSE = 307,
    T_LNUMBER = 308,
    T_DNUMBER = 309,
    T_STRING = 310,
    T_VARIABLE = 311,
    T_INLINE_HTML = 312,
    T_ENCAPSED_AND_WHITESPACE = 313,
    T_CONSTANT_ENCAPSED_STRING = 314,
    T_STRING_VARNAME = 315,
    T_NUM_STRING = 316,
    T_EVAL = 317,
    T_INC = 318,
    T_DEC = 319,
    T_NEW = 320,
    T_EXIT = 321,
    T_IF = 322,
    T_ENDIF = 323,
    T_ECHO = 324,
    T_DO = 325,
    T_WHILE = 326,
    T_ENDWHILE = 327,
    T_FOR = 328,
    T_ENDFOR = 329,
    T_FOREACH = 330,
    T_ENDFOREACH = 331,
    T_DECLARE = 332,
    T_ENDDECLARE = 333,
    T_AS = 334,
    T_SWITCH = 335,
    T_ENDSWITCH = 336,
    T_CASE = 337,
    T_DEFAULT = 338,
    T_BREAK = 339,
    T_CONTINUE = 340,
    T_GOTO = 341,
    T_FUNCTION = 342,
    T_FN = 343,
    T_CONST = 344,
    T_RETURN = 345,
    T_TRY = 346,
    T_CATCH = 347,
    T_FINALLY = 348,
    T_THROW = 349,
    T_USE = 350,
    T_INSTEADOF = 351,
    T_GLOBAL = 352,
    T_STATIC = 353,
    T_ABSTRACT = 354,
    T_FINAL = 355,
    T_PRIVATE = 356,
    T_PROTECTED = 357,
    T_PUBLIC = 358,
    T_VAR = 359,
    T_UNSET = 360,
    T_ISSET = 361,
    T_EMPTY = 362,
    T_HALT_COMPILER = 363,
    T_CLASS = 364,
    T_TRAIT = 365,
    T_INTERFACE = 366,
    T_EXTENDS = 367,
    T_IMPLEMENTS = 368,
    T_OBJECT_OPERATOR = 369,
    T_LIST = 370,
    T_ARRAY = 371,
    T_CALLABLE = 372,
    T_LINE = 373,
    T_FILE = 374,
    T_DIR = 375,
    T_CLASS_C = 376,
    T_TRAIT_C = 377,
    T_METHOD_C = 378,
    T_FUNC_C = 379,
    T_COMMENT = 380,
    T_DOC_COMMENT = 381,
    T_OPEN_TAG = 382,
    T_OPEN_TAG_WITH_ECHO = 383,
    T_CLOSE_TAG = 384,
    T_WHITESPACE = 385,
    T_START_HEREDOC = 386,
    T_END_HEREDOC = 387,
    T_DOLLAR_OPEN_CURLY_BRACES = 388,
    T_CURLY_OPEN = 389,
    T_PAAMAYIM_NEKUDOTAYIM = 390,
    T_NAMESPACE = 391,
    T_NS_C = 392,
    T_NS_SEPARATOR = 393,
    T_ELLIPSIS = 394,
    T_BAD_CHARACTER = 395,
    T_ERROR = 396
  };
#endif

@exussum12
Copy link
Contributor

After compiling successfully its fine now when I switch back to the branch, I will see if I can reproduce, same script and same machine as yesterday is now working.

Script for rebuild was make clean && ./buildconf && ./configure && make -j 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants