help-bison
[Top][All Lists]
Advanced

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

Is generate C++ Bison parser re-entrant?


From: Ricky Zhang
Subject: Is generate C++ Bison parser re-entrant?
Date: Wed, 30 Nov 2016 15:58:09 -0500

I'm working on a hobby project that use flex/bison to generate C++
scanner/parser. Because there are gazillion number of the parsing objects.
The parsing itself is embarrassingly parallel problem. I want to pool a
couple of ready-to-run scanner/parser object and let them run in parallel.

I read through Flex and Bison official document and skim through their
generated codes.

I can confirm that from Flex document and its code the generating C++
scanner is re-entrant.

However, I have hard time to confirm this from Bison document. It does have
document stating how to build an re-entrant C parser in Bison. But it
doesn't explicitly imply if you build a C++ parser, it is re-entrant. I
found a couple of static class member in Bison generated parser header
file, which make me concern on this matter:

    // Tables.

  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing

  // STATE-NUM.

  static const short int yypact_[];


  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.

  // Performed when YYTABLE does not specify something else to do.  Zero

  // means the default is an error.

  static const unsigned char yydefact_[];


  // YYPGOTO[NTERM-NUM].

  static const signed char yypgoto_[];


  // YYDEFGOTO[NTERM-NUM].

  static const signed char yydefgoto_[];


  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If

  // positive, shift that token.  If negative, reduce the rule whose

  // number is the opposite.  If YYTABLE_NINF, syntax error.

  static const short int yytable_[];


  static const short int yycheck_[];


  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing

  // symbol of state STATE-NUM.

  static const unsigned char yystos_[];


  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.

  static const unsigned char yyr1_[];


  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.

  static const unsigned char yyr2_[];


Is generate C++ Bison parser re-entrant?

Cheers,
Ricky


reply via email to

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