reflex.cpp.targetspec

00001 // ///////////////////////////////////////////////////////////////////////////
00002 // reflex.cpp.targetspec by Victor Dods, created 2006/11/09
00003 // ///////////////////////////////////////////////////////////////////////////
00004 // Unless a different license was explicitly granted in writing by the
00005 // copyright holder (Victor Dods), this software is freely distributable under
00006 // the terms of the GNU General Public License, version 2.  Any works deriving
00007 // from this work must also be released under the GNU GPL.  See the included
00008 // file LICENSE for details.
00009 // ///////////////////////////////////////////////////////////////////////////
00010 
00011 // This is a reflex targetspec file for a C++ lexical scanner class using a
00012 // deterministic finite automaton (DFA).
00013 %target cpp
00014 
00015 // The value of this directive specifies the filename to use when generating
00016 // the header file (it is used by the below add_codespec directive).
00017 %add_required_directive header_filename %string
00018 // This refers to the file reflex.cpp.header.codespec in the data directory.
00019 // See that file for the header template code.
00020 %add_codespec "header" header_filename
00021 
00022 // The value of this directive specifies the filename to use when generating
00023 // the implementation file (it is used by the below add_codespec directive).
00024 %add_required_directive implementation_filename %string
00025 // This refers to the file reflex.cpp.implementation.codespec in the data
00026 // directory.  See that file for the implementation template code.
00027 %add_codespec "implementation" implementation_filename
00028 
00029 // ///////////////////////////////////////////////////////////////////////////
00030 // The following directives can be thought of as applying to the header file
00031 // which is to be generated by reflex.
00032 // ///////////////////////////////////////////////////////////////////////////
00033 
00034 // The value of this directive will be placed at the top of the generated
00035 // header file, below the generated #include directives.  It is a dumb code
00036 // block (as opposed to a strict code block) so that you can open a namespace
00037 // which the generated class will be enclosed in (and consequently, the
00038 // matching close-bracket is not in the same code block).
00039 // e.g. %{ namespace SweetNamespace { %}
00040 %add_optional_directive top_of_header_file                  %dumb_code_block
00041 // The name of the class to be generated by reflex, e.g. "DumbScanner"
00042 %add_required_directive class_name                          %identifier
00043 // The optional class inheritance of the generated class,
00044 // e.g. { public AwesomeBase }
00045 %add_optional_directive class_inheritance                   %strict_code_block
00046 // Class declarations to put at the top of the generated class.  They will by
00047 // default have class access of public.  This may be necessary to use in some
00048 // cases to guarantee that these declarations come before later ones
00049 // (including the scanner's generated methods.
00050 // e.g. { enum HippoType { HAPPY, SAD, ANGRY }; }
00051 %add_optional_directive top_of_class                        %strict_code_block
00052 // Specifies the parameters for both the declaration and the definition of the
00053 // generated class' constructor, unless constructor_definition_parameters is
00054 // also specified, in which case, this one is only used for the constructor's
00055 // declaration (i.e. the one which appears in the header file).
00056 // e.g. "HippoType best_hippo_type = ANGRY"
00057 %add_optional_directive constructor_parameters              %strict_code_block
00058 // Specifies the parameters for the definition of the generated class'
00059 // constructor (i.e. the one which appears in the implementation file),
00060 // overriding constructor_parameters.  It is an error to specify a value
00061 // for this directive without specifying a value for constructor_parameters.
00062 // e.g. "HippoType best_hippo_type"
00063 %add_optional_directive constructor_definition_parameters   %strict_code_block
00064 // When present, causes the generated class' destructor to be virtual.
00065 %add_optional_directive force_virtual_destructor
00066 // Specifies the class access of the generated Scan method.  Valid values are
00067 // "public:", "protected:" or "private:".  The default access is "public:".
00068 %add_optional_directive scan_method_access                  %string
00069 // Specifies the parameters for the declaration and the definition of the
00070 // generated Scan method, unless scan_method_definition_parameters is also
00071 // specified, in which case, this one is only used for the Scan method's
00072 // declaration (i.e. the one which appears in the header file).  These
00073 // parameters will be available to all regex rule handlers specified in the
00074 // reflex source file.
00075 // e.g. "AstBase *dest_token, HippoType hippo_type = HAPPY"
00076 %add_optional_directive scan_method_parameters              %strict_code_block
00077 // Specifies the parameters for the definition of the generated Scan method
00078 // (i.e. the one which appears in the implementation file).  It is an error to
00079 // specify a value for this directive without specifying a value for
00080 // scan_method_parameters. These parameters will be available to all regex
00081 // rule handlers specified in the reflex source file.
00082 // e.g. "AstBase *dest_token, HippoType hippo_type"
00083 %add_optional_directive scan_method_definition_parameters   %strict_code_block
00084 // Similar to top_of_class, this facilitates class declarations at the bottom,
00085 // which may be necessary when declarations from the middle of the generated
00086 // class are needed.  Again, the default class access level is public.
00087 // e.g. { Mode::Name m_saved_scanner_mode; }
00088 %add_optional_directive bottom_of_class                     %strict_code_block
00089 // This is the analog to top_of_header_file -- its contents go directly at the
00090 // bottom of the generated header file.  If you opened a namespace from within
00091 // top_of_header_file, remember to close it here.
00092 // e.g. %{ } // end of namespace SweetNamespace %}
00093 %add_optional_directive bottom_of_header_file               %dumb_code_block
00094 
00095 // ///////////////////////////////////////////////////////////////////////////
00096 // The following directives can be thought of as applying to the
00097 // implementation file which is to be generated by reflex.
00098 // ///////////////////////////////////////////////////////////////////////////
00099 
00100 // Like top_of_header_file, the value of this directive will be placed at the
00101 // top of the generated implementation file, below the generated #include
00102 // directives.  It is also a dumb code block, so you can employ unterminated
00103 // namespace blocks.
00104 // e.g. %{ namespace SweetNamespace { %}
00105 %add_optional_directive top_of_implementation_file          %dumb_code_block
00106 // If any superclasses or members need explicit construction, do it here.
00107 // e.g. { AwesomeBase(1, 2, 3), m_saved_scanner_mode(Mode::MAIN) }
00108 %add_optional_directive superclass_and_member_constructors  %strict_code_block
00109 // This specifies code for the body of the generated class' constructor.
00110 // e.g. { std::cout << "constructor being executed" << std::endl; }
00111 %add_optional_directive constructor_actions                 %strict_code_block
00112 // Like constructor_actions, this specifies code for the body of the generated
00113 // class' destructor.
00114 // e.g. { std::cout << "destructor being executed" << std::endl; }
00115 %add_optional_directive destructor_actions                  %strict_code_block
00116 // If anything needs to be done at the very beginning of the generated Scan
00117 // method, it should be specified here.  If you wanted to enclose the entire
00118 // contents of the Scan method within a "try" block, you would use this to
00119 // open the "try" block.
00120 // e.g. %{ try { %}
00121 %add_optional_directive start_of_scan_method_actions        %dumb_code_block
00122 // This is the analog to start_of_scan_method_actions -- its contents go
00123 // directly at the end of the generated Scan method.  If you opened a "try"
00124 // block within start_of_scan_method_actions, remember to finish it with one
00125 // or more "catch" blocks.  This section of the Scan method will only be
00126 // reached if no scanner regex rules or rejection_actions (see below) return
00127 // upon end-of-file.  If you specify a non-void value for return_type, you
00128 // should remember to provide a return statement (your C++ compiler should
00129 // warn about this if left out).
00130 // e.g. %{ } catch (...) { std::cout << "caught exception" << std::endl } %}
00131 %add_optional_directive end_of_scan_method_actions          %dumb_code_block
00132 // This is the analog to top_of_implementation_file -- its contents go
00133 // directly at the bottom of the generated implementation file.  If you opened
00134 // a namespace from within top_of_implementation_file, remember to close it
00135 // here.
00136 // e.g. %{ } // end of namespace SweetNamespace %}
00137 %add_optional_directive bottom_of_implementation_file       %dumb_code_block
00138 
00139 // ///////////////////////////////////////////////////////////////////////////
00140 // The following directives can be thought of as I/O parameters for the
00141 // scanner class which is to be generated by reflex.
00142 // ///////////////////////////////////////////////////////////////////////////
00143 
00144 // This specifies the return type of the generated Scan method.  The default
00145 // value is void so as to not require a return statement in the Scan method.
00146 // e.g. use "TrisonParserClass::Token::Type" -- when reflex is used with
00147 // trison.
00148 %add_optional_directive return_type                         %string             %default "void"
00149 // This value's code should return true only when the next read operation will
00150 // produce the end-of-file condition.  The default value is an example for
00151 // indicating EOF for stdin.
00152 %add_optional_directive return_true_iff_input_is_at_end     %strict_code_block  %default { return std::cin.peek() == std::char_traits<char>::eof(); }
00153 // This value's code should return the next input character.  The null char
00154 // '\0' should not be returned by this code; correspondingly, this code will
00155 // never be called once the end-of-file condition has been reached.  The
00156 // default value is an example for returning the next character from stdin.
00157 %add_optional_directive return_next_input_char              %strict_code_block  %default { return std::cin.get(); }
00158 // This value's code is executed when a character is not matched by any regex
00159 // rule in the scanner's current state.  The rejected character is in the
00160 // local variable rejected_atom.  This is never called at the end of input;
00161 // the main scanner loop is broken from and end_of_scan_method_actions is
00162 // executed.  The default value simply prints the unmatched char to stdout.
00163 %add_optional_directive rejection_actions                   %strict_code_block  %default { std::cout << rejected_atom; }
00164 // This specifies code to be executed when the scanner object is being reset
00165 // to start scanning from a new source.  This code is executed in addition to
00166 // various internal state-machine-related initialization that is required.
00167 %add_optional_directive reset_for_new_input_actions         %strict_code_block
00168 
00169 // ///////////////////////////////////////////////////////////////////////////
00170 // Miscellaneous directives
00171 // ///////////////////////////////////////////////////////////////////////////
00172 
00173 // When present, indicates that the code associated with debug spew will be
00174 // generated; the methods Get/SetDebugSpewFlags will be generated.
00175 %add_optional_directive generate_debug_spew_code
00176 // When present, will prevent the timestamp from being added to the top of
00177 // the generated source code files (useful when the generated files are
00178 // checked into a version control system).  The default behavior is to 
00179 // put a timestamp in the generated header and implementation files.
00180 %add_optional_directive dont_generate_timestamps
00181 
00182 
00183 // TODO: add BARF-developer debug code directive

Hosted by SourceForge.net Logo -- Generated on Mon Jan 7 22:58:00 2008 for BARF by doxygen 1.5.1