Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One trick I could suggest is to separate the compilation of the constructors of both, your lexer and your grammar. The easiest way to achieve this is to leave only the declaration of those constructors in their respecitive header files and to move the definition of those functions into separate translation units. For instance:</p> <p>grammar.hpp:</p> <pre><code>template &lt;typename Iterator&gt; struct grammar : qi::grammar&lt;Iterator&gt; { grammar(); // declaration only // ... }; </code></pre> <p>grammar_def.hpp:</p> <pre><code>// This file should not contain anything else. #include "grammar.hpp" // Definition of constructor. template &lt;typename Iterator&gt; grammar&lt;Iterator&gt;::grammar() { // initialize your rules here } </code></pre> <p>grammar.cpp:</p> <pre><code>// This file should not contain anything else. #include "grammar_def.hpp" // Explicitly instantiate the constructor for the iterator type // you use to invoke the grammar (here, as an example I use // std::string::const_iterator). typedef std::string::const_iterator iterator_type; template grammar&lt;iterator_type&gt;::grammar(); </code></pre> <p>Do the same thing for the lexer object.</p> <p>This approach requires a bit more work than the straight method, but it allows to distribute the memory and time requirements for the overall compilation. Another advantage of this approach is that any change in the grammar constructor does not require the recompilation of anything except the file <code>grammar.cpp</code>.</p> <p>Another advice for the lexer: try to minimize the use of <code>token_def&lt;&gt;</code> instances as much as possible. You need to use <code>token_def&lt;&gt;</code> only when you want to access the token value as an attribute during parsing. In all other cases you might get away with <code>lex::string</code> or <code>lex::char_</code> to define your tokens.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload