├── .gitignore ├── AUTHORS ├── COPYING ├── Doxyfile ├── Makefile.am ├── README ├── autogen.sh ├── bashast ├── bashast.g ├── features_script │ └── features.sh └── gunit │ ├── arith_main.gunit │ ├── array.gunit │ ├── assoc_array.gunit │ ├── brace.gunit │ ├── command_sub.gunit │ ├── comment.gunit │ ├── compound.gunit │ ├── cond_main.gunit │ ├── continued_lines.gunit │ ├── expansions.gunit │ ├── fname.gunit │ ├── function.gunit │ ├── list.gunit │ ├── param_main.gunit │ ├── pipeline.gunit │ ├── proc_sub.gunit │ ├── redir.gunit │ ├── runtests.sh │ ├── simp_command.gunit │ └── simp_prog.gunit ├── coding_standard └── coding_standard.tex ├── configure.ac ├── doxample.am ├── doxygen.am ├── m4 ├── ax_boost_base.m4 ├── doxample.m4 └── gtest.m4 └── src ├── builtins ├── builtins.h ├── echo_builtin.cpp ├── echo_builtin.h └── tests │ ├── echo_tests.cpp │ └── run_tests.cpp ├── cppbash_builtin.cpp └── cppbash_builtin.h /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.la 4 | *.lo 5 | *.log 6 | .deps 7 | .libs 8 | .dirstamp 9 | Makefile.in 10 | aclocal.m4 11 | depcomp 12 | install-sh 13 | missing 14 | Makefile 15 | autom4te.cache 16 | builtin_unittests 17 | bashast.g 18 | bashast.tokens 19 | bashast/.DS_Store 20 | bashast/*.ebuild 21 | bashast/c_runtime 22 | bashast/output 23 | bashast/portage_parse 24 | bashast/tmp/ 25 | bashast/tokens.png 26 | bashastLexer.* 27 | bashastParser.* 28 | coding_standard/*.pdf 29 | coding_standard/*.log 30 | coding_standard/*.aux 31 | config.* 32 | *.run 33 | configure 34 | tests/a.out 35 | *.temp 36 | bashast/output.g 37 | .DS_Store 38 | m4/libtool.m4 39 | m4/ltoptions.m4 40 | m4/ltsugar.m4 41 | m4/ltversion.m4 42 | m4/lt~obsolete.m4 43 | libtool 44 | ltmain.sh 45 | INSTALL 46 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Nathan Eloe 2 | Petteri Räty 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Doxyfile: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.7.1 2 | 3 | # This file describes the settings to be used by the documentation system 4 | # doxygen (www.doxygen.org) for a project 5 | # 6 | # All text after a hash (#) is considered a comment and will be ignored 7 | # The format is: 8 | # TAG = value [value, ...] 9 | # For lists items can also be appended using: 10 | # TAG += value [value, ...] 11 | # Values that contain spaces should be placed between quotes (" ") 12 | 13 | #--------------------------------------------------------------------------- 14 | # Project related configuration options 15 | #--------------------------------------------------------------------------- 16 | 17 | # This tag specifies the encoding used for all characters in the config file 18 | # that follow. The default is UTF-8 which is also the encoding used for all 19 | # text before the first occurrence of this tag. Doxygen uses libiconv (or the 20 | # iconv built into libc) for the transcoding. See 21 | # http://www.gnu.org/software/libiconv for the list of possible encodings. 22 | 23 | DOXYFILE_ENCODING = UTF-8 24 | 25 | # The PROJECT_NAME tag is a single word (or a sequence of words surrounded 26 | # by quotes) that should identify the project. 27 | 28 | PROJECT_NAME = libbash 29 | 30 | # The PROJECT_NUMBER tag can be used to enter a project or revision number. 31 | # This could be handy for archiving the generated documentation or 32 | # if some version control system is used. 33 | 34 | PROJECT_NUMBER = 0.1 35 | 36 | # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 37 | # base path where the generated documentation will be put. 38 | # If a relative path is entered, it will be relative to the location 39 | # where doxygen was started. If left blank the current directory will be used. 40 | 41 | OUTPUT_DIRECTORY = docs 42 | 43 | # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 44 | # 4096 sub-directories (in 2 levels) under the output directory of each output 45 | # format and will distribute the generated files over these directories. 46 | # Enabling this option can be useful when feeding doxygen a huge amount of 47 | # source files, where putting all generated files in the same directory would 48 | # otherwise cause performance problems for the file system. 49 | 50 | CREATE_SUBDIRS = NO 51 | 52 | # The OUTPUT_LANGUAGE tag is used to specify the language in which all 53 | # documentation generated by doxygen is written. Doxygen will use this 54 | # information to generate all constant output in the proper language. 55 | # The default language is English, other supported languages are: 56 | # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 57 | # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 58 | # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 59 | # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 60 | # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, 61 | # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. 62 | 63 | OUTPUT_LANGUAGE = English 64 | 65 | # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 66 | # include brief member descriptions after the members that are listed in 67 | # the file and class documentation (similar to JavaDoc). 68 | # Set to NO to disable this. 69 | 70 | BRIEF_MEMBER_DESC = YES 71 | 72 | # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 73 | # the brief description of a member or function before the detailed description. 74 | # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 75 | # brief descriptions will be completely suppressed. 76 | 77 | REPEAT_BRIEF = YES 78 | 79 | # This tag implements a quasi-intelligent brief description abbreviator 80 | # that is used to form the text in various listings. Each string 81 | # in this list, if found as the leading text of the brief description, will be 82 | # stripped from the text and the result after processing the whole list, is 83 | # used as the annotated text. Otherwise, the brief description is used as-is. 84 | # If left blank, the following values are used ("$name" is automatically 85 | # replaced with the name of the entity): "The $name class" "The $name widget" 86 | # "The $name file" "is" "provides" "specifies" "contains" 87 | # "represents" "a" "an" "the" 88 | 89 | ABBREVIATE_BRIEF = 90 | 91 | # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 92 | # Doxygen will generate a detailed section even if there is only a brief 93 | # description. 94 | 95 | ALWAYS_DETAILED_SEC = NO 96 | 97 | # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 98 | # inherited members of a class in the documentation of that class as if those 99 | # members were ordinary class members. Constructors, destructors and assignment 100 | # operators of the base classes will not be shown. 101 | 102 | INLINE_INHERITED_MEMB = NO 103 | 104 | # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 105 | # path before files name in the file list and in the header files. If set 106 | # to NO the shortest path that makes the file name unique will be used. 107 | 108 | FULL_PATH_NAMES = YES 109 | 110 | # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 111 | # can be used to strip a user-defined part of the path. Stripping is 112 | # only done if one of the specified strings matches the left-hand part of 113 | # the path. The tag can be used to show relative paths in the file list. 114 | # If left blank the directory from which doxygen is run is used as the 115 | # path to strip. 116 | 117 | STRIP_FROM_PATH = 118 | 119 | # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 120 | # the path mentioned in the documentation of a class, which tells 121 | # the reader which header file to include in order to use a class. 122 | # If left blank only the name of the header file containing the class 123 | # definition is used. Otherwise one should specify the include paths that 124 | # are normally passed to the compiler using the -I flag. 125 | 126 | STRIP_FROM_INC_PATH = 127 | 128 | # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 129 | # (but less readable) file names. This can be useful is your file systems 130 | # doesn't support long names like on DOS, Mac, or CD-ROM. 131 | 132 | SHORT_NAMES = NO 133 | 134 | # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 135 | # will interpret the first line (until the first dot) of a JavaDoc-style 136 | # comment as the brief description. If set to NO, the JavaDoc 137 | # comments will behave just like regular Qt-style comments 138 | # (thus requiring an explicit @brief command for a brief description.) 139 | 140 | JAVADOC_AUTOBRIEF = NO 141 | 142 | # If the QT_AUTOBRIEF tag is set to YES then Doxygen will 143 | # interpret the first line (until the first dot) of a Qt-style 144 | # comment as the brief description. If set to NO, the comments 145 | # will behave just like regular Qt-style comments (thus requiring 146 | # an explicit \brief command for a brief description.) 147 | 148 | QT_AUTOBRIEF = NO 149 | 150 | # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 151 | # treat a multi-line C++ special comment block (i.e. a block of //! or /// 152 | # comments) as a brief description. This used to be the default behaviour. 153 | # The new default is to treat a multi-line C++ comment block as a detailed 154 | # description. Set this tag to YES if you prefer the old behaviour instead. 155 | 156 | MULTILINE_CPP_IS_BRIEF = NO 157 | 158 | # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 159 | # member inherits the documentation from any documented member that it 160 | # re-implements. 161 | 162 | INHERIT_DOCS = YES 163 | 164 | # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 165 | # a new page for each member. If set to NO, the documentation of a member will 166 | # be part of the file/class/namespace that contains it. 167 | 168 | SEPARATE_MEMBER_PAGES = NO 169 | 170 | # The TAB_SIZE tag can be used to set the number of spaces in a tab. 171 | # Doxygen uses this value to replace tabs by spaces in code fragments. 172 | 173 | TAB_SIZE = 2 174 | 175 | # This tag can be used to specify a number of aliases that acts 176 | # as commands in the documentation. An alias has the form "name=value". 177 | # For example adding "sideeffect=\par Side Effects:\n" will allow you to 178 | # put the command \sideeffect (or @sideeffect) in the documentation, which 179 | # will result in a user-defined paragraph with heading "Side Effects:". 180 | # You can put \n's in the value part of an alias to insert newlines. 181 | 182 | ALIASES = 183 | 184 | # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 185 | # sources only. Doxygen will then generate output that is more tailored for C. 186 | # For instance, some of the names that are used will be different. The list 187 | # of all members will be omitted, etc. 188 | 189 | OPTIMIZE_OUTPUT_FOR_C = NO 190 | 191 | # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 192 | # sources only. Doxygen will then generate output that is more tailored for 193 | # Java. For instance, namespaces will be presented as packages, qualified 194 | # scopes will look different, etc. 195 | 196 | OPTIMIZE_OUTPUT_JAVA = NO 197 | 198 | # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 199 | # sources only. Doxygen will then generate output that is more tailored for 200 | # Fortran. 201 | 202 | OPTIMIZE_FOR_FORTRAN = NO 203 | 204 | # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 205 | # sources. Doxygen will then generate output that is tailored for 206 | # VHDL. 207 | 208 | OPTIMIZE_OUTPUT_VHDL = NO 209 | 210 | # Doxygen selects the parser to use depending on the extension of the files it 211 | # parses. With this tag you can assign which parser to use for a given extension. 212 | # Doxygen has a built-in mapping, but you can override or extend it using this 213 | # tag. The format is ext=language, where ext is a file extension, and language 214 | # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 215 | # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 216 | # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 217 | # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 218 | # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. 219 | 220 | EXTENSION_MAPPING = 221 | 222 | # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 223 | # to include (a tag file for) the STL sources as input, then you should 224 | # set this tag to YES in order to let doxygen match functions declarations and 225 | # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 226 | # func(std::string) {}). This also make the inheritance and collaboration 227 | # diagrams that involve STL classes more complete and accurate. 228 | 229 | BUILTIN_STL_SUPPORT = YES 230 | 231 | # If you use Microsoft's C++/CLI language, you should set this option to YES to 232 | # enable parsing support. 233 | 234 | CPP_CLI_SUPPORT = NO 235 | 236 | # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 237 | # Doxygen will parse them like normal C++ but will assume all classes use public 238 | # instead of private inheritance when no explicit protection keyword is present. 239 | 240 | SIP_SUPPORT = NO 241 | 242 | # For Microsoft's IDL there are propget and propput attributes to indicate getter 243 | # and setter methods for a property. Setting this option to YES (the default) 244 | # will make doxygen to replace the get and set methods by a property in the 245 | # documentation. This will only work if the methods are indeed getting or 246 | # setting a simple type. If this is not the case, or you want to show the 247 | # methods anyway, you should set this option to NO. 248 | 249 | IDL_PROPERTY_SUPPORT = YES 250 | 251 | # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 252 | # tag is set to YES, then doxygen will reuse the documentation of the first 253 | # member in the group (if any) for the other members of the group. By default 254 | # all members of a group must be documented explicitly. 255 | 256 | DISTRIBUTE_GROUP_DOC = NO 257 | 258 | # Set the SUBGROUPING tag to YES (the default) to allow class member groups of 259 | # the same type (for instance a group of public functions) to be put as a 260 | # subgroup of that type (e.g. under the Public Functions section). Set it to 261 | # NO to prevent subgrouping. Alternatively, this can be done per class using 262 | # the \nosubgrouping command. 263 | 264 | SUBGROUPING = YES 265 | 266 | # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 267 | # is documented as struct, union, or enum with the name of the typedef. So 268 | # typedef struct TypeS {} TypeT, will appear in the documentation as a struct 269 | # with name TypeT. When disabled the typedef will appear as a member of a file, 270 | # namespace, or class. And the struct will be named TypeS. This can typically 271 | # be useful for C code in case the coding convention dictates that all compound 272 | # types are typedef'ed and only the typedef is referenced, never the tag name. 273 | 274 | TYPEDEF_HIDES_STRUCT = NO 275 | 276 | # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 277 | # determine which symbols to keep in memory and which to flush to disk. 278 | # When the cache is full, less often used symbols will be written to disk. 279 | # For small to medium size projects (<1000 input files) the default value is 280 | # probably good enough. For larger projects a too small cache size can cause 281 | # doxygen to be busy swapping symbols to and from disk most of the time 282 | # causing a significant performance penality. 283 | # If the system has enough physical memory increasing the cache will improve the 284 | # performance by keeping more symbols in memory. Note that the value works on 285 | # a logarithmic scale so increasing the size by one will rougly double the 286 | # memory usage. The cache size is given by this formula: 287 | # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 288 | # corresponding to a cache size of 2^16 = 65536 symbols 289 | 290 | SYMBOL_CACHE_SIZE = 0 291 | 292 | #--------------------------------------------------------------------------- 293 | # Build related configuration options 294 | #--------------------------------------------------------------------------- 295 | 296 | # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 297 | # documentation are documented, even if no documentation was available. 298 | # Private class members and static file members will be hidden unless 299 | # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES 300 | 301 | EXTRACT_ALL = NO 302 | 303 | # If the EXTRACT_PRIVATE tag is set to YES all private members of a class 304 | # will be included in the documentation. 305 | 306 | EXTRACT_PRIVATE = YES 307 | 308 | # If the EXTRACT_STATIC tag is set to YES all static members of a file 309 | # will be included in the documentation. 310 | 311 | EXTRACT_STATIC = NO 312 | 313 | # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 314 | # defined locally in source files will be included in the documentation. 315 | # If set to NO only classes defined in header files are included. 316 | 317 | EXTRACT_LOCAL_CLASSES = YES 318 | 319 | # This flag is only useful for Objective-C code. When set to YES local 320 | # methods, which are defined in the implementation section but not in 321 | # the interface are included in the documentation. 322 | # If set to NO (the default) only methods in the interface are included. 323 | 324 | EXTRACT_LOCAL_METHODS = NO 325 | 326 | # If this flag is set to YES, the members of anonymous namespaces will be 327 | # extracted and appear in the documentation as a namespace called 328 | # 'anonymous_namespace{file}', where file will be replaced with the base 329 | # name of the file that contains the anonymous namespace. By default 330 | # anonymous namespace are hidden. 331 | 332 | EXTRACT_ANON_NSPACES = NO 333 | 334 | # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 335 | # undocumented members of documented classes, files or namespaces. 336 | # If set to NO (the default) these members will be included in the 337 | # various overviews, but no documentation section is generated. 338 | # This option has no effect if EXTRACT_ALL is enabled. 339 | 340 | HIDE_UNDOC_MEMBERS = NO 341 | 342 | # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 343 | # undocumented classes that are normally visible in the class hierarchy. 344 | # If set to NO (the default) these classes will be included in the various 345 | # overviews. This option has no effect if EXTRACT_ALL is enabled. 346 | 347 | HIDE_UNDOC_CLASSES = NO 348 | 349 | # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 350 | # friend (class|struct|union) declarations. 351 | # If set to NO (the default) these declarations will be included in the 352 | # documentation. 353 | 354 | HIDE_FRIEND_COMPOUNDS = NO 355 | 356 | # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 357 | # documentation blocks found inside the body of a function. 358 | # If set to NO (the default) these blocks will be appended to the 359 | # function's detailed documentation block. 360 | 361 | HIDE_IN_BODY_DOCS = NO 362 | 363 | # The INTERNAL_DOCS tag determines if documentation 364 | # that is typed after a \internal command is included. If the tag is set 365 | # to NO (the default) then the documentation will be excluded. 366 | # Set it to YES to include the internal documentation. 367 | 368 | INTERNAL_DOCS = NO 369 | 370 | # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 371 | # file names in lower-case letters. If set to YES upper-case letters are also 372 | # allowed. This is useful if you have classes or files whose names only differ 373 | # in case and if your file system supports case sensitive file names. Windows 374 | # and Mac users are advised to set this option to NO. 375 | 376 | CASE_SENSE_NAMES = NO 377 | 378 | # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 379 | # will show members with their full class and namespace scopes in the 380 | # documentation. If set to YES the scope will be hidden. 381 | 382 | HIDE_SCOPE_NAMES = NO 383 | 384 | # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 385 | # will put a list of the files that are included by a file in the documentation 386 | # of that file. 387 | 388 | SHOW_INCLUDE_FILES = YES 389 | 390 | # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 391 | # will list include files with double quotes in the documentation 392 | # rather than with sharp brackets. 393 | 394 | FORCE_LOCAL_INCLUDES = NO 395 | 396 | # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 397 | # is inserted in the documentation for inline members. 398 | 399 | INLINE_INFO = YES 400 | 401 | # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 402 | # will sort the (detailed) documentation of file and class members 403 | # alphabetically by member name. If set to NO the members will appear in 404 | # declaration order. 405 | 406 | SORT_MEMBER_DOCS = YES 407 | 408 | # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 409 | # brief documentation of file, namespace and class members alphabetically 410 | # by member name. If set to NO (the default) the members will appear in 411 | # declaration order. 412 | 413 | SORT_BRIEF_DOCS = NO 414 | 415 | # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 416 | # will sort the (brief and detailed) documentation of class members so that 417 | # constructors and destructors are listed first. If set to NO (the default) 418 | # the constructors will appear in the respective orders defined by 419 | # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 420 | # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 421 | # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. 422 | 423 | SORT_MEMBERS_CTORS_1ST = NO 424 | 425 | # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 426 | # hierarchy of group names into alphabetical order. If set to NO (the default) 427 | # the group names will appear in their defined order. 428 | 429 | SORT_GROUP_NAMES = NO 430 | 431 | # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 432 | # sorted by fully-qualified names, including namespaces. If set to 433 | # NO (the default), the class list will be sorted only by class name, 434 | # not including the namespace part. 435 | # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 436 | # Note: This option applies only to the class list, not to the 437 | # alphabetical list. 438 | 439 | SORT_BY_SCOPE_NAME = NO 440 | 441 | # The GENERATE_TODOLIST tag can be used to enable (YES) or 442 | # disable (NO) the todo list. This list is created by putting \todo 443 | # commands in the documentation. 444 | 445 | GENERATE_TODOLIST = YES 446 | 447 | # The GENERATE_TESTLIST tag can be used to enable (YES) or 448 | # disable (NO) the test list. This list is created by putting \test 449 | # commands in the documentation. 450 | 451 | GENERATE_TESTLIST = YES 452 | 453 | # The GENERATE_BUGLIST tag can be used to enable (YES) or 454 | # disable (NO) the bug list. This list is created by putting \bug 455 | # commands in the documentation. 456 | 457 | GENERATE_BUGLIST = YES 458 | 459 | # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 460 | # disable (NO) the deprecated list. This list is created by putting 461 | # \deprecated commands in the documentation. 462 | 463 | GENERATE_DEPRECATEDLIST= YES 464 | 465 | # The ENABLED_SECTIONS tag can be used to enable conditional 466 | # documentation sections, marked by \if sectionname ... \endif. 467 | 468 | ENABLED_SECTIONS = 469 | 470 | # The MAX_INITIALIZER_LINES tag determines the maximum number of lines 471 | # the initial value of a variable or define consists of for it to appear in 472 | # the documentation. If the initializer consists of more lines than specified 473 | # here it will be hidden. Use a value of 0 to hide initializers completely. 474 | # The appearance of the initializer of individual variables and defines in the 475 | # documentation can be controlled using \showinitializer or \hideinitializer 476 | # command in the documentation regardless of this setting. 477 | 478 | MAX_INITIALIZER_LINES = 30 479 | 480 | # Set the SHOW_USED_FILES tag to NO to disable the list of files generated 481 | # at the bottom of the documentation of classes and structs. If set to YES the 482 | # list will mention the files that were used to generate the documentation. 483 | 484 | SHOW_USED_FILES = YES 485 | 486 | # If the sources in your project are distributed over multiple directories 487 | # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 488 | # in the documentation. The default is NO. 489 | 490 | SHOW_DIRECTORIES = NO 491 | 492 | # Set the SHOW_FILES tag to NO to disable the generation of the Files page. 493 | # This will remove the Files entry from the Quick Index and from the 494 | # Folder Tree View (if specified). The default is YES. 495 | 496 | SHOW_FILES = YES 497 | 498 | # Set the SHOW_NAMESPACES tag to NO to disable the generation of the 499 | # Namespaces page. 500 | # This will remove the Namespaces entry from the Quick Index 501 | # and from the Folder Tree View (if specified). The default is YES. 502 | 503 | SHOW_NAMESPACES = YES 504 | 505 | # The FILE_VERSION_FILTER tag can be used to specify a program or script that 506 | # doxygen should invoke to get the current version for each file (typically from 507 | # the version control system). Doxygen will invoke the program by executing (via 508 | # popen()) the command , where is the value of 509 | # the FILE_VERSION_FILTER tag, and is the name of an input file 510 | # provided by doxygen. Whatever the program writes to standard output 511 | # is used as the file version. See the manual for examples. 512 | 513 | FILE_VERSION_FILTER = 514 | 515 | # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 516 | # by doxygen. The layout file controls the global structure of the generated 517 | # output files in an output format independent way. The create the layout file 518 | # that represents doxygen's defaults, run doxygen with the -l option. 519 | # You can optionally specify a file name after the option, if omitted 520 | # DoxygenLayout.xml will be used as the name of the layout file. 521 | 522 | LAYOUT_FILE = 523 | 524 | #--------------------------------------------------------------------------- 525 | # configuration options related to warning and progress messages 526 | #--------------------------------------------------------------------------- 527 | 528 | # The QUIET tag can be used to turn on/off the messages that are generated 529 | # by doxygen. Possible values are YES and NO. If left blank NO is used. 530 | 531 | QUIET = NO 532 | 533 | # The WARNINGS tag can be used to turn on/off the warning messages that are 534 | # generated by doxygen. Possible values are YES and NO. If left blank 535 | # NO is used. 536 | 537 | WARNINGS = YES 538 | 539 | # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 540 | # for undocumented members. If EXTRACT_ALL is set to YES then this flag will 541 | # automatically be disabled. 542 | 543 | WARN_IF_UNDOCUMENTED = YES 544 | 545 | # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 546 | # potential errors in the documentation, such as not documenting some 547 | # parameters in a documented function, or documenting parameters that 548 | # don't exist or using markup commands wrongly. 549 | 550 | WARN_IF_DOC_ERROR = YES 551 | 552 | # This WARN_NO_PARAMDOC option can be abled to get warnings for 553 | # functions that are documented, but have no documentation for their parameters 554 | # or return value. If set to NO (the default) doxygen will only warn about 555 | # wrong or incomplete parameter documentation, but not about the absence of 556 | # documentation. 557 | 558 | WARN_NO_PARAMDOC = NO 559 | 560 | # The WARN_FORMAT tag determines the format of the warning messages that 561 | # doxygen can produce. The string should contain the $file, $line, and $text 562 | # tags, which will be replaced by the file and line number from which the 563 | # warning originated and the warning text. Optionally the format may contain 564 | # $version, which will be replaced by the version of the file (if it could 565 | # be obtained via FILE_VERSION_FILTER) 566 | 567 | WARN_FORMAT = "$file:$line: $text" 568 | 569 | # The WARN_LOGFILE tag can be used to specify a file to which warning 570 | # and error messages should be written. If left blank the output is written 571 | # to stderr. 572 | 573 | WARN_LOGFILE = 574 | 575 | #--------------------------------------------------------------------------- 576 | # configuration options related to the input files 577 | #--------------------------------------------------------------------------- 578 | 579 | # The INPUT tag can be used to specify the files and/or directories that contain 580 | # documented source files. You may enter file names like "myfile.cpp" or 581 | # directories like "/usr/src/myproject". Separate the files or directories 582 | # with spaces. 583 | 584 | INPUT = src 585 | 586 | # This tag can be used to specify the character encoding of the source files 587 | # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 588 | # also the default input encoding. Doxygen uses libiconv (or the iconv built 589 | # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 590 | # the list of possible encodings. 591 | 592 | INPUT_ENCODING = UTF-8 593 | 594 | # If the value of the INPUT tag contains directories, you can use the 595 | # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 596 | # and *.h) to filter out the source-files in the directories. If left 597 | # blank the following patterns are tested: 598 | # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 599 | # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 600 | 601 | FILE_PATTERNS = 602 | 603 | # The RECURSIVE tag can be used to turn specify whether or not subdirectories 604 | # should be searched for input files as well. Possible values are YES and NO. 605 | # If left blank NO is used. 606 | 607 | RECURSIVE = YES 608 | 609 | # The EXCLUDE tag can be used to specify files and/or directories that should 610 | # excluded from the INPUT source files. This way you can easily exclude a 611 | # subdirectory from a directory tree whose root is specified with the INPUT tag. 612 | 613 | EXCLUDE = 614 | 615 | # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 616 | # directories that are symbolic links (a Unix filesystem feature) are excluded 617 | # from the input. 618 | 619 | EXCLUDE_SYMLINKS = NO 620 | 621 | # If the value of the INPUT tag contains directories, you can use the 622 | # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 623 | # certain files from those directories. Note that the wildcards are matched 624 | # against the file with absolute path, so to exclude all test directories 625 | # for example use the pattern */test/* 626 | 627 | EXCLUDE_PATTERNS = 628 | 629 | # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 630 | # (namespaces, classes, functions, etc.) that should be excluded from the 631 | # output. The symbol name can be a fully qualified name, a word, or if the 632 | # wildcard * is used, a substring. Examples: ANamespace, AClass, 633 | # AClass::ANamespace, ANamespace::*Test 634 | 635 | EXCLUDE_SYMBOLS = 636 | 637 | # The EXAMPLE_PATH tag can be used to specify one or more files or 638 | # directories that contain example code fragments that are included (see 639 | # the \include command). 640 | 641 | EXAMPLE_PATH = 642 | 643 | # If the value of the EXAMPLE_PATH tag contains directories, you can use the 644 | # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 645 | # and *.h) to filter out the source-files in the directories. If left 646 | # blank all files are included. 647 | 648 | EXAMPLE_PATTERNS = 649 | 650 | # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 651 | # searched for input files to be used with the \include or \dontinclude 652 | # commands irrespective of the value of the RECURSIVE tag. 653 | # Possible values are YES and NO. If left blank NO is used. 654 | 655 | EXAMPLE_RECURSIVE = NO 656 | 657 | # The IMAGE_PATH tag can be used to specify one or more files or 658 | # directories that contain image that are included in the documentation (see 659 | # the \image command). 660 | 661 | IMAGE_PATH = 662 | 663 | # The INPUT_FILTER tag can be used to specify a program that doxygen should 664 | # invoke to filter for each input file. Doxygen will invoke the filter program 665 | # by executing (via popen()) the command , where 666 | # is the value of the INPUT_FILTER tag, and is the name of an 667 | # input file. Doxygen will then use the output that the filter program writes 668 | # to standard output. 669 | # If FILTER_PATTERNS is specified, this tag will be 670 | # ignored. 671 | 672 | INPUT_FILTER = 673 | 674 | # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 675 | # basis. 676 | # Doxygen will compare the file name with each pattern and apply the 677 | # filter if there is a match. 678 | # The filters are a list of the form: 679 | # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 680 | # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 681 | # is applied to all files. 682 | 683 | FILTER_PATTERNS = 684 | 685 | # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 686 | # INPUT_FILTER) will be used to filter the input files when producing source 687 | # files to browse (i.e. when SOURCE_BROWSER is set to YES). 688 | 689 | FILTER_SOURCE_FILES = NO 690 | 691 | #--------------------------------------------------------------------------- 692 | # configuration options related to source browsing 693 | #--------------------------------------------------------------------------- 694 | 695 | # If the SOURCE_BROWSER tag is set to YES then a list of source files will 696 | # be generated. Documented entities will be cross-referenced with these sources. 697 | # Note: To get rid of all source code in the generated output, make sure also 698 | # VERBATIM_HEADERS is set to NO. 699 | 700 | SOURCE_BROWSER = NO 701 | 702 | # Setting the INLINE_SOURCES tag to YES will include the body 703 | # of functions and classes directly in the documentation. 704 | 705 | INLINE_SOURCES = NO 706 | 707 | # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 708 | # doxygen to hide any special comment blocks from generated source code 709 | # fragments. Normal C and C++ comments will always remain visible. 710 | 711 | STRIP_CODE_COMMENTS = YES 712 | 713 | # If the REFERENCED_BY_RELATION tag is set to YES 714 | # then for each documented function all documented 715 | # functions referencing it will be listed. 716 | 717 | REFERENCED_BY_RELATION = NO 718 | 719 | # If the REFERENCES_RELATION tag is set to YES 720 | # then for each documented function all documented entities 721 | # called/used by that function will be listed. 722 | 723 | REFERENCES_RELATION = NO 724 | 725 | # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 726 | # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 727 | # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 728 | # link to the source code. 729 | # Otherwise they will link to the documentation. 730 | 731 | REFERENCES_LINK_SOURCE = YES 732 | 733 | # If the USE_HTAGS tag is set to YES then the references to source code 734 | # will point to the HTML generated by the htags(1) tool instead of doxygen 735 | # built-in source browser. The htags tool is part of GNU's global source 736 | # tagging system (see http://www.gnu.org/software/global/global.html). You 737 | # will need version 4.8.6 or higher. 738 | 739 | USE_HTAGS = NO 740 | 741 | # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 742 | # will generate a verbatim copy of the header file for each class for 743 | # which an include is specified. Set to NO to disable this. 744 | 745 | VERBATIM_HEADERS = YES 746 | 747 | #--------------------------------------------------------------------------- 748 | # configuration options related to the alphabetical class index 749 | #--------------------------------------------------------------------------- 750 | 751 | # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 752 | # of all compounds will be generated. Enable this if the project 753 | # contains a lot of classes, structs, unions or interfaces. 754 | 755 | ALPHABETICAL_INDEX = YES 756 | 757 | # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 758 | # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 759 | # in which this list will be split (can be a number in the range [1..20]) 760 | 761 | COLS_IN_ALPHA_INDEX = 5 762 | 763 | # In case all classes in a project start with a common prefix, all 764 | # classes will be put under the same header in the alphabetical index. 765 | # The IGNORE_PREFIX tag can be used to specify one or more prefixes that 766 | # should be ignored while generating the index headers. 767 | 768 | IGNORE_PREFIX = 769 | 770 | #--------------------------------------------------------------------------- 771 | # configuration options related to the HTML output 772 | #--------------------------------------------------------------------------- 773 | 774 | # If the GENERATE_HTML tag is set to YES (the default) Doxygen will 775 | # generate HTML output. 776 | 777 | GENERATE_HTML = YES 778 | 779 | # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 780 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 781 | # put in front of it. If left blank `html' will be used as the default path. 782 | 783 | HTML_OUTPUT = html 784 | 785 | # The HTML_FILE_EXTENSION tag can be used to specify the file extension for 786 | # each generated HTML page (for example: .htm,.php,.asp). If it is left blank 787 | # doxygen will generate files with .html extension. 788 | 789 | HTML_FILE_EXTENSION = .html 790 | 791 | # The HTML_HEADER tag can be used to specify a personal HTML header for 792 | # each generated HTML page. If it is left blank doxygen will generate a 793 | # standard header. 794 | 795 | HTML_HEADER = 796 | 797 | # The HTML_FOOTER tag can be used to specify a personal HTML footer for 798 | # each generated HTML page. If it is left blank doxygen will generate a 799 | # standard footer. 800 | 801 | HTML_FOOTER = 802 | 803 | # The HTML_STYLESHEET tag can be used to specify a user-defined cascading 804 | # style sheet that is used by each HTML page. It can be used to 805 | # fine-tune the look of the HTML output. If the tag is left blank doxygen 806 | # will generate a default style sheet. Note that doxygen will try to copy 807 | # the style sheet file to the HTML output directory, so don't put your own 808 | # stylesheet in the HTML output directory as well, or it will be erased! 809 | 810 | HTML_STYLESHEET = 811 | 812 | # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 813 | # Doxygen will adjust the colors in the stylesheet and background images 814 | # according to this color. Hue is specified as an angle on a colorwheel, 815 | # see http://en.wikipedia.org/wiki/Hue for more information. 816 | # For instance the value 0 represents red, 60 is yellow, 120 is green, 817 | # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 818 | # The allowed range is 0 to 359. 819 | 820 | HTML_COLORSTYLE_HUE = 220 821 | 822 | # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 823 | # the colors in the HTML output. For a value of 0 the output will use 824 | # grayscales only. A value of 255 will produce the most vivid colors. 825 | 826 | HTML_COLORSTYLE_SAT = 100 827 | 828 | # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 829 | # the luminance component of the colors in the HTML output. Values below 830 | # 100 gradually make the output lighter, whereas values above 100 make 831 | # the output darker. The value divided by 100 is the actual gamma applied, 832 | # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 833 | # and 100 does not change the gamma. 834 | 835 | HTML_COLORSTYLE_GAMMA = 80 836 | 837 | # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 838 | # page will contain the date and time when the page was generated. Setting 839 | # this to NO can help when comparing the output of multiple runs. 840 | 841 | HTML_TIMESTAMP = YES 842 | 843 | # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 844 | # files or namespaces will be aligned in HTML using tables. If set to 845 | # NO a bullet list will be used. 846 | 847 | HTML_ALIGN_MEMBERS = YES 848 | 849 | # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 850 | # documentation will contain sections that can be hidden and shown after the 851 | # page has loaded. For this to work a browser that supports 852 | # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 853 | # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). 854 | 855 | HTML_DYNAMIC_SECTIONS = NO 856 | 857 | # If the GENERATE_DOCSET tag is set to YES, additional index files 858 | # will be generated that can be used as input for Apple's Xcode 3 859 | # integrated development environment, introduced with OSX 10.5 (Leopard). 860 | # To create a documentation set, doxygen will generate a Makefile in the 861 | # HTML output directory. Running make will produce the docset in that 862 | # directory and running "make install" will install the docset in 863 | # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 864 | # it at startup. 865 | # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 866 | # for more information. 867 | 868 | GENERATE_DOCSET = NO 869 | 870 | # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 871 | # feed. A documentation feed provides an umbrella under which multiple 872 | # documentation sets from a single provider (such as a company or product suite) 873 | # can be grouped. 874 | 875 | DOCSET_FEEDNAME = "Doxygen generated docs" 876 | 877 | # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 878 | # should uniquely identify the documentation set bundle. This should be a 879 | # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 880 | # will append .docset to the name. 881 | 882 | DOCSET_BUNDLE_ID = org.doxygen.Project 883 | 884 | # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 885 | # the documentation publisher. This should be a reverse domain-name style 886 | # string, e.g. com.mycompany.MyDocSet.documentation. 887 | 888 | DOCSET_PUBLISHER_ID = org.doxygen.Publisher 889 | 890 | # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. 891 | 892 | DOCSET_PUBLISHER_NAME = Publisher 893 | 894 | # If the GENERATE_HTMLHELP tag is set to YES, additional index files 895 | # will be generated that can be used as input for tools like the 896 | # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 897 | # of the generated HTML documentation. 898 | 899 | GENERATE_HTMLHELP = NO 900 | 901 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 902 | # be used to specify the file name of the resulting .chm file. You 903 | # can add a path in front of the file if the result should not be 904 | # written to the html output directory. 905 | 906 | CHM_FILE = 907 | 908 | # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 909 | # be used to specify the location (absolute path including file name) of 910 | # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 911 | # the HTML help compiler on the generated index.hhp. 912 | 913 | HHC_LOCATION = 914 | 915 | # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 916 | # controls if a separate .chi index file is generated (YES) or that 917 | # it should be included in the master .chm file (NO). 918 | 919 | GENERATE_CHI = NO 920 | 921 | # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 922 | # is used to encode HtmlHelp index (hhk), content (hhc) and project file 923 | # content. 924 | 925 | CHM_INDEX_ENCODING = 926 | 927 | # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 928 | # controls whether a binary table of contents is generated (YES) or a 929 | # normal table of contents (NO) in the .chm file. 930 | 931 | BINARY_TOC = NO 932 | 933 | # The TOC_EXPAND flag can be set to YES to add extra items for group members 934 | # to the contents of the HTML help documentation and to the tree view. 935 | 936 | TOC_EXPAND = NO 937 | 938 | # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 939 | # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 940 | # that can be used as input for Qt's qhelpgenerator to generate a 941 | # Qt Compressed Help (.qch) of the generated HTML documentation. 942 | 943 | GENERATE_QHP = NO 944 | 945 | # If the QHG_LOCATION tag is specified, the QCH_FILE tag can 946 | # be used to specify the file name of the resulting .qch file. 947 | # The path specified is relative to the HTML output folder. 948 | 949 | QCH_FILE = 950 | 951 | # The QHP_NAMESPACE tag specifies the namespace to use when generating 952 | # Qt Help Project output. For more information please see 953 | # http://doc.trolltech.com/qthelpproject.html#namespace 954 | 955 | QHP_NAMESPACE = org.doxygen.Project 956 | 957 | # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 958 | # Qt Help Project output. For more information please see 959 | # http://doc.trolltech.com/qthelpproject.html#virtual-folders 960 | 961 | QHP_VIRTUAL_FOLDER = doc 962 | 963 | # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 964 | # add. For more information please see 965 | # http://doc.trolltech.com/qthelpproject.html#custom-filters 966 | 967 | QHP_CUST_FILTER_NAME = 968 | 969 | # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 970 | # custom filter to add. For more information please see 971 | # 972 | # Qt Help Project / Custom Filters. 973 | 974 | QHP_CUST_FILTER_ATTRS = 975 | 976 | # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 977 | # project's 978 | # filter section matches. 979 | # 980 | # Qt Help Project / Filter Attributes. 981 | 982 | QHP_SECT_FILTER_ATTRS = 983 | 984 | # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 985 | # be used to specify the location of Qt's qhelpgenerator. 986 | # If non-empty doxygen will try to run qhelpgenerator on the generated 987 | # .qhp file. 988 | 989 | QHG_LOCATION = 990 | 991 | # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files 992 | # will be generated, which together with the HTML files, form an Eclipse help 993 | # plugin. To install this plugin and make it available under the help contents 994 | # menu in Eclipse, the contents of the directory containing the HTML and XML 995 | # files needs to be copied into the plugins directory of eclipse. The name of 996 | # the directory within the plugins directory should be the same as 997 | # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 998 | # the help appears. 999 | 1000 | GENERATE_ECLIPSEHELP = NO 1001 | 1002 | # A unique identifier for the eclipse help plugin. When installing the plugin 1003 | # the directory name containing the HTML and XML files should also have 1004 | # this name. 1005 | 1006 | ECLIPSE_DOC_ID = org.doxygen.Project 1007 | 1008 | # The DISABLE_INDEX tag can be used to turn on/off the condensed index at 1009 | # top of each HTML page. The value NO (the default) enables the index and 1010 | # the value YES disables it. 1011 | 1012 | DISABLE_INDEX = NO 1013 | 1014 | # This tag can be used to set the number of enum values (range [1..20]) 1015 | # that doxygen will group on one line in the generated HTML documentation. 1016 | 1017 | ENUM_VALUES_PER_LINE = 4 1018 | 1019 | # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 1020 | # structure should be generated to display hierarchical information. 1021 | # If the tag value is set to YES, a side panel will be generated 1022 | # containing a tree-like index structure (just like the one that 1023 | # is generated for HTML Help). For this to work a browser that supports 1024 | # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 1025 | # Windows users are probably better off using the HTML help feature. 1026 | 1027 | GENERATE_TREEVIEW = NO 1028 | 1029 | # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 1030 | # and Class Hierarchy pages using a tree view instead of an ordered list. 1031 | 1032 | USE_INLINE_TREES = NO 1033 | 1034 | # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 1035 | # used to set the initial width (in pixels) of the frame in which the tree 1036 | # is shown. 1037 | 1038 | TREEVIEW_WIDTH = 250 1039 | 1040 | # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 1041 | # links to external symbols imported via tag files in a separate window. 1042 | 1043 | EXT_LINKS_IN_WINDOW = NO 1044 | 1045 | # Use this tag to change the font size of Latex formulas included 1046 | # as images in the HTML documentation. The default is 10. Note that 1047 | # when you change the font size after a successful doxygen run you need 1048 | # to manually remove any form_*.png images from the HTML output directory 1049 | # to force them to be regenerated. 1050 | 1051 | FORMULA_FONTSIZE = 10 1052 | 1053 | # Use the FORMULA_TRANPARENT tag to determine whether or not the images 1054 | # generated for formulas are transparent PNGs. Transparent PNGs are 1055 | # not supported properly for IE 6.0, but are supported on all modern browsers. 1056 | # Note that when changing this option you need to delete any form_*.png files 1057 | # in the HTML output before the changes have effect. 1058 | 1059 | FORMULA_TRANSPARENT = YES 1060 | 1061 | # When the SEARCHENGINE tag is enabled doxygen will generate a search box 1062 | # for the HTML output. The underlying search engine uses javascript 1063 | # and DHTML and should work on any modern browser. Note that when using 1064 | # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 1065 | # (GENERATE_DOCSET) there is already a search function so this one should 1066 | # typically be disabled. For large projects the javascript based search engine 1067 | # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. 1068 | 1069 | SEARCHENGINE = YES 1070 | 1071 | # When the SERVER_BASED_SEARCH tag is enabled the search engine will be 1072 | # implemented using a PHP enabled web server instead of at the web client 1073 | # using Javascript. Doxygen will generate the search PHP script and index 1074 | # file to put on the web server. The advantage of the server 1075 | # based approach is that it scales better to large projects and allows 1076 | # full text search. The disadvances is that it is more difficult to setup 1077 | # and does not have live searching capabilities. 1078 | 1079 | SERVER_BASED_SEARCH = NO 1080 | 1081 | #--------------------------------------------------------------------------- 1082 | # configuration options related to the LaTeX output 1083 | #--------------------------------------------------------------------------- 1084 | 1085 | # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 1086 | # generate Latex output. 1087 | 1088 | GENERATE_LATEX = YES 1089 | 1090 | # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 1091 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1092 | # put in front of it. If left blank `latex' will be used as the default path. 1093 | 1094 | LATEX_OUTPUT = latex 1095 | 1096 | # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 1097 | # invoked. If left blank `latex' will be used as the default command name. 1098 | # Note that when enabling USE_PDFLATEX this option is only used for 1099 | # generating bitmaps for formulas in the HTML output, but not in the 1100 | # Makefile that is written to the output directory. 1101 | 1102 | LATEX_CMD_NAME = latex 1103 | 1104 | # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 1105 | # generate index for LaTeX. If left blank `makeindex' will be used as the 1106 | # default command name. 1107 | 1108 | MAKEINDEX_CMD_NAME = makeindex 1109 | 1110 | # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 1111 | # LaTeX documents. This may be useful for small projects and may help to 1112 | # save some trees in general. 1113 | 1114 | COMPACT_LATEX = NO 1115 | 1116 | # The PAPER_TYPE tag can be used to set the paper type that is used 1117 | # by the printer. Possible values are: a4, a4wide, letter, legal and 1118 | # executive. If left blank a4wide will be used. 1119 | 1120 | PAPER_TYPE = a4wide 1121 | 1122 | # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 1123 | # packages that should be included in the LaTeX output. 1124 | 1125 | EXTRA_PACKAGES = 1126 | 1127 | # The LATEX_HEADER tag can be used to specify a personal LaTeX header for 1128 | # the generated latex document. The header should contain everything until 1129 | # the first chapter. If it is left blank doxygen will generate a 1130 | # standard header. Notice: only use this tag if you know what you are doing! 1131 | 1132 | LATEX_HEADER = 1133 | 1134 | # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 1135 | # is prepared for conversion to pdf (using ps2pdf). The pdf file will 1136 | # contain links (just like the HTML output) instead of page references 1137 | # This makes the output suitable for online browsing using a pdf viewer. 1138 | 1139 | PDF_HYPERLINKS = YES 1140 | 1141 | # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 1142 | # plain latex in the generated Makefile. Set this option to YES to get a 1143 | # higher quality PDF documentation. 1144 | 1145 | USE_PDFLATEX = NO 1146 | 1147 | # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 1148 | # command to the generated LaTeX files. This will instruct LaTeX to keep 1149 | # running if errors occur, instead of asking the user for help. 1150 | # This option is also used when generating formulas in HTML. 1151 | 1152 | LATEX_BATCHMODE = NO 1153 | 1154 | # If LATEX_HIDE_INDICES is set to YES then doxygen will not 1155 | # include the index chapters (such as File Index, Compound Index, etc.) 1156 | # in the output. 1157 | 1158 | LATEX_HIDE_INDICES = NO 1159 | 1160 | # If LATEX_SOURCE_CODE is set to YES then doxygen will include 1161 | # source code with syntax highlighting in the LaTeX output. 1162 | # Note that which sources are shown also depends on other settings 1163 | # such as SOURCE_BROWSER. 1164 | 1165 | LATEX_SOURCE_CODE = NO 1166 | 1167 | #--------------------------------------------------------------------------- 1168 | # configuration options related to the RTF output 1169 | #--------------------------------------------------------------------------- 1170 | 1171 | # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 1172 | # The RTF output is optimized for Word 97 and may not look very pretty with 1173 | # other RTF readers or editors. 1174 | 1175 | GENERATE_RTF = NO 1176 | 1177 | # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 1178 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1179 | # put in front of it. If left blank `rtf' will be used as the default path. 1180 | 1181 | RTF_OUTPUT = rtf 1182 | 1183 | # If the COMPACT_RTF tag is set to YES Doxygen generates more compact 1184 | # RTF documents. This may be useful for small projects and may help to 1185 | # save some trees in general. 1186 | 1187 | COMPACT_RTF = NO 1188 | 1189 | # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 1190 | # will contain hyperlink fields. The RTF file will 1191 | # contain links (just like the HTML output) instead of page references. 1192 | # This makes the output suitable for online browsing using WORD or other 1193 | # programs which support those fields. 1194 | # Note: wordpad (write) and others do not support links. 1195 | 1196 | RTF_HYPERLINKS = NO 1197 | 1198 | # Load stylesheet definitions from file. Syntax is similar to doxygen's 1199 | # config file, i.e. a series of assignments. You only have to provide 1200 | # replacements, missing definitions are set to their default value. 1201 | 1202 | RTF_STYLESHEET_FILE = 1203 | 1204 | # Set optional variables used in the generation of an rtf document. 1205 | # Syntax is similar to doxygen's config file. 1206 | 1207 | RTF_EXTENSIONS_FILE = 1208 | 1209 | #--------------------------------------------------------------------------- 1210 | # configuration options related to the man page output 1211 | #--------------------------------------------------------------------------- 1212 | 1213 | # If the GENERATE_MAN tag is set to YES (the default) Doxygen will 1214 | # generate man pages 1215 | 1216 | GENERATE_MAN = NO 1217 | 1218 | # The MAN_OUTPUT tag is used to specify where the man pages will be put. 1219 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1220 | # put in front of it. If left blank `man' will be used as the default path. 1221 | 1222 | MAN_OUTPUT = man 1223 | 1224 | # The MAN_EXTENSION tag determines the extension that is added to 1225 | # the generated man pages (default is the subroutine's section .3) 1226 | 1227 | MAN_EXTENSION = .3 1228 | 1229 | # If the MAN_LINKS tag is set to YES and Doxygen generates man output, 1230 | # then it will generate one additional man file for each entity 1231 | # documented in the real man page(s). These additional files 1232 | # only source the real man page, but without them the man command 1233 | # would be unable to find the correct page. The default is NO. 1234 | 1235 | MAN_LINKS = NO 1236 | 1237 | #--------------------------------------------------------------------------- 1238 | # configuration options related to the XML output 1239 | #--------------------------------------------------------------------------- 1240 | 1241 | # If the GENERATE_XML tag is set to YES Doxygen will 1242 | # generate an XML file that captures the structure of 1243 | # the code including all documentation. 1244 | 1245 | GENERATE_XML = NO 1246 | 1247 | # The XML_OUTPUT tag is used to specify where the XML pages will be put. 1248 | # If a relative path is entered the value of OUTPUT_DIRECTORY will be 1249 | # put in front of it. If left blank `xml' will be used as the default path. 1250 | 1251 | XML_OUTPUT = xml 1252 | 1253 | # The XML_SCHEMA tag can be used to specify an XML schema, 1254 | # which can be used by a validating XML parser to check the 1255 | # syntax of the XML files. 1256 | 1257 | XML_SCHEMA = 1258 | 1259 | # The XML_DTD tag can be used to specify an XML DTD, 1260 | # which can be used by a validating XML parser to check the 1261 | # syntax of the XML files. 1262 | 1263 | XML_DTD = 1264 | 1265 | # If the XML_PROGRAMLISTING tag is set to YES Doxygen will 1266 | # dump the program listings (including syntax highlighting 1267 | # and cross-referencing information) to the XML output. Note that 1268 | # enabling this will significantly increase the size of the XML output. 1269 | 1270 | XML_PROGRAMLISTING = YES 1271 | 1272 | #--------------------------------------------------------------------------- 1273 | # configuration options for the AutoGen Definitions output 1274 | #--------------------------------------------------------------------------- 1275 | 1276 | # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 1277 | # generate an AutoGen Definitions (see autogen.sf.net) file 1278 | # that captures the structure of the code including all 1279 | # documentation. Note that this feature is still experimental 1280 | # and incomplete at the moment. 1281 | 1282 | GENERATE_AUTOGEN_DEF = NO 1283 | 1284 | #--------------------------------------------------------------------------- 1285 | # configuration options related to the Perl module output 1286 | #--------------------------------------------------------------------------- 1287 | 1288 | # If the GENERATE_PERLMOD tag is set to YES Doxygen will 1289 | # generate a Perl module file that captures the structure of 1290 | # the code including all documentation. Note that this 1291 | # feature is still experimental and incomplete at the 1292 | # moment. 1293 | 1294 | GENERATE_PERLMOD = NO 1295 | 1296 | # If the PERLMOD_LATEX tag is set to YES Doxygen will generate 1297 | # the necessary Makefile rules, Perl scripts and LaTeX code to be able 1298 | # to generate PDF and DVI output from the Perl module output. 1299 | 1300 | PERLMOD_LATEX = NO 1301 | 1302 | # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 1303 | # nicely formatted so it can be parsed by a human reader. 1304 | # This is useful 1305 | # if you want to understand what is going on. 1306 | # On the other hand, if this 1307 | # tag is set to NO the size of the Perl module output will be much smaller 1308 | # and Perl will parse it just the same. 1309 | 1310 | PERLMOD_PRETTY = YES 1311 | 1312 | # The names of the make variables in the generated doxyrules.make file 1313 | # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 1314 | # This is useful so different doxyrules.make files included by the same 1315 | # Makefile don't overwrite each other's variables. 1316 | 1317 | PERLMOD_MAKEVAR_PREFIX = 1318 | 1319 | #--------------------------------------------------------------------------- 1320 | # Configuration options related to the preprocessor 1321 | #--------------------------------------------------------------------------- 1322 | 1323 | # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 1324 | # evaluate all C-preprocessor directives found in the sources and include 1325 | # files. 1326 | 1327 | ENABLE_PREPROCESSING = YES 1328 | 1329 | # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 1330 | # names in the source code. If set to NO (the default) only conditional 1331 | # compilation will be performed. Macro expansion can be done in a controlled 1332 | # way by setting EXPAND_ONLY_PREDEF to YES. 1333 | 1334 | MACRO_EXPANSION = NO 1335 | 1336 | # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 1337 | # then the macro expansion is limited to the macros specified with the 1338 | # PREDEFINED and EXPAND_AS_DEFINED tags. 1339 | 1340 | EXPAND_ONLY_PREDEF = NO 1341 | 1342 | # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 1343 | # in the INCLUDE_PATH (see below) will be search if a #include is found. 1344 | 1345 | SEARCH_INCLUDES = YES 1346 | 1347 | # The INCLUDE_PATH tag can be used to specify one or more directories that 1348 | # contain include files that are not input files but should be processed by 1349 | # the preprocessor. 1350 | 1351 | INCLUDE_PATH = 1352 | 1353 | # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 1354 | # patterns (like *.h and *.hpp) to filter out the header-files in the 1355 | # directories. If left blank, the patterns specified with FILE_PATTERNS will 1356 | # be used. 1357 | 1358 | INCLUDE_FILE_PATTERNS = 1359 | 1360 | # The PREDEFINED tag can be used to specify one or more macro names that 1361 | # are defined before the preprocessor is started (similar to the -D option of 1362 | # gcc). The argument of the tag is a list of macros of the form: name 1363 | # or name=definition (no spaces). If the definition and the = are 1364 | # omitted =1 is assumed. To prevent a macro definition from being 1365 | # undefined via #undef or recursively expanded use the := operator 1366 | # instead of the = operator. 1367 | 1368 | PREDEFINED = 1369 | 1370 | # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 1371 | # this tag can be used to specify a list of macro names that should be expanded. 1372 | # The macro definition that is found in the sources will be used. 1373 | # Use the PREDEFINED tag if you want to use a different macro definition. 1374 | 1375 | EXPAND_AS_DEFINED = 1376 | 1377 | # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 1378 | # doxygen's preprocessor will remove all function-like macros that are alone 1379 | # on a line, have an all uppercase name, and do not end with a semicolon. Such 1380 | # function macros are typically used for boiler-plate code, and will confuse 1381 | # the parser if not removed. 1382 | 1383 | SKIP_FUNCTION_MACROS = YES 1384 | 1385 | #--------------------------------------------------------------------------- 1386 | # Configuration::additions related to external references 1387 | #--------------------------------------------------------------------------- 1388 | 1389 | # The TAGFILES option can be used to specify one or more tagfiles. 1390 | # Optionally an initial location of the external documentation 1391 | # can be added for each tagfile. The format of a tag file without 1392 | # this location is as follows: 1393 | # 1394 | # TAGFILES = file1 file2 ... 1395 | # Adding location for the tag files is done as follows: 1396 | # 1397 | # TAGFILES = file1=loc1 "file2 = loc2" ... 1398 | # where "loc1" and "loc2" can be relative or absolute paths or 1399 | # URLs. If a location is present for each tag, the installdox tool 1400 | # does not have to be run to correct the links. 1401 | # Note that each tag file must have a unique name 1402 | # (where the name does NOT include the path) 1403 | # If a tag file is not located in the directory in which doxygen 1404 | # is run, you must also specify the path to the tagfile here. 1405 | 1406 | TAGFILES = 1407 | 1408 | # When a file name is specified after GENERATE_TAGFILE, doxygen will create 1409 | # a tag file that is based on the input files it reads. 1410 | 1411 | GENERATE_TAGFILE = 1412 | 1413 | # If the ALLEXTERNALS tag is set to YES all external classes will be listed 1414 | # in the class index. If set to NO only the inherited external classes 1415 | # will be listed. 1416 | 1417 | ALLEXTERNALS = NO 1418 | 1419 | # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 1420 | # in the modules index. If set to NO, only the current project's groups will 1421 | # be listed. 1422 | 1423 | EXTERNAL_GROUPS = YES 1424 | 1425 | # The PERL_PATH should be the absolute path and name of the perl script 1426 | # interpreter (i.e. the result of `which perl'). 1427 | 1428 | PERL_PATH = /usr/bin/perl 1429 | 1430 | #--------------------------------------------------------------------------- 1431 | # Configuration options related to the dot tool 1432 | #--------------------------------------------------------------------------- 1433 | 1434 | # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 1435 | # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 1436 | # or super classes. Setting the tag to NO turns the diagrams off. Note that 1437 | # this option is superseded by the HAVE_DOT option below. This is only a 1438 | # fallback. It is recommended to install and use dot, since it yields more 1439 | # powerful graphs. 1440 | 1441 | CLASS_DIAGRAMS = YES 1442 | 1443 | # You can define message sequence charts within doxygen comments using the \msc 1444 | # command. Doxygen will then run the mscgen tool (see 1445 | # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 1446 | # documentation. The MSCGEN_PATH tag allows you to specify the directory where 1447 | # the mscgen tool resides. If left empty the tool is assumed to be found in the 1448 | # default search path. 1449 | 1450 | MSCGEN_PATH = 1451 | 1452 | # If set to YES, the inheritance and collaboration graphs will hide 1453 | # inheritance and usage relations if the target is undocumented 1454 | # or is not a class. 1455 | 1456 | HIDE_UNDOC_RELATIONS = YES 1457 | 1458 | # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 1459 | # available from the path. This tool is part of Graphviz, a graph visualization 1460 | # toolkit from AT&T and Lucent Bell Labs. The other options in this section 1461 | # have no effect if this option is set to NO (the default) 1462 | 1463 | HAVE_DOT = NO 1464 | 1465 | # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 1466 | # allowed to run in parallel. When set to 0 (the default) doxygen will 1467 | # base this on the number of processors available in the system. You can set it 1468 | # explicitly to a value larger than 0 to get control over the balance 1469 | # between CPU load and processing speed. 1470 | 1471 | DOT_NUM_THREADS = 0 1472 | 1473 | # By default doxygen will write a font called FreeSans.ttf to the output 1474 | # directory and reference it in all dot files that doxygen generates. This 1475 | # font does not include all possible unicode characters however, so when you need 1476 | # these (or just want a differently looking font) you can specify the font name 1477 | # using DOT_FONTNAME. You need need to make sure dot is able to find the font, 1478 | # which can be done by putting it in a standard location or by setting the 1479 | # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 1480 | # containing the font. 1481 | 1482 | DOT_FONTNAME = FreeSans.ttf 1483 | 1484 | # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 1485 | # The default size is 10pt. 1486 | 1487 | DOT_FONTSIZE = 10 1488 | 1489 | # By default doxygen will tell dot to use the output directory to look for the 1490 | # FreeSans.ttf font (which doxygen will put there itself). If you specify a 1491 | # different font using DOT_FONTNAME you can set the path where dot 1492 | # can find it using this tag. 1493 | 1494 | DOT_FONTPATH = 1495 | 1496 | # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 1497 | # will generate a graph for each documented class showing the direct and 1498 | # indirect inheritance relations. Setting this tag to YES will force the 1499 | # the CLASS_DIAGRAMS tag to NO. 1500 | 1501 | CLASS_GRAPH = YES 1502 | 1503 | # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 1504 | # will generate a graph for each documented class showing the direct and 1505 | # indirect implementation dependencies (inheritance, containment, and 1506 | # class references variables) of the class with other documented classes. 1507 | 1508 | COLLABORATION_GRAPH = YES 1509 | 1510 | # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 1511 | # will generate a graph for groups, showing the direct groups dependencies 1512 | 1513 | GROUP_GRAPHS = YES 1514 | 1515 | # If the UML_LOOK tag is set to YES doxygen will generate inheritance and 1516 | # collaboration diagrams in a style similar to the OMG's Unified Modeling 1517 | # Language. 1518 | 1519 | UML_LOOK = NO 1520 | 1521 | # If set to YES, the inheritance and collaboration graphs will show the 1522 | # relations between templates and their instances. 1523 | 1524 | TEMPLATE_RELATIONS = NO 1525 | 1526 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 1527 | # tags are set to YES then doxygen will generate a graph for each documented 1528 | # file showing the direct and indirect include dependencies of the file with 1529 | # other documented files. 1530 | 1531 | INCLUDE_GRAPH = YES 1532 | 1533 | # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 1534 | # HAVE_DOT tags are set to YES then doxygen will generate a graph for each 1535 | # documented header file showing the documented files that directly or 1536 | # indirectly include this file. 1537 | 1538 | INCLUDED_BY_GRAPH = YES 1539 | 1540 | # If the CALL_GRAPH and HAVE_DOT options are set to YES then 1541 | # doxygen will generate a call dependency graph for every global function 1542 | # or class method. Note that enabling this option will significantly increase 1543 | # the time of a run. So in most cases it will be better to enable call graphs 1544 | # for selected functions only using the \callgraph command. 1545 | 1546 | CALL_GRAPH = NO 1547 | 1548 | # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 1549 | # doxygen will generate a caller dependency graph for every global function 1550 | # or class method. Note that enabling this option will significantly increase 1551 | # the time of a run. So in most cases it will be better to enable caller 1552 | # graphs for selected functions only using the \callergraph command. 1553 | 1554 | CALLER_GRAPH = NO 1555 | 1556 | # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 1557 | # will graphical hierarchy of all classes instead of a textual one. 1558 | 1559 | GRAPHICAL_HIERARCHY = YES 1560 | 1561 | # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 1562 | # then doxygen will show the dependencies a directory has on other directories 1563 | # in a graphical way. The dependency relations are determined by the #include 1564 | # relations between the files in the directories. 1565 | 1566 | DIRECTORY_GRAPH = YES 1567 | 1568 | # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 1569 | # generated by dot. Possible values are png, jpg, or gif 1570 | # If left blank png will be used. 1571 | 1572 | DOT_IMAGE_FORMAT = png 1573 | 1574 | # The tag DOT_PATH can be used to specify the path where the dot tool can be 1575 | # found. If left blank, it is assumed the dot tool can be found in the path. 1576 | 1577 | DOT_PATH = 1578 | 1579 | # The DOTFILE_DIRS tag can be used to specify one or more directories that 1580 | # contain dot files that are included in the documentation (see the 1581 | # \dotfile command). 1582 | 1583 | DOTFILE_DIRS = 1584 | 1585 | # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 1586 | # nodes that will be shown in the graph. If the number of nodes in a graph 1587 | # becomes larger than this value, doxygen will truncate the graph, which is 1588 | # visualized by representing a node as a red box. Note that doxygen if the 1589 | # number of direct children of the root node in a graph is already larger than 1590 | # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 1591 | # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. 1592 | 1593 | DOT_GRAPH_MAX_NODES = 50 1594 | 1595 | # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 1596 | # graphs generated by dot. A depth value of 3 means that only nodes reachable 1597 | # from the root by following a path via at most 3 edges will be shown. Nodes 1598 | # that lay further from the root node will be omitted. Note that setting this 1599 | # option to 1 or 2 may greatly reduce the computation time needed for large 1600 | # code bases. Also note that the size of a graph can be further restricted by 1601 | # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. 1602 | 1603 | MAX_DOT_GRAPH_DEPTH = 0 1604 | 1605 | # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 1606 | # background. This is disabled by default, because dot on Windows does not 1607 | # seem to support this out of the box. Warning: Depending on the platform used, 1608 | # enabling this option may lead to badly anti-aliased labels on the edges of 1609 | # a graph (i.e. they become hard to read). 1610 | 1611 | DOT_TRANSPARENT = NO 1612 | 1613 | # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 1614 | # files in one run (i.e. multiple -o and -T options on the command line). This 1615 | # makes dot run faster, but since only newer versions of dot (>1.8.10) 1616 | # support this, this feature is disabled by default. 1617 | 1618 | DOT_MULTI_TARGETS = NO 1619 | 1620 | # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 1621 | # generate a legend page explaining the meaning of the various boxes and 1622 | # arrows in the dot generated graphs. 1623 | 1624 | GENERATE_LEGEND = YES 1625 | 1626 | # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 1627 | # remove the intermediate dot files that are used to generate 1628 | # the various graphs. 1629 | 1630 | DOT_CLEANUP = YES 1631 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ############################################### 2 | #Copyright 2010 Nathan Eloe 3 | # 4 | #This file is part of libbash. 5 | # 6 | #libbash is free software: you can redistribute it and/or modify 7 | #it under the terms of the GNU General Public License as published by 8 | #the Free Software Foundation, either version 2 of the License, or 9 | #(at your option) any later version. 10 | # 11 | #libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | #GNU General Public License for more details. 14 | # 15 | #You should have received a copy of the GNU General Public License 16 | #along with libbash. If not, see . 17 | ############################################### 18 | # Makefile.am for libbash 19 | # Author: Nathan Eloe 20 | ############################################### 21 | include doxygen.am 22 | 23 | ACLOCAL_AMFLAGS = -I m4 24 | 25 | TESTS = bashast/gunit/runtests.sh 26 | TEST_EXTENSIONS= .sh 27 | SH_LOG_COMPILER = /bin/bash 28 | 29 | if HAVE_GTEST 30 | TESTS += builtin_unittests 31 | check_PROGRAMS = builtin_unittests 32 | builtin_unittests_SOURCES = src/builtins/tests/run_tests.cpp 33 | builtin_unittests_SOURCES += src/builtins/tests/echo_tests.cpp 34 | builtin_unittests_LDADD = ${GTEST_LIBS} libcppbash.la 35 | endif 36 | 37 | AM_CXXFLAGS=-std=c++0x 38 | 39 | lib_LTLIBRARIES = libcppbash.la 40 | libcppbash_la_SOURCES = src/cppbash_builtin.cpp 41 | libcppbash_la_SOURCES += src/builtins/echo_builtin.cpp 42 | libcppbash_la_CPPFLAGS = $(BOOST_CPPFLAGS) 43 | 44 | coding_standard.pdf: coding_standard/coding_standard.tex 45 | @PDFLATEX@ coding_standard/coding_standard.tex 2&>1 > /dev/null 46 | 47 | grammar.run: bashast.g 48 | @JAVA@ -classpath @antlr_cp@ -Xmx1024m org.antlr.Tool -Xconversiontimeout 20000 $< 49 | touch $@ 50 | 51 | bashast.g: bashast/bashast.g 52 | sed -e 's/CommonTree/pANTLR3_BASE_TREE/g' -e 's/Java/C/g' $< > $@ 53 | 54 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ############################################# 2 | #Copyright 2010 Nathan Eloe 3 | # 4 | #This file is part of libbash. 5 | # 6 | #libbash is free software: you can redistribute it and/or modify 7 | #it under the terms of the GNU General Public License as published by 8 | #the Free Software Foundation, either version 2 of the License, or 9 | #(at your option) any later version. 10 | # 11 | #libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | #GNU General Public License for more details. 14 | # 15 | #You should have received a copy of the GNU General Public License 16 | #along with libbash. If not, see . 17 | ############################################### 18 | 19 | This is the README file for libbash 20 | 21 | Directory information: 22 | bashast/: Grammar file 23 | bashast/gunit: Grammar gunit tests 24 | src/: source directory for libbash library 25 | src/builtins: source directory for built in bash functionality classes 26 | src/builtins/tests: Unit tests for builtins 27 | coding_standard/: LaTeX coding standard for the project 28 | docs/: output folder for Doxygen generated documentation 29 | 30 | Build Instructions: 31 | 32 | ./autogen.sh 33 | 34 | This will run ./configure for you so you are ready to build the thing. 35 | Now you can run make check to build the library and run tests. Other 36 | available targets: 37 | 38 | To build ANTLR C runtime libraries from grammar: 39 | make grammar.run 40 | To generate the coding standard from the latex file (with pdflatex): 41 | make coding_standard.pdf 42 | To generate the doxygen documentation: 43 | make doxygen-doc 44 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf -W all -i && ./configure --enable-gtest 3 | -------------------------------------------------------------------------------- /bashast/bashast.g: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with libbash. If not, see . 18 | **/ 19 | grammar bashast; 20 | options 21 | { 22 | backtrack = true; 23 | output = AST; 24 | language = Java; 25 | ASTLabelType = CommonTree; 26 | } 27 | tokens{ 28 | ARG; 29 | ARRAY; 30 | BRACE; 31 | BRACE_EXP; 32 | COMMAND_SUB; 33 | CASE_PATTERN; 34 | SUBSHELL; 35 | CURRSHELL; 36 | COMPOUND_ARITH; 37 | COMPOUND_COND; 38 | FOR_INIT; 39 | FOR_COND; 40 | FOR_MOD; 41 | FNAME; 42 | OFFSET; 43 | LIST_EXPAND; 44 | OP; 45 | PRE_INCR; 46 | PRE_DECR; 47 | POST_INCR; 48 | POST_DECR; 49 | PROC_SUB; 50 | VAR_REF; 51 | NEGATION; 52 | LIST; 53 | REPLACE_FIRST; 54 | REPLACE_ALL; 55 | STRING; 56 | COMMAND; 57 | REPLACE_FIRST; 58 | REPLACE_LAST; 59 | FILE_DESCRIPTOR; 60 | FILE_DESCRIPTOR_MOVE; 61 | REDIR; 62 | ARITHMETIC_CONDITION; 63 | KEYWORD_TEST; 64 | BUILTIN_TEST; 65 | MATCH_ANY_EXCEPT; 66 | MATCH_EXACTLY_ONE; 67 | MATCH_AT_MOST_ONE; 68 | MATCH_NONE; 69 | MATCH_ANY; 70 | MATCH_AT_LEAST_ONE; 71 | MATCH_PATTERN; 72 | MATCH_ANY_EXCEPT; 73 | CHARACTER_CLASS; 74 | EQUIVALENCE_CLASS; 75 | COLLATING_SYMBOL; 76 | SINGLE_QUOTED_STRING; 77 | DOUBLE_QUOTED_STRING; 78 | } 79 | 80 | start : (flcomment! EOL!)? EOL!* list^ ; 81 | //Because the comment token doesn't handle the first comment in a file if it's on the first line, have a parser rule for it 82 | flcomment 83 | : BLANK? '#' commentpart*; 84 | commentpart 85 | : nqstr|BLANK|LBRACE|RBRACE|SEMIC|DOUBLE_SEMIC|TICK|LPAREN|RPAREN|LLPAREN|RRPAREN|PIPE|COMMA|SQUOTE|QUOTE|LT|GT; 86 | list : list_level_2 BLANK* (';'|'&'|EOL)? -> ^(LIST list_level_2); 87 | clist 88 | options{greedy=false;} 89 | : list_level_2 -> ^(LIST list_level_2); 90 | list_level_1 91 | : (function|pipeline) (BLANK!*('&&'^|'||'^)BLANK!* (function|pipeline))*; 92 | list_level_2 93 | : list_level_1 ((BLANK!?';'!|BLANK!?'&'^|(BLANK!? EOL!)+)BLANK!? list_level_1)*; 94 | pipeline 95 | : var_def+ 96 | | time?('!' BLANK!*)? BLANK!* command^ (BLANK!* PIPE^ BLANK!* command)*; 97 | time : TIME^ BLANK!+ timearg?; 98 | timearg : '-p' BLANK!+; 99 | //The structure of a command in bash 100 | command 101 | : EXPORT^ var_def+ 102 | | compound_command 103 | | simple_command; 104 | //Simple bash commands 105 | simple_command 106 | : var_def+ bash_command^ redirect* 107 | | bash_command^ redirect*; 108 | bash_command 109 | : fname_no_res_word (BLANK+ arg)* -> ^(COMMAND fname_no_res_word arg*); 110 | //An argument to a command 111 | arg 112 | : brace_expansion 113 | | var_ref 114 | | fname 115 | | res_word_str -> ^(STRING res_word_str) 116 | | command_sub 117 | | var_ref; 118 | redirect: BLANK!* here_string_op^ BLANK!* fname 119 | | BLANK!* here_doc_op^ BLANK!* fname EOL! heredoc 120 | | BLANK* redir_op BLANK* DIGIT MINUS? -> ^(REDIR redir_op DIGIT MINUS?) 121 | | BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest) 122 | | BLANK!* proc_sub; 123 | redir_dest 124 | : fname //path to a file 125 | | file_desc_as_file; //handles file descriptors0 126 | file_desc_as_file 127 | : AMP DIGIT -> FILE_DESCRIPTOR[$DIGIT] 128 | | AMP DIGIT MINUS -> FILE_DESCRIPTOR_MOVE[$DIGIT]; 129 | heredoc : (fname EOL!)*; 130 | here_string_op 131 | : HERE_STRING_OP; 132 | here_doc_op 133 | : LSHIFT MINUS -> OP["<<-"] 134 | | LSHIFT -> OP["<<"]; 135 | redir_op: AMP LT -> OP["&<"] 136 | | GT AMP -> OP[">&"] 137 | | LT AMP -> OP["<&"] 138 | | LT GT -> OP["<>"] 139 | | RSHIFT -> OP[">>"] 140 | | AMP GT -> OP["&>"] 141 | | AMP RSHIFT -> OP ["&>>"] 142 | | LT 143 | | GT 144 | | DIGIT redir_op; 145 | brace_expansion 146 | : pre=fname? brace post=fname? -> ^(BRACE_EXP ($pre)? brace ($post)?); 147 | brace 148 | : LBRACE BLANK* brace_expansion_inside BLANK?RBRACE -> ^(BRACE brace_expansion_inside); 149 | brace_expansion_inside 150 | : commasep|range; 151 | range : DIGIT DOTDOT^ DIGIT 152 | | LETTER DOTDOT^ LETTER; 153 | brace_expansion_part 154 | : fname 155 | | brace 156 | | var_ref 157 | | command_sub; 158 | commasep: brace_expansion_part(COMMA! brace_expansion_part)+; 159 | command_sub 160 | : DOLLAR LPAREN BLANK* pipeline BLANK? RPAREN -> ^(COMMAND_SUB pipeline) 161 | | TICK BLANK* pipeline BLANK? TICK -> ^(COMMAND_SUB pipeline) ; 162 | //compound commands 163 | compound_command 164 | : for_expr 165 | | sel_expr 166 | | if_expr 167 | | while_expr 168 | | until_expr 169 | | case_expr 170 | | subshell 171 | | currshell 172 | | arith_comparison 173 | | cond_comparison; 174 | //Expressions allowed inside a compound command 175 | for_expr: FOR BLANK+ name (wspace IN BLANK+ word)? semiel DO wspace* clist semiel DONE -> ^(FOR name (word)? clist) 176 | | FOR BLANK* LLPAREN EOL? (BLANK* init=arithmetic BLANK*|BLANK+)? (SEMIC (BLANK? fcond=arithmetic BLANK*|BLANK+)? SEMIC|DOUBLE_SEMIC) (BLANK* mod=arithmetic)? wspace* RRPAREN semiel DO wspace clist semiel DONE 177 | -> ^(FOR ^(FOR_INIT $init)? ^(FOR_COND $fcond)? ^(FOR_MOD $mod)? clist) 178 | ; 179 | sel_expr: SELECT BLANK+ name (wspace IN BLANK+ word)? semiel DO wspace* clist semiel DONE -> ^(SELECT name (word)? clist) 180 | ; 181 | if_expr : IF wspace+ ag=clist BLANK* semiel THEN wspace+ iflist=clist BLANK? semiel EOL* (elif_expr)* (ELSE wspace+ else_list=clist BLANK? semiel EOL*)? FI 182 | -> ^(IF $ag $iflist (elif_expr)* ^($else_list)?) 183 | ; 184 | elif_expr 185 | : ELIF BLANK+ ag=clist BLANK* semiel THEN wspace+ iflist=clist BLANK* semiel -> ^(IF["if"] $ag $iflist); 186 | while_expr 187 | : WHILE wspace istrue=clist semiel DO wspace dothis=clist semiel DONE -> ^(WHILE $istrue $dothis) 188 | ; 189 | until_expr 190 | : UNTIL wspace istrue=clist semiel DO wspace dothis=clist semiel DONE -> ^(UNTIL $istrue $dothis) 191 | ; 192 | case_expr 193 | : CASE^ BLANK!+ word wspace! IN! wspace! (case_stmt wspace!)* last_case? ESAC!; 194 | case_stmt 195 | options{greedy=false;} 196 | : wspace* (LPAREN BLANK*)? pattern (BLANK* PIPE BLANK? pattern)* BLANK* RPAREN wspace* clist wspace* DOUBLE_SEMIC 197 | -> ^(CASE_PATTERN pattern+ clist) 198 | | wspace* (LPAREN BLANK*)? pattern (BLANK? PIPE BLANK* pattern)* BLANK* RPAREN wspace* DOUBLE_SEMIC 199 | -> ^(CASE_PATTERN pattern+) 200 | ; 201 | //the last case can have a slightly different structure than the rest; this accounts for that 202 | last_case 203 | options{greedy=false;} 204 | : wspace* (LPAREN BLANK*)? pattern (BLANK* PIPE BLANK? pattern)* BLANK* RPAREN wspace* clist? (wspace* DOUBLE_SEMIC|(BLANK* EOL)+) 205 | -> ^(CASE_PATTERN pattern+ clist?) 206 | ; 207 | //A grouping of commands executed in a subshell 208 | subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(SUBSHELL clist); 209 | //A grouping of commands executed in the current shell 210 | currshell 211 | : LBRACE wspace clist semiel RBRACE -> ^(CURRSHELL clist); 212 | //comparison using arithmetic 213 | arith_comparison 214 | : LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithmetic); 215 | cond_comparison 216 | : cond_expr -> ^(COMPOUND_COND cond_expr); 217 | //Variables 218 | //Defining a variable 219 | var_def : BLANK* name LSQUARE BLANK? index BLANK* RSQUARE EQUALS value BLANK* -> ^(EQUALS ^(name index) value) 220 | | BLANK!* name EQUALS^ value BLANK!* 221 | | BLANK!* LET! name EQUALS^ arithmetic BLANK!*; 222 | //Possible values of a variable 223 | value : num 224 | | var_ref 225 | | fname 226 | | LPAREN! wspace!? arr_val RPAREN!; 227 | //allow the parser to create array variables 228 | arr_val : 229 | | (ag+=val wspace?)+ -> ^(ARRAY $ag+); 230 | val : '['!BLANK!*index BLANK!?']'!EQUALS^ pos_val 231 | | pos_val; 232 | pos_val : command_sub 233 | | var_ref 234 | | num 235 | | fname; 236 | //possible indexes for the variable. Names are used when it acts more like a map/hash than an array 237 | index : num 238 | | name; 239 | //Referencing a variable (different possible ways/special parameters) 240 | var_ref 241 | : DOLLAR LBRACE BLANK* var_exp BLANK* RBRACE -> ^(VAR_REF var_exp) 242 | | DOLLAR name -> ^(VAR_REF name) 243 | | DOLLAR num -> ^(VAR_REF num) 244 | | DOLLAR TIMES -> ^(VAR_REF TIMES) 245 | | DOLLAR AT -> ^(VAR_REF AT) 246 | | DOLLAR POUND -> ^(VAR_REF POUND) 247 | | DOLLAR QMARK -> ^(VAR_REF QMARK) 248 | | DOLLAR MINUS -> ^(VAR_REF MINUS) 249 | | DOLLAR BANG -> ^(VAR_REF BANG) 250 | | DOLLAR '_' -> ^(VAR_REF '_'); 251 | //Variable expansions 252 | var_exp : var_name WORDOP^ word 253 | | var_name COLON os=num (COLON len=num)? -> ^(OFFSET var_name $os ^($len)?) 254 | | BANG^ var_name (TIMES|AT) 255 | | BANG var_name LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name $op) 256 | | POUND^ var_name 257 | | var_name (POUND^|POUNDPOUND^) fname 258 | | var_name (PCT^|PCTPCT^) fname 259 | | var_name SLASH POUND ns_str SLASH fname -> ^(REPLACE_FIRST var_name ns_str fname) 260 | | var_name SLASH PCT ns_str SLASH fname -> ^(REPLACE_LAST var_name ns_str fname) 261 | | var_name SLASH SLASH ns_str SLASH fname -> ^(REPLACE_ALL var_name ns_str fname) 262 | | var_name SLASH SLASH ns_str SLASH? -> ^(REPLACE_ALL var_name ns_str) 263 | | var_name SLASH ns_str SLASH fname -> ^(REPLACE_FIRST var_name ns_str fname) 264 | | var_name SLASH POUND ns_str SLASH? -> ^(REPLACE_FIRST var_name ns_str) 265 | | var_name SLASH PCT ns_str SLASH? -> ^(REPLACE_LAST var_name ns_str) 266 | | var_name SLASH ns_str SLASH? -> ^(REPLACE_FIRST var_name ns_str) 267 | | arr_var_ref 268 | | var_name; 269 | //Allowable variable names in the variable expansion 270 | var_name: num|name|TIMES|AT; 271 | //Referencing an array variable 272 | arr_var_ref 273 | : name^ LSQUARE! DIGIT+ RSQUARE!; 274 | //Conditional Expressions 275 | cond_expr 276 | : LSQUARE LSQUARE wspace keyword_cond wspace RSQUARE RSQUARE -> ^(KEYWORD_TEST keyword_cond) 277 | | LSQUARE wspace builtin_cond wspace RSQUARE -> ^(BUILTIN_TEST builtin_cond) 278 | | TEST wspace builtin_cond-> ^(BUILTIN_TEST builtin_cond); 279 | cond_primary 280 | : LPAREN! BLANK!* keyword_cond BLANK!* RPAREN! 281 | | keyword_cond_binary 282 | | keyword_cond_unary 283 | | fname; 284 | keyword_cond_binary 285 | : cond_part BLANK!* binary_str_op_keyword^ BLANK!? cond_part; 286 | keyword_cond_unary 287 | : UOP^ BLANK!+ cond_part; 288 | builtin_cond_primary 289 | : LPAREN! BLANK!* builtin_cond BLANK!* RPAREN! 290 | | builtin_cond_binary 291 | | builtin_cond_unary 292 | | fname; 293 | builtin_cond_binary 294 | : cond_part BLANK!* binary_string_op_builtin^ BLANK!? cond_part; 295 | builtin_cond_unary 296 | : UOP^ BLANK!+ cond_part; 297 | keyword_cond 298 | : (negate_primary|cond_primary) (BLANK!* (LOGICOR^|LOGICAND^) BLANK!* keyword_cond)?; 299 | builtin_cond 300 | : (negate_builtin_primary|builtin_cond_primary) (BLANK!* (LOGICOR^|LOGICAND^) BLANK!* builtin_cond)?; 301 | negate_primary 302 | : BANG BLANK+ cond_primary -> ^(NEGATION cond_primary); 303 | negate_builtin_primary 304 | : BANG BLANK+ builtin_cond_primary -> ^(NEGATION builtin_cond_primary); 305 | binary_str_op_keyword 306 | : BOP 307 | | EQUALS EQUALS -> OP["=="] 308 | | EQUALS 309 | | BANG EQUALS -> OP["!="] 310 | | LT 311 | | GT; 312 | binary_string_op_builtin 313 | : BOP 314 | | EQUALS 315 | | BANG EQUALS -> OP["!="] 316 | | ESC_LT 317 | | ESC_GT; 318 | unary_cond 319 | : UOP^ BLANK! cond_part; 320 | //Allowable parts of conditions 321 | cond_part: brace_expansion 322 | | var_ref 323 | | res_word_str -> ^(STRING res_word_str) 324 | | num 325 | | fname 326 | | arithmetic; 327 | //Rules for whitespace/line endings 328 | wspace : BLANK+|EOL; 329 | semiel : (';'|EOL) BLANK*; 330 | 331 | //definition of word. this is just going to grow... 332 | word : brace_expansion 333 | | command_sub 334 | | var_ref 335 | | num 336 | | fname 337 | | arithmetic_expansion 338 | | res_word_str -> ^(STRING res_word_str); 339 | pattern : command_sub 340 | | fname 341 | | TIMES; 342 | num 343 | options{k=1;backtrack=false;} 344 | : DIGIT|NUMBER; 345 | //A rule for filenames/strings 346 | res_word_str 347 | : CASE|DO|DONE|ELIF|ELSE|ESAC|FI|FOR|FUNCTION|IF|IN|SELECT|THEN|UNTIL|WHILE|TIME; 348 | //Any allowable part of a string, including slashes, no pounds 349 | str_part 350 | : ns_str_part 351 | | SLASH; 352 | //Any allowable part of a string, with pounds 353 | str_part_with_pound 354 | : str_part 355 | | POUND 356 | | POUNDPOUND; 357 | //Parts of strings, no slashes 358 | ns_str_part 359 | : ns_str_part_no_res 360 | | res_word_str; 361 | //Parts of strings, no slashes, no reserved words 362 | ns_str_part_no_res 363 | : num 364 | | name|NQSTR|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|BOP|UOP|TEST|'_'|TILDE|INC|DEC|ARITH_ASSIGN|ESC_CHAR|CARET; 365 | //strings with no slashes, used in certain variable expansions 366 | ns_str : ns_str_part* -> ^(STRING ns_str_part*); 367 | //Allowable parts of double quoted strings 368 | dq_str_part 369 | : BLANK|EOL|AMP|LOGICAND|LOGICOR|LT|GT|PIPE|SQUOTE|SEMIC|COMMA|LPAREN|RPAREN|LLPAREN|RRPAREN|DOUBLE_SEMIC|LBRACE|RBRACE|TICK|LEQ|GEQ 370 | | str_part_with_pound; 371 | //Allowable parts of single quoted strings 372 | sq_str_part 373 | : str_part_with_pound 374 | | BLANK|EOL|AMP|LOGICAND|LOGICOR|LT|GT|PIPE|QUOTE|SEMIC|COMMA|LPAREN|RPAREN|LLPAREN|RRPAREN|DOUBLE_SEMIC|LBRACE|RBRACE|DOLLAR|TICK|BOP|UOP; 375 | //Generic strings/filenames. 376 | fname : nqstr -> ^(STRING nqstr); 377 | //A string that is NOT a bash reserved word 378 | fname_no_res_word 379 | : nqstr_no_res_word -> ^(STRING nqstr_no_res_word); 380 | //No quoted string, no reserved words 381 | nqstr_no_res_word 382 | : res_word_str (no_res_word_part|str_part_with_pound)+ 383 | | no_res_word_part (no_res_word_part|str_part_with_pound)*; 384 | //parts of strings, not including reserved word parts 385 | no_res_word_part 386 | : bracket_pattern_match 387 | | extended_pattern_match 388 | | var_ref 389 | | command_sub 390 | | arithmetic_expansion 391 | | dqstr 392 | | sqstr 393 | | ns_str_part_no_res 394 | | SLASH 395 | | pattern_match_trigger; 396 | //non-quoted string rule, allows expansions 397 | nqstr : (bracket_pattern_match|extended_pattern_match|var_ref|command_sub|arithmetic_expansion|dqstr|sqstr|(str_part str_part_with_pound*)|pattern_match_trigger|BANG)+; 398 | //double quoted string rule, allows expansions 399 | dqstr : QUOTE dqstr_part* QUOTE -> ^(DOUBLE_QUOTED_STRING dqstr_part*); 400 | dqstr_part 401 | : bracket_pattern_match 402 | | extended_pattern_match 403 | | var_ref 404 | | command_sub 405 | | arithmetic_expansion 406 | | dq_str_part 407 | | pattern_match_trigger 408 | | BANG; 409 | //single quoted string rule, no expansions 410 | sqstr : SQUOTE sq_str_part* SQUOTE -> ^(SINGLE_QUOTED_STRING sq_str_part*); 411 | //certain tokens that trigger pattern matching 412 | pattern_match_trigger 413 | : LSQUARE 414 | | RSQUARE 415 | | QMARK 416 | | PLUS 417 | | TIMES 418 | | AT; 419 | //Pattern matching using brackets 420 | bracket_pattern_match 421 | : LSQUARE RSQUARE (BANG|CARET) pattern_match* RSQUARE -> ^(MATCH_ANY_EXCEPT RSQUARE pattern_match*) 422 | | LSQUARE RSQUARE pattern_match* RSQUARE -> ^(MATCH_PATTERN RSQUARE pattern_match*) 423 | | LSQUARE (BANG|CARET) pattern_match+ RSQUARE -> ^(MATCH_ANY_EXCEPT pattern_match+) 424 | | LSQUARE pattern_match+ RSQUARE -> ^(MATCH_PATTERN pattern_match+); 425 | //allowable patterns with bracket pattern matching 426 | pattern_match 427 | : pattern_class_match 428 | | str_part str_part_with_pound*; 429 | //special class patterns to match: [:alpha:] etc 430 | pattern_class_match 431 | : LSQUARE COLON NAME COLON RSQUARE -> ^(CHARACTER_CLASS NAME) 432 | | LSQUARE EQUALS pattern_char EQUALS RSQUARE -> ^(EQUIVALENCE_CLASS pattern_char) 433 | | LSQUARE DOT NAME DOT RSQUARE -> ^(COLLATING_SYMBOL NAME); 434 | //Characters allowed in matching equivalence classes 435 | pattern_char 436 | : LETTER|DIGIT|NQCHAR_NO_ALPHANUM|QMARK|COLON|AT|SEMIC|POUND|SLASH|BANG|TIMES|COMMA|PIPE|AMP|MINUS|PLUS|PCT|EQUALS|LSQUARE|RSQUARE|RPAREN|LPAREN|RBRACE|LBRACE|DOLLAR|TICK|DOT|LT|GT|SQUOTE|QUOTE; 437 | //extended pattern matching 438 | extended_pattern_match 439 | : QMARK LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_AT_MOST_ONE fname+) 440 | | TIMES LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_ANY fname+) 441 | | PLUS LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_AT_LEAST_ONE fname+) 442 | | AT LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_EXACTLY_ONE fname+) 443 | | BANG LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_NONE fname+); 444 | //Arithmetic expansion 445 | arithmetic_expansion 446 | : DOLLAR! LLPAREN! BLANK!* arithmetic_part BLANK!* RRPAREN!; 447 | arithmetic_part 448 | : arithmetics 449 | | arithmetic; 450 | //The comma operator for arithmetic expansions 451 | arithmetics 452 | : arithmetic (BLANK!* COMMA! BLANK!* arithmetic)*; 453 | arithmetic 454 | : arithmetic_condition 455 | | arithmetic_assignment; 456 | //The base of the arithmetic operator. Used for order of operations 457 | primary : num 458 | | var_ref 459 | | command_sub 460 | | name -> ^(VAR_REF name) 461 | | LPAREN! (arithmetics) RPAREN!; 462 | post_inc_dec 463 | : name BLANK?INC -> ^(POST_INCR name) 464 | | name BLANK?DEC -> ^(POST_DECR name); 465 | pre_inc_dec 466 | : INC BLANK?name -> ^(PRE_INCR name) 467 | | DEC BLANK?name -> ^(PRE_DECR name); 468 | unary : post_inc_dec 469 | | pre_inc_dec 470 | | primary 471 | | PLUS^ primary 472 | | MINUS^ primary; 473 | negation 474 | : (BANG^BLANK!?|TILDE^BLANK!?)?unary; 475 | exponential 476 | : negation (BLANK!* EXP^ BLANK!* negation)* ; 477 | tdm : exponential (BLANK!*(TIMES^|SLASH^|PCT^)BLANK!* exponential)*; 478 | addsub : tdm (BLANK!* (PLUS^|MINUS^)BLANK!* tdm)*; 479 | shifts : addsub (BLANK!* (LSHIFT^|RSHIFT^) BLANK!* addsub)*; 480 | compare : shifts (BLANK!* (LEQ^|GEQ^|LT^|GT^)BLANK!* shifts)?; 481 | bitwiseand 482 | : compare (BLANK!* AMP^ BLANK!* compare)*; 483 | bitwisexor 484 | : bitwiseand (BLANK!* CARET^ BLANK!* bitwiseand)*; 485 | bitwiseor 486 | : bitwisexor (BLANK!* PIPE^ BLANK!* bitwisexor)*; 487 | logicand: bitwiseor (BLANK!* LOGICAND^ BLANK!* bitwiseor)*; 488 | logicor : logicand (BLANK!* LOGICOR^ BLANK!* logicand)*; 489 | 490 | arithmetic_condition 491 | : cnd=logicor QMARK t=logicor COLON f=logicor -> ^(ARITHMETIC_CONDITION $cnd $t $f); 492 | arithmetic_assignment 493 | : (name BLANK!* (EQUALS^|ARITH_ASSIGN^) BLANK!*)? logicor; 494 | //process substitution 495 | proc_sub: (dir=LT|dir=GT)LPAREN BLANK* clist BLANK* RPAREN -> ^(PROC_SUB $dir clist); 496 | //the biggie: functions 497 | function: FUNCTION BLANK+ fname (BLANK* parens)? wspace compound_command redirect* -> ^(FUNCTION fname compound_command redirect*) 498 | | fname BLANK* parens wspace compound_command redirect* -> ^(FUNCTION["function"] fname compound_command redirect*); 499 | parens : LPAREN BLANK* RPAREN; 500 | name : NAME 501 | | LETTER 502 | | '_'; 503 | 504 | //**************** 505 | // TOKENS/LEXER RULES 506 | //**************** 507 | 508 | COMMENT 509 | : (BLANK|EOL) '#' ~('\n'|'\r')* {$channel=HIDDEN;} 510 | ; 511 | //Bash "reserved words" 512 | BANG : '!'; 513 | CASE : 'case'; 514 | DO : 'do'; 515 | DONE : 'done'; 516 | ELIF : 'elif'; 517 | ELSE : 'else'; 518 | ESAC : 'esac'; 519 | FI : 'fi'; 520 | FOR : 'for'; 521 | FUNCTION: 'function'; 522 | IF : 'if'; 523 | IN : 'in'; 524 | SELECT : 'select'; 525 | THEN : 'then'; 526 | UNTIL : 'until'; 527 | WHILE : 'while'; 528 | LBRACE : '{'; 529 | RBRACE : '}'; 530 | TIME : 'time'; 531 | 532 | //Other special useful symbols 533 | RPAREN : ')'; 534 | LPAREN : '('; 535 | LLPAREN : '(('; 536 | RRPAREN : '))'; 537 | LSQUARE : '['; 538 | RSQUARE : ']'; 539 | TICK : '`'; 540 | DOLLAR : '$'; 541 | AT : '@'; 542 | DOT : '.'; 543 | DOTDOT : '..'; 544 | //Arith ops 545 | LET : 'let'; 546 | TIMES : '*'; 547 | EQUALS : '='; 548 | MINUS : '-'; 549 | PLUS : '+'; 550 | INC : '++'; 551 | DEC : '--'; 552 | EXP : '**'; 553 | AMP : '&'; 554 | LEQ : '<='; 555 | GEQ : '>='; 556 | CARET : '^'; 557 | LT : '<'; 558 | GT : '>'; 559 | LSHIFT : '<<'; 560 | RSHIFT : '>>'; 561 | ARITH_ASSIGN 562 | : (TIMES|SLASH|PCT|PLUS|MINUS|LSHIFT|RSHIFT|AMP|CARET|PIPE) EQUALS; 563 | //some separators 564 | SEMIC : ';'; 565 | DOUBLE_SEMIC 566 | : ';;'; 567 | PIPE : '|'; 568 | QUOTE : '"'; 569 | SQUOTE : '\''; 570 | COMMA : ','; 571 | //Because bash isn't exactly whitespace dependent... need to explicitly handle blanks 572 | BLANK : (' '|'\t')+; 573 | EOL : ('\r'?'\n')+ ; 574 | //some fragments for creating words... 575 | DIGIT : '0'..'9'; 576 | NUMBER : DIGIT DIGIT+; 577 | LETTER : ('a'..'z'|'A'..'Z'); 578 | fragment 579 | ALPHANUM: (DIGIT|LETTER); 580 | //Some special redirect operators 581 | TILDE : '~'; 582 | HERE_STRING_OP 583 | : '<<<'; 584 | //Tokens for parameter expansion 585 | POUND : '#'; 586 | POUNDPOUND 587 | : '##'; 588 | PCT : '%'; 589 | PCTPCT : '%%'; 590 | SLASH : '/'; 591 | WORDOP : (':-'|':='|':?'|':+'); 592 | COLON : ':'; 593 | QMARK : '?'; 594 | //Operators for conditional statements 595 | TEST : 'test'; 596 | LOGICAND 597 | : '&&'; 598 | LOGICOR : '||'; 599 | BOP : MINUS LETTER LETTER; 600 | UOP : MINUS LETTER; 601 | //Some builtins 602 | EXPORT : 'export'; 603 | //Tokens for strings 604 | CONTINUE_LINE 605 | : ('\\' EOL)+{$channel=HIDDEN;}; 606 | ESC_RPAREN 607 | : '\\' RPAREN; 608 | ESC_LPAREN 609 | : '\\' LPAREN; 610 | ESC_LT : '\\''<'; 611 | ESC_GT : '\\''>'; 612 | //Handle ANSI C escaped characters: escaped octal, escaped hex, escaped ctrl+ chars, then all others 613 | ESC_CHAR: '\\' (('0'..'7')('0'..'7')('0'..'7')?|'x'('0'..'9'|'a'..'f'|'A'..'F')('0'..'9'|'a'..'f'|'A'..'F')?|'c'.|.); 614 | NAME : (LETTER|'_')(ALPHANUM|'_')+; 615 | NQCHAR_NO_ALPHANUM 616 | : ~('\n'|'\r'|' '|'\t'|'\\'|CARET|QMARK|COLON|AT|SEMIC|POUND|SLASH|BANG|TIMES|COMMA|PIPE|AMP|MINUS|PLUS|PCT|EQUALS|LSQUARE|RSQUARE|RPAREN|LPAREN|RBRACE|LBRACE|DOLLAR|TICK|DOT|LT|GT|SQUOTE|QUOTE|'a'..'z'|'A'..'Z'|'0'..'9')+; 617 | NQSTR : (NQCHAR_NO_ALPHANUM|ALPHANUM)+; 618 | -------------------------------------------------------------------------------- /bashast/features_script/features.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A "featureful" script that demonstrates all the functionality of the parser 3 | 4 | ############################################# 5 | #Copyright 2010 Nathan Eloe 6 | # 7 | #This file is part of libbash. 8 | # 9 | #libbash is free software: you can redistribute it and/or modify 10 | #it under the terms of the GNU General Public License as published by 11 | #the Free Software Foundation, either version 2 of the License, or 12 | #(at your option) any later version. 13 | # 14 | #libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | #GNU General Public License for more details. 17 | # 18 | #You should have received a copy of the GNU General Public License 19 | #along with libbash. If not, see . 20 | ############################################## 21 | 22 | #comment 23 | #demonstrates expansions in strings both double- and non-quoted 24 | function lots_o_echo() { 25 | echo "The number of tests that have failed: $failedtests" 26 | echo '$failedtests' 27 | echo $failedtests 28 | } 29 | 30 | do_some_arith() { 31 | (( 5*4 )) 32 | (( 5**4 )) 33 | (( $failedtests+5/4 )) 34 | (( $z+-3 )) 35 | } 36 | 37 | function arrays() ( 38 | asdf=(a b c d) 39 | echo ${asdf[3]} 40 | foo=(`echo 6` b c d) 41 | arr[foo]=3 42 | bar=(a b [5]=c); 43 | ) 44 | 45 | echo {a,b} 46 | echo {a..d} 47 | echo {{a,b},c,d} 48 | echo a{b,c} 49 | 50 | $(echo foobar) 51 | ls |grep gunit >> filelist 52 | 53 | case `echo asdf` in 54 | gz) 55 | echo yay 56 | ;; 57 | bzip) 58 | echo three 59 | ;; 60 | *) echo woo 61 | ;; 62 | esac 63 | 64 | for each in `ls |grep log`; do 65 | echo $each 66 | cat each 67 | done 68 | 69 | for ((5+3;6+2;3+1)); do echo yay; done 70 | 71 | select each in `ls |grep output`; do 72 | echo asdf 2> /dev/null 73 | done 74 | 75 | if echo yay2; then 76 | echo yay 77 | fi 78 | 79 | until [[ -a this/is.afile ]]; do 80 | touch this/is.afile 81 | done 82 | 83 | while [ -n foobar ]; do 84 | echo "file found" 85 | done 86 | 87 | if test 5 -eq 6; then 88 | echo "something's wrong" 89 | fi 90 | 91 | echo this command has multiple arguments 92 | 93 | wc <(cat /usr/share/dict/linux.words) 94 | 95 | cd build && ./configure && make && make_install || echo fail 96 | 97 | cd /usr/bin; ls -al|grep more 98 | 99 | asdf=parameters 100 | ${asdf:-foo} 101 | ${asdf:8} 102 | ${!asdf*} 103 | ${!asdf@} 104 | ${#foo} 105 | ${replaice/with/pattern} 106 | ${asdf#bar} 107 | ${asdf##bar} 108 | ${asdf%bar} 109 | ${asdf%bar} 110 | $1 $@ $* 111 | $? 112 | ${PV//./_} 113 | ${PV/#foo/bar} 114 | ${PV/%foo/bar} 115 | 116 | MY_PN=${PN/asterisk-} 117 | 118 | cat asdf |grep three 2>&1 > /dev/null 119 | echo asdf >> APPEND 120 | echo cat <<. 17 | **/ 18 | gunit bashast; 19 | 20 | //for this set of unittests, we'll start from the 21 | //top of the order of ops 22 | 23 | primary: 24 | "3" -> "3" 25 | 26 | post_inc_dec: 27 | "b--" -> (POST_DECR b) 28 | "i++" -> (POST_INCR i) 29 | 30 | pre_inc_dec: 31 | "++i" -> (PRE_INCR i) 32 | "--b" -> (PRE_DECR b) 33 | 34 | unary: 35 | "6" -> "6" 36 | "+9" -> (+ 9) 37 | "-15" -> (- 15) 38 | "++ z" -> (PRE_INCR z) 39 | "f--" -> (POST_DECR f) 40 | 41 | negation: 42 | "8" -> "8" 43 | 44 | exponential: 45 | "8" -> "8" 46 | "6**2" -> (** 6 2) 47 | "-5**+4" -> (** (- 5) (+ 4)) 48 | 49 | tdm: 50 | "9" -> "9" 51 | "7 * 9" -> (* 7 9) 52 | "7 / 9" -> (/ 7 9) 53 | "7 % 9" -> (% 7 9) 54 | "6*4*3" -> (* (* 6 4) 3) 55 | "6*4/3" -> (/ (* 6 4) 3) 56 | "6%4*3" -> (* (% 6 4) 3) 57 | "7/3**6" -> (/ 7 (** 3 6)) 58 | "7/-3**6" -> (/ 7 (** (- 3) 6)) 59 | 60 | addsub: 61 | "10" -> "10" 62 | "9+27" -> (+ 9 27) 63 | "9-27" -> (- 9 27) 64 | "9-27+8" -> (+ (- 9 27) 8) 65 | "9-35*-2" -> (- 9 (* 35 (- 2))) 66 | "9*5+2" -> (+ (* 9 5) 2) 67 | 68 | shifts: 69 | "16" -> "16" 70 | "16+2>>3" -> (>> (+ 16 2) 3) 71 | "16+2<<3" -> (<< (+ 16 2) 3) 72 | 73 | compare: 74 | "17" ->"17" 75 | "19<20" -> (< 19 20) 76 | 77 | bitwiseand: 78 | "17" -> "17" 79 | "17 & 15" -> (& 17 15) 80 | 81 | bitwisexor: 82 | "17" -> "17" 83 | "17 ^ 15" -> (^ 17 15) 84 | 85 | bitwiseor: 86 | "17" -> "17" 87 | "17 | 15" -> (| 17 15) 88 | 89 | logicand: 90 | "17" -> "17" 91 | "17 && 15" -> (&& 17 15) 92 | 93 | logicor: 94 | "17" -> "17" 95 | "17 || 15" -> (|| 17 15) 96 | 97 | arithmetic_assignment: 98 | "13"->"13" 99 | "foo=5+3" -> (= foo (+ 5 3)) 100 | "asdf += 5" -> (+= asdf 5) 101 | 102 | arithmetic_condition: 103 | "5?7:2"->(ARITHMETIC_CONDITION 5 7 2) 104 | "(4-3)?0:1"->(ARITHMETIC_CONDITION (- 4 3) 0 1) 105 | 106 | arithmetics: 107 | "5+4, 3+2, $a*$b" -> (+ 5 4) (+ 3 2) (* (VAR_REF a) (VAR_REF b)) 108 | 109 | start: 110 | "echo $(( 3 + 2 ))" -> (LIST (COMMAND (STRING echo) (STRING (+ 3 2)))) 111 | "echo $((++i))" -> (LIST (COMMAND (STRING echo) (STRING (PRE_INCR i)))) 112 | "echo \"The solution is: $(( 3+2 ))\""-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The solution is : (+ 3 2))))) 113 | -------------------------------------------------------------------------------- /bashast/gunit/array.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | var_def: 4 | "asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))) 5 | "asdf=(`echo 6` b c d)"->(= asdf (ARRAY (COMMAND_SUB (COMMAND (STRING echo) (STRING 6))) (STRING b) (STRING c) (STRING d))) 6 | "asdf=(${P} b c d)"->(= asdf (ARRAY (VAR_REF P) (STRING b) (STRING c) (STRING d))) 7 | 8 | var_ref: 9 | "$asdf" -> (VAR_REF asdf) 10 | "${asdf[3]}" -> (VAR_REF (asdf 3)) 11 | "${asdf[4] }" -> (VAR_REF (asdf 4)) 12 | "${asdf}" -> (VAR_REF asdf) 13 | -------------------------------------------------------------------------------- /bashast/gunit/assoc_array.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | var_def: 4 | "arr[foo]=\"asdf\"" -> (= (arr foo) (STRING (DOUBLE_QUOTED_STRING asdf))) 5 | "arr=(a b [4]=c)" -> (= arr (ARRAY (STRING a) (STRING b) (= 4 (STRING c)))) 6 | -------------------------------------------------------------------------------- /bashast/gunit/brace.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | brace: 4 | "{a,b}"-> (BRACE (STRING a) (STRING b)) 5 | "{a,b,c}" -> (BRACE (STRING a) (STRING b) (STRING c)) 6 | "{a..d}" -> (BRACE (.. a d)) 7 | "{{a,b},c,d}" -> (BRACE (BRACE (STRING a) (STRING b)) (STRING c) (STRING d)) 8 | 9 | brace_expansion: 10 | "{a,b}" -> (BRACE_EXP (BRACE (STRING a) (STRING b))) 11 | "a{b,c}" -> (BRACE_EXP (STRING a) (BRACE (STRING b) (STRING c))) 12 | "{c..d}f" -> (BRACE_EXP (BRACE (.. c d)) (STRING f)) 13 | "z{{a,b},c}" -> (BRACE_EXP (STRING z) (BRACE (BRACE (STRING a) (STRING b)) (STRING c))) 14 | -------------------------------------------------------------------------------- /bashast/gunit/command_sub.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | command_sub: 4 | "$(echo \"foo\")" -> (COMMAND_SUB (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING foo)))) 5 | "$(ls |grep file)" -> (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING file)))) 6 | "`cat output.log |grep error|cut`" -> (COMMAND_SUB (| (| (COMMAND (STRING cat) (STRING output . log)) (COMMAND (STRING grep) (STRING error))) (COMMAND (STRING cut)))) 7 | 8 | -------------------------------------------------------------------------------- /bashast/gunit/comment.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | start: 4 | "./hello #comment" -> (LIST (COMMAND (STRING . / hello))) 5 | " 6 | #comment 7 | ./hello" -> (LIST (COMMAND (STRING . / hello))) 8 | "#!/bin/bash 9 | #author: Nathan Eloe 10 | ./hello" -> (LIST (COMMAND (STRING . / hello))) 11 | "#!/bin/bash 12 | #lots of comments! 13 | #comment 14 | ./command #comment 15 | #comment" -> (LIST (COMMAND (STRING . / command))) 16 | -------------------------------------------------------------------------------- /bashast/gunit/compound.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | cond_comparison: 4 | "[[ -a this/is.afile ]]" -> (COMPOUND_COND (KEYWORD_TEST (-a (STRING this / is . afile)))) 5 | "[[ -a this/is.afile]]" FAIL 6 | "[[-a this/is.afile ]]" FAIL 7 | "[[ 8 | -a this/is.afile ]]" -> (COMPOUND_COND (KEYWORD_TEST (-a (STRING this / is . afile)))) 9 | "test ! -a this/is.afile" -> (COMPOUND_COND (BUILTIN_TEST (NEGATION (-a (STRING this / is . afile))))) 10 | "[[ asdf > qwert ]]" -> (COMPOUND_COND (KEYWORD_TEST (> (STRING asdf) (STRING qwert)))) 11 | "[ asdf \> qwert ]" -> (COMPOUND_COND (BUILTIN_TEST (\> (STRING asdf) (STRING qwert)))) 12 | 13 | arith_comparison: 14 | "((5+3))" -> (COMPOUND_ARITH (+ 5 3)) 15 | "(( 5+3 ))" -> (COMPOUND_ARITH (+ 5 3)) 16 | 17 | currshell: 18 | "{ time cat; }" -> (CURRSHELL (LIST (COMMAND (STRING cat) time))) 19 | "{ time cat 20 | }" -> (CURRSHELL (LIST (COMMAND (STRING cat) time))) 21 | "{time cat}" FAIL 22 | "{ time cat }" FAIL 23 | 24 | subshell: 25 | "(time cat)" -> (SUBSHELL (LIST (COMMAND (STRING cat) time))) 26 | "(time cat )" ->(SUBSHELL (LIST (COMMAND (STRING cat) time))) 27 | "( time cat)" -> (SUBSHELL (LIST (COMMAND (STRING cat) time))) 28 | "( time cat; 29 | )" -> (SUBSHELL (LIST (COMMAND (STRING cat) time))) 30 | 31 | case_expr: 32 | "case `echo asdf` in 33 | esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf)))) 34 | 35 | "case `echo asdf` in 36 | gz) 37 | echo yay 38 | ;; 39 | bzip) 40 | echo three 41 | ;; 42 | *) echo woo 43 | ;; 44 | esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) 45 | 46 | "case `echo asdf` in 47 | gz) 48 | echo yay 49 | ;; 50 | bzip) 51 | echo three 52 | ;; 53 | *) echo woo 54 | esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) 55 | 56 | "case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo esac" FAIL 57 | "case `echo asdf` in gz|asdf) echo yay ;; bzip) echo three ;; *) echo woo ;; esac" -> (case (COMMAND_SUB (COMMAND (STRING echo) (STRING asdf))) (CASE_PATTERN (STRING gz) (STRING asdf) (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING woo))))) 58 | 59 | for_expr: 60 | "for each in `ls |grep log`; do 61 | echo \"file found\" 62 | done" -> (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 63 | "for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 64 | "for each in `ls |grep log`; do echo file done" FAIL 65 | 66 | "for ((5+3;5+3;5+3)); do echo yay; done" -> (for (FOR_INIT (+ 5 3)) (FOR_COND (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay)))) 67 | "for ((5+3; ;5+3)); do echo yay; done" -> (for (FOR_INIT (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay)))) 68 | "for ((;5+3 ;5+3)); do echo yay; done" -> (for (FOR_COND (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay)))) 69 | "for ((5+3;;5+3)); do echo yay; done" -> (for (FOR_INIT (+ 5 3)) (FOR_MOD (+ 5 3)) (LIST (COMMAND (STRING echo) (STRING yay)))) 70 | 71 | 72 | sel_expr: 73 | "select each in `ls |grep log`; do 74 | echo \"file found\" 75 | done" -> (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 76 | "select each in `ls |grep log`; do echo \"file found\"; done" -> (select each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 77 | "select each in `ls |grep log`; do echo file done" FAIL 78 | 79 | if_expr: 80 | "if echo yay2; then 81 | echo yay 82 | fi" -> (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) 83 | "if echo yay2; then echo yay ;fi" -> (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))) 84 | "if echo yay2 then echo yay; fi" FAIL 85 | 86 | "if echo yay2; then 87 | echo yay 88 | elif echo yay3; then 89 | echo boo 90 | fi" -> (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))) (if (LIST (COMMAND (STRING echo) (STRING yay3))) (LIST (COMMAND (STRING echo) (STRING boo))))) 91 | 92 | "if echo yay2; then 93 | echo yay 94 | elif echo yay3; then 95 | echo boo 96 | elif echo yay4; then echo hurrah 97 | else echo darn 98 | fi" -> (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay))) (if (LIST (COMMAND (STRING echo) (STRING yay3))) (LIST (COMMAND (STRING echo) (STRING boo)))) (if (LIST (COMMAND (STRING echo) (STRING yay4))) (LIST (COMMAND (STRING echo) (STRING hurrah)))) (LIST (COMMAND (STRING echo) (STRING darn)))) 99 | 100 | while_expr: 101 | "while echo true; do 102 | echo \"file found\" 103 | done" -> (while (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 104 | "while echo true; do echo \"file found\"; done" -> (while (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 105 | "while echo true`; do echo file done" FAIL 106 | 107 | until_expr: 108 | "until echo true; do 109 | echo \"file found\" 110 | done" -> (until (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 111 | "until echo true; do echo \"file found\"; done" -> (until (LIST (COMMAND (STRING echo) (STRING true))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found))))) 112 | "until echo true`; do echo file done" FAIL 113 | 114 | case_expr: 115 | "case \"$1\" in 116 | *) 117 | echo \"Usage: $0 start|stop\" >&2 118 | exit 3 119 | ;; 120 | esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3))))) 121 | 122 | "case $asdf in 123 | a) 124 | echo \"yay\" 125 | ;; 126 | esac" -> (case (VAR_REF asdf) (CASE_PATTERN (STRING a) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING yay)))))) 127 | "case asdf in 128 | asdf) 129 | echo \"yay\" 130 | ;; 131 | esac" -> (case (STRING asdf) (CASE_PATTERN (STRING asdf) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING yay)))))) 132 | "case 1 in 1) echo yay ;; esac" -> (case 1 (CASE_PATTERN (STRING 1) (LIST (COMMAND (STRING echo) (STRING yay))))) 133 | "case /usr/bin in 1) echo yay ;; esac" -> (case (STRING / usr / bin) (CASE_PATTERN (STRING 1) (LIST (COMMAND (STRING echo) (STRING yay))))) 134 | "case \"$1\" in 135 | stop) 136 | ;; 137 | *) 138 | echo \"Usage: $0 start|stop\" >&2 139 | exit 3 140 | ;; 141 | esac" -> (case (STRING (DOUBLE_QUOTED_STRING (VAR_REF 1))) (CASE_PATTERN (STRING stop)) (CASE_PATTERN (STRING *) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING Usage : (VAR_REF 0) start | stop)) (REDIR >& 2)) (COMMAND (STRING exit) (STRING 3))))) 142 | -------------------------------------------------------------------------------- /bashast/gunit/cond_main.gunit: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | **/ 18 | gunit bashast; 19 | 20 | cond_expr: 21 | "[[ -a this/is.afile ]]" -> (KEYWORD_TEST (-a (STRING this / is . afile))) 22 | "[ -n \"yar53\" ]" -> (BUILTIN_TEST (-n (STRING (DOUBLE_QUOTED_STRING yar53)))) 23 | "test 5 -eq 6" -> (BUILTIN_TEST (-eq 5 6)) 24 | "[[ \"asdf\" != \"boo\" && -a filename ]]" -> (KEYWORD_TEST (&& (!= (STRING (DOUBLE_QUOTED_STRING asdf)) (STRING (DOUBLE_QUOTED_STRING boo))) (-a (STRING filename)))) 25 | "[[ true ]]" -> (KEYWORD_TEST (STRING true)) 26 | "[[ true && (false || three) ]]" -> (KEYWORD_TEST (&& (STRING true) (|| (STRING false) (STRING three)))) 27 | -------------------------------------------------------------------------------- /bashast/gunit/continued_lines.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | start: 4 | 5 | "ech\ 6 | o Hello\ 7 | world" -> (LIST (COMMAND (STRING ech o) (STRING Hello) (STRING world))) 8 | 9 | "sed -i \ 10 | -e 's/three/\ 11 | four/'" -> (LIST (COMMAND (STRING sed) (STRING -i) (STRING -e) (STRING (SINGLE_QUOTED_STRING s / three / four /)))) 12 | -------------------------------------------------------------------------------- /bashast/gunit/expansions.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | list: 4 | "echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (BRACE_EXP (STRING a) (BRACE (STRING b) (STRING c) (STRING d))))) 5 | "((5+5))" -> (LIST (COMPOUND_ARITH (+ 5 5))) 6 | "(( 4 + $asdf ))" -> (LIST (COMPOUND_ARITH (+ 4 (VAR_REF asdf)))) 7 | "[[ while=while ]] && echo true" -> (LIST (&& (COMPOUND_COND (KEYWORD_TEST (= (STRING while) (STRING while)))) (COMMAND (STRING echo) (STRING true)))) 8 | "for each in `ls |grep output`; do 9 | echo $each 10 | done" -> (LIST (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (VAR_REF each))))) 11 | "wc <(cat /usr/share/dict/linux.words)" -> (LIST (COMMAND (STRING wc) (PROC_SUB < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words)))))) 12 | -------------------------------------------------------------------------------- /bashast/gunit/fname.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | fname: 4 | "+%Y%m%d" -> (STRING + % Y % m % d) 5 | "\"http://www.gnu.org/software/autoconf/autoconf.html\"" -> (STRING (DOUBLE_QUOTED_STRING http : / / www . gnu . org / software / autoconf / autoconf . html)) 6 | "\"http://dev.gentoo.org/~mpagano/genpatches\"" -> (STRING (DOUBLE_QUOTED_STRING http : / / dev . gentoo . org / ~mpagano / genpatches)) 7 | "\"\"" -> (STRING DOUBLE_QUOTED_STRING) 8 | "\"For more info on this patchset, and how to report problems, see:\"" -> (STRING (DOUBLE_QUOTED_STRING For more info on this patchset , and how to report problems , see :)) 9 | "\"asdf;!\"" -> (STRING (DOUBLE_QUOTED_STRING asdf ; !)) 10 | "\"$(whoami)\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (COMMAND (STRING whoami))))) 11 | "\"`whoami`\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (COMMAND (STRING whoami))))) 12 | "'`whoami`'" -> (STRING (SINGLE_QUOTED_STRING ` whoami `)) 13 | "'$(whoami)'" -> (STRING (SINGLE_QUOTED_STRING $ ( whoami ))) 14 | "\"${P}\"" -> (STRING (DOUBLE_QUOTED_STRING (VAR_REF P))) 15 | "'${P}'" -> (STRING (SINGLE_QUOTED_STRING $ { P })) 16 | "asdf#" -> (STRING asdf #) 17 | "'asdf'" -> (STRING (SINGLE_QUOTED_STRING asdf)) 18 | "'asdf\"asdf'" -> (STRING (SINGLE_QUOTED_STRING asdf " asdf)) 19 | "\"asdf'asdf\"" -> (STRING (DOUBLE_QUOTED_STRING asdf ' asdf)) 20 | "!/bin/bash" -> (STRING ! / bin / bash) 21 | "ab?(g|h)"-> (STRING ab (MATCH_AT_MOST_ONE (STRING g) (STRING h))) 22 | "ab*(gh|i)" -> (STRING ab (MATCH_ANY (STRING gh) (STRING i))) 23 | "ab+(gh|i)" -> (STRING ab (MATCH_AT_LEAST_ONE (STRING gh) (STRING i))) 24 | "ab@(gh|i)" -> (STRING ab (MATCH_EXACTLY_ONE (STRING gh) (STRING i))) 25 | "ab!(gh|i)" -> (STRING ab (MATCH_NONE (STRING gh) (STRING i))) 26 | "\"abc\"\'\"\'\"def\"" -> (STRING (DOUBLE_QUOTED_STRING abc) (SINGLE_QUOTED_STRING ") (DOUBLE_QUOTED_STRING def)) 27 | "my\ name\ is" -> (STRING my \ name \ is) 28 | "octal\007" -> (STRING octal \007) 29 | "hex\xaF" -> (STRING hex \xaF) 30 | "ctrlx\cx" -> (STRING ctrlx \cx) 31 | "tab\\ttab" -> "(STRING tab \\\t tab)" 32 | "abc[def]" -> (STRING abc (MATCH_PATTERN def)) 33 | "a[]" -> (STRING a [ ]) 34 | "ab[d-h]" -> (STRING ab (MATCH_PATTERN d -h)) 35 | "ab[!d-h]" -> (STRING ab (MATCH_ANY_EXCEPT d -h)) 36 | "ab[^d-h]" -> (STRING ab (MATCH_ANY_EXCEPT d -h)) 37 | "ab[]c]" -> (STRING ab (MATCH_PATTERN ] c)) 38 | "ab[:alpha:]" -> (STRING ab (MATCH_PATTERN : alpha :)) 39 | "ab[=c=]" -> (STRING ab (MATCH_PATTERN = c =)) 40 | "ab[.c.]" -> (STRING ab (MATCH_PATTERN . c .)) 41 | "ab[[:alpha:]]" -> (STRING ab (MATCH_PATTERN (CHARACTER_CLASS alpha))) 42 | "ab[[:alpha:][:digit:]]" -> (STRING ab (MATCH_PATTERN (CHARACTER_CLASS alpha) (CHARACTER_CLASS digit))) 43 | "ab[^[:alpha:]]" -> (STRING ab (MATCH_ANY_EXCEPT (CHARACTER_CLASS alpha))) 44 | "ab[[=c=]]" -> (STRING ab (MATCH_PATTERN (EQUIVALENCE_CLASS c))) 45 | "ab[[.backslash.]]" -> (STRING ab (MATCH_PATTERN (COLLATING_SYMBOL backslash))) 46 | "ab[12[:alpha:]]" -> (STRING ab (MATCH_PATTERN 12 (CHARACTER_CLASS alpha))) 47 | "\"'foo'\"" -> (STRING (DOUBLE_QUOTED_STRING ' foo ')) 48 | -------------------------------------------------------------------------------- /bashast/gunit/function.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | function: 4 | "function quit { 5 | exit 6 | }" -> (function (STRING quit) (CURRSHELL (LIST (COMMAND (STRING exit))))) 7 | 8 | "function quit{ exit; }" FAIL 9 | "function quit { exit }" FAIL 10 | "function quit { exit; }" -> (function (STRING quit) (CURRSHELL (LIST (COMMAND (STRING exit))))) 11 | "function foo() { :; }" -> (function (STRING foo) (CURRSHELL (LIST (COMMAND (STRING :))))) 12 | "foo() { :; }" -> (function (STRING foo) (CURRSHELL (LIST (COMMAND (STRING :))))) 13 | 14 | "function quit { exit; } > /dev/null" -> (function (STRING quit) (CURRSHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null))) 15 | "function help { echo hi; } 2> /dev/null" -> (function (STRING help) (CURRSHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null))) 16 | "function help { echo 3; } 2> /dev/null > output" OK 17 | -------------------------------------------------------------------------------- /bashast/gunit/list.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | list: 4 | "make" -> (LIST (COMMAND (STRING make))) 5 | "make && make modules_install;" -> (LIST (&& (COMMAND (STRING make)) (COMMAND (STRING make) (STRING modules_install)))) 6 | "make && make modules_install &" -> (LIST (&& (COMMAND (STRING make)) (COMMAND (STRING make) (STRING modules_install)))) 7 | "cd /usr/bin; ls -al |grep more&& cp ./less ./more" -> (LIST (COMMAND (STRING cd) (STRING / usr / bin)) (&& (| (COMMAND (STRING ls) (STRING -al)) (COMMAND (STRING grep) (STRING more))) (COMMAND (STRING cp) (STRING . / less) (STRING . / more)))) 8 | "mkdir test 9 | cd test 10 | cp ../asdf.tar.gz . 11 | tar xpf asdf.tar.gz" -> (LIST (COMMAND (STRING mkdir) (STRING test)) (COMMAND (STRING cd) (STRING test)) (COMMAND (STRING cp) (STRING .. / asdf . tar . gz) (STRING .)) (COMMAND (STRING tar) (STRING xpf) (STRING asdf . tar . gz))) 12 | "mkdir build && cd build 13 | ./configure && make" -> (LIST (&& (COMMAND (STRING mkdir) (STRING build)) (COMMAND (STRING cd) (STRING build))) (&& (COMMAND (STRING . / configure)) (COMMAND (STRING make)))) 14 | "make;make modules_install 15 | 16 | 17 | cp arch/x86_64/boot/bzImage /boot/kernel" -> (LIST (COMMAND (STRING make)) (COMMAND (STRING make) (STRING modules_install)) (COMMAND (STRING cp) (STRING arch / x86_64 / boot / bzImage) (STRING / boot / kernel))) 18 | 19 | "a=asdf 20 | b=three 21 | echo \"a b\"" -> (LIST (= a (STRING asdf)) (= b (STRING three)) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING a b)))) 22 | "echo one && (echo two || echo three)" -> (LIST (&& (COMMAND (STRING echo) (STRING one)) (SUBSHELL (LIST (|| (COMMAND (STRING echo) (STRING two)) (COMMAND (STRING echo) (STRING three))))))) 23 | -------------------------------------------------------------------------------- /bashast/gunit/param_main.gunit: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | **/ 18 | gunit bashast; 19 | 20 | var_ref: 21 | "$asdf" -> (VAR_REF asdf) 22 | "${asdf}" -> (VAR_REF asdf) 23 | "${asdf:-foo}" -> (VAR_REF (:- asdf (STRING foo))) 24 | "${bar:7}" -> (VAR_REF (OFFSET bar 7)) 25 | "${foo:5:2}" -> (VAR_REF (OFFSET foo 5 2)) 26 | "${!asdf*}" -> (VAR_REF (! asdf *)) 27 | "${!asdf@}" -> (VAR_REF (! asdf @)) 28 | "${!asdf[*]}" -> (VAR_REF (LIST_EXPAND asdf *)) 29 | "${!asdf[@]}" -> (VAR_REF (LIST_EXPAND asdf @)) 30 | "${#foo}" -> (VAR_REF (# foo)) 31 | "${foo#bar}" -> (VAR_REF (# foo (STRING bar))) 32 | "${foo##bar}" -> (VAR_REF (## foo (STRING bar))) 33 | "${foo%bar}" -> (VAR_REF (% foo (STRING bar))) 34 | "${foo%%bar}" -> (VAR_REF (%% foo (STRING bar))) 35 | "${this/is/pattern}"->(VAR_REF (REPLACE_FIRST this (STRING is) (STRING pattern))) 36 | //Test positional/special parameters 37 | "$1" -> (VAR_REF 1) 38 | "$@" -> (VAR_REF @) 39 | "$*" -> (VAR_REF *) 40 | "${@}" -> (VAR_REF @) 41 | "${3}" -> (VAR_REF 3) 42 | "$?" -> (VAR_REF ?) 43 | "${PV//./_}" -> (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))) 44 | "${PV/#foo/bar}" -> (VAR_REF (REPLACE_FIRST PV (STRING foo) (STRING bar))) 45 | "${PV/%foo/bar}" -> (VAR_REF (REPLACE_LAST PV (STRING foo) (STRING bar))) 46 | 47 | var_def: 48 | "MY_PN=${PN/asterisk-}" -> (= MY_PN (VAR_REF (REPLACE_FIRST PN (STRING asterisk -)))) 49 | -------------------------------------------------------------------------------- /bashast/gunit/pipeline.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | pipeline: 4 | "cat asdf" -> (COMMAND (STRING cat) (STRING asdf)) 5 | "time -p cat file" -> (COMMAND (STRING cat) (STRING file) (time -p)) 6 | "time cat file | grep search" -> (| (COMMAND (STRING cat) (STRING file) time) (COMMAND (STRING grep) (STRING search))) 7 | "time -p cat | grep asdf | a.out" -> (| (| (COMMAND (STRING cat) (time -p)) (COMMAND (STRING grep) (STRING asdf))) (COMMAND (STRING a . out))) 8 | "time -p cat file |grep search >> log" -> (| (COMMAND (STRING cat) (STRING file) (time -p)) (COMMAND (STRING grep) (STRING search) (REDIR >> (STRING log)))) 9 | "if time cat; then 10 | echo \"three\" 11 | fi" -> (if (LIST (COMMAND (STRING cat) time)) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING three))))) 12 | -------------------------------------------------------------------------------- /bashast/gunit/proc_sub.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | proc_sub: 4 | "<( true )" -> (PROC_SUB < (LIST (COMMAND (STRING true)))) 5 | ">(false)" -> (PROC_SUB > (LIST (COMMAND (STRING false)))) 6 | -------------------------------------------------------------------------------- /bashast/gunit/redir.gunit: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with libbash. If not, see . 18 | **/ 19 | gunit bashast; 20 | 21 | redirect: 22 | ">output_file" -> (REDIR > (STRING output_file)) 23 | "1>output.file" -> (REDIR 1 > (STRING output . file)) 24 | "2>&1" -> (REDIR 2 >& 1) 25 | ">> /this/is/append" -> (REDIR >> (STRING / this / is / append)) 26 | "&> allout" -> (REDIR &> (STRING allout)) 27 | "< this.is.1input" -> (REDIR < (STRING this . is . 1input)) 28 | "3< \"input from file\"" -> (REDIR 3 < (STRING (DOUBLE_QUOTED_STRING input from file))) 29 | "2<&0" -> (REDIR 2 <& 0) 30 | "<< asdf 31 | asdf 32 | " -> (<< (STRING asdf) (STRING asdf)) 33 | "<<< herestring" -> (<<< (STRING herestring)) 34 | "<< blue 35 | red 36 | green 37 | " -> (<< (STRING blue) (STRING red) (STRING green)) 38 | -------------------------------------------------------------------------------- /bashast/gunit/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################# 3 | #Copyright 2010 Nathan Eloe 4 | # 5 | #This file is part of libbash. 6 | # 7 | #libbash is free software: you can redistribute it and/or modify 8 | #it under the terms of the GNU General Public License as published by 9 | #the Free Software Foundation, either version 2 of the License, or 10 | #(at your option) any later version. 11 | # 12 | #libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | #GNU General Public License for more details. 15 | # 16 | #You should have received a copy of the GNU General Public License 17 | #along with libbash. If not, see . 18 | ############################################## 19 | #variable for number of tests 20 | let failedtests=0 21 | 22 | #test running function 23 | function rtest { 24 | freason="" 25 | gramname=`cat $1 |grep gunit|awk '{print $2}'|awk -F';' '{print $1}'` 26 | grammar="$gramname.g" 27 | if [[ ! -a "$SCRIPTDIR/$grammar" ]]; then 28 | cp "$SCRIPTDIR/../$grammar" $SCRIPTDIR 29 | fi 30 | if [[ ! -a "$SCRIPTDIR/${gramname}Lexer.java" && ! -a "$SCRIPTDIR/${gramname}Parser.java" ]]; then 31 | java -Xmx1024m org.antlr.Tool -Xconversiontimeout 20000 $SCRIPTDIR/$grammar 32 | if [[ ! -a "$SCRIPTDIR/${gramname}Lexer.java" && ! -a "$SCRIPTDIR/${gramname}Parser.java" ]]; then 33 | freason="Grammar generation failure" 34 | fi 35 | fi 36 | if [[ $freason == "" && ! -a "$SCRIPTDIR/${gramname}Lexer.class" && ! -a "$SCRIPTDIR/${gramname}Parser.class" ]]; then 37 | javac $SCRIPTDIR/*.java 2> /dev/null 38 | if [[ ! -a "$SCRIPTDIR/${gramname}Lexer.class" && ! -a "$SCRIPTDIR/${gramname}Parser.class" ]]; then 39 | freason="Compilation failure" 40 | fi 41 | fi 42 | java org.antlr.gunit.Interp $1 > $1.output 43 | failed=`cat $1.output|grep "Failures:"|awk -F: '{print $3}'|awk '{print $1}'` 44 | 45 | if [[ $freason == "" && failed -ne '0' ]]; then 46 | freason="Unit test failure" 47 | fi 48 | if [[ $freason == "" ]]; then 49 | printf "\e[0;0m$1:\e[0;32m passed\e[0;0m\n" 50 | rm $1.output 51 | else 52 | printf "\e[0;0m$1:\e[0;31m fail\e[0m: $freason\n" 53 | ((failedtests++)) 54 | fi 55 | } 56 | 57 | #Get the directory of the script 58 | SCRIPTDIR=`dirname $0` 59 | #set up the classpath 60 | if type -p java-config > /dev/null; then 61 | export CLASSPATH=".:$SCRIPTDIR:$(java-config -dp antlr-3)" 62 | else 63 | export CLASSPATH=".:$SCRIPTDIR:/usr/share/java/antlr-3.2.jar:/Applications/ANTLRWorks.app/Contents/Resources/Java/antlrworks.jar" 64 | fi 65 | 66 | if [[ $# -eq 0 ]]; then 67 | for gtest in `ls ${SCRIPTDIR}|grep gunit`; do 68 | rtest ${SCRIPTDIR}/$gtest 69 | done 70 | else 71 | for gtest in "$@"; do 72 | if [[ -a $gtest ]]; then 73 | rtest $gtest 74 | else 75 | echo "gunit file not found: $gtest" 76 | fi 77 | done 78 | cat $SCRIPTDIR/*.output 2> /dev/null 79 | rm $SCRIPTDIR/*.output 2> /dev/null 80 | fi 81 | if [[ $# -gt 0 ]]; then 82 | testsrun=$# 83 | else 84 | testsrun=`ls $SCRIPTDIR | grep gunit | wc -l` 85 | fi 86 | echo "===========================" 87 | printf "Test summary:\n\e[0;32mPass:\e[0;0m $(($testsrun-$failedtests))\n\e[0;31mFail: \e[0;0m$failedtests\n" 88 | 89 | rm $SCRIPTDIR/*.output 2> /dev/null 90 | rm $SCRIPTDIR/*.java 2> /dev/null 91 | rm $SCRIPTDIR/*.class 2> /dev/null 92 | rm $SCRIPTDIR/*.tokens 2> /dev/null 93 | rm $SCRIPTDIR/*.g 2> /dev/null 94 | exit $failedtests 95 | -------------------------------------------------------------------------------- /bashast/gunit/simp_command.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | simple_command: 4 | "./command" -> (COMMAND (STRING . / command)) 5 | "asdf=5 cat" -> (COMMAND (STRING cat) (= asdf 5)) 6 | "asdf=5 cat out.log > result" -> (COMMAND (STRING cat) (STRING out . log) (= asdf 5) (REDIR > (STRING result))) 7 | "cat results.log > asdf 2> /dev/null" -> (COMMAND (STRING cat) (STRING results . log) (REDIR > (STRING asdf)) (REDIR 2 > (STRING / dev / null))) 8 | "i=3 g=4 h=18 grep asdf" -> (COMMAND (STRING grep) (STRING asdf) (= i 3) (= g 4) (= h 18)) 9 | "./configure --prefix=/usr/local" -> (COMMAND (STRING . / configure) (STRING -- prefix = / usr / local)) 10 | "[[while" -> (COMMAND (STRING [ [ while)) 11 | "./foobär" -> (COMMAND (STRING . / foobär)) 12 | "cat ~/Documents/todo.txt" -> (COMMAND (STRING cat) (STRING ~ / Documents / todo . txt)) 13 | -------------------------------------------------------------------------------- /bashast/gunit/simp_prog.gunit: -------------------------------------------------------------------------------- 1 | gunit bashast; 2 | 3 | start: 4 | "echo \"finding file\" 5 | for each in `ls | grep output`; do 6 | echo \"I found a file\" 7 | done 8 | 9 | echo \"finding complete\" 10 | "-> (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding file))) (for each (COMMAND_SUB (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING I found a file))))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING finding complete)))) 11 | 12 | "function quit { 13 | exit 14 | } 15 | hello () { 16 | echo Hello! 17 | } 18 | hello 19 | quit 20 | echo foo" -> (LIST (function (STRING quit) (CURRSHELL (LIST (COMMAND (STRING exit))))) (function (STRING hello) (CURRSHELL (LIST (COMMAND (STRING echo) (STRING Hello !))))) (COMMAND (STRING hello)) (COMMAND (STRING quit)) (COMMAND (STRING echo) (STRING foo))) 21 | -------------------------------------------------------------------------------- /coding_standard/coding_standard.tex: -------------------------------------------------------------------------------- 1 | \documentclass[letterpaper,10pt]{article} 2 | \usepackage{url} 3 | 4 | %opening/title 5 | \title{libbash Coding Standard} 6 | \author{Nathan Eloe} 7 | \date{\today} 8 | 9 | \begin{document} 10 | \maketitle 11 | \section{Introduction and Acknowledgements} 12 | The majority of the coding styles in this document can be found at \url{http://www.mst.edu/~cpp/cpp_coding_standard_v1_1.pdf}. Minor changes have been made to the standard outlined there for personal preference and consistency. 13 | \section{Commit Messages} 14 | Commit messages should contain a brief (50 characters or less) description in the first line, followed by a more verbose and explanatory statement. The title explanation should have normal sentence capitalization, and the explanatory statements should use proper English grammar. 15 | \section{File Names} 16 | Files must be named descriptively. Files that will be included should be indicative of the functionality they provide. If the file provides a class, the name of the file and class should match. The names of header and implementation files (in the case of a class) should match. 17 | \subsection{File Extensions} 18 | The following extensions will be used:\\ 19 | Header files: .h\\ 20 | Implementation files: .cpp\\ 21 | Templated implementation files: .hpp 22 | \section{Project Files} 23 | Code must be split into two types of files: header files and implementation files. Header files may contain no implementation except functions that may be implemented in one line/command, for example accessor/mutator functions.\\ 24 | Implementation and header names must match. A class prototyped in the file foobar.h must be implemented in foobar.cpp or foobar.hpp.\\ 25 | \subsection{Header files} 26 | Header files must contain the appropriate ifndef header guard: 27 | \begin{verbatim} 28 | #ifndef FILENAME_H 29 | #define FILENAME_H 30 | 31 | /* 32 | code 33 | */ 34 | 35 | #endif 36 | \end{verbatim} 37 | \subsection{Implementation Files} 38 | Implementation files will NEVER be included by another file. Files with the extension .hpp should only be included at the end of the header file of the templated class they are implementing. 39 | \section{Comments} 40 | \subsection{File comments} 41 | At the top of every file that has not been automatically generated, a comment block containing the file name, author name, brief description in the following form (Doxygen style commenting) after the licence comment block: 42 | \begin{verbatim} 43 | /// 44 | /// \file: filename.h 45 | /// \author: author name 46 | /// \brief description of the file 47 | /// 48 | \end{verbatim} 49 | More information if needed may be added after the brief description. 50 | \subsection{Class comments} 51 | Any header prototyping a class should have a comment block containing the class name and a brief description: 52 | \begin{verbatim} 53 | /// 54 | /// \class class_name 55 | /// \brief description of class 56 | /// 57 | \end{verbatim} 58 | More information if needed may be added after the brief description. 59 | \subsection{Function comments} 60 | Functional comments should appear in the header files in which they are prototyped. In the case of a function that has no prototype, the functional comment will go directly before the function implementation. The comment block should have the following form: 61 | \begin{verbatim} 62 | /// 63 | /// \fn function_name 64 | /// \brief description of function 65 | /// \return what the function returns 66 | /// 67 | \end{verbatim} 68 | \subsection{Class variables} 69 | Member variables in a class should have the following comment block: 70 | \begin{verbatim} 71 | /// 72 | /// \var scope::variable_name 73 | /// \brief description of variable 74 | /// 75 | \end{verbatim} 76 | \section{Program code} 77 | \subsection{Indentation} 78 | Every line inside of a code block should be indented for easier readability.\\ 79 | Tabs should not be used for indentation, only spaces. Indentation width will be two spaces. 80 | \subsection{Naming conventions} 81 | The name of a variable, function, class, or struct should be obvious from it's name.\\ 82 | Names will use underscored names not mixed case.\\ 83 | One letter names may only be used as counters in loops or if the usage is obvious or widely accepted (x and y for coordinates, etc).\\ 84 | Global variables should not be used. Any global constant should remain constant and may not be modified.\\ 85 | Template names should be descriptive or conventional. 86 | Class names should begin with lower case letters. 87 | \subsection{Namespaces} 88 | Namespaces should never be "use"d. On using any STL class, it should be manually scoped: 89 | \begin{verbatim} 90 | using namespace std; //Not good 91 | vector names; //Not good 92 | std::vector names; //GOOD 93 | \end{verbatim} 94 | Namespaces may be used in implementation files if they do not cause conflicts, as implementation files should never be included in another file. 95 | \section{Statements} 96 | \subsection{Simple statements} 97 | Each line should contain only one statement: 98 | \begin{verbatim} 99 | int x=5; cout << x << endl; //bad 100 | 101 | //the following lines are good 102 | int x=5; 103 | cout << x << endl; 104 | \end{verbatim} 105 | The comma operator should not be used to group multiple statements unless it makes the meaning clearer. 106 | \subsection{Variable declaration} 107 | Multiple variables may only be declared on one line if none of the values of the variables are being set. Example: 108 | \begin{verbatim} 109 | int x,y,z; //good 110 | int x=5,y,z; //bad 111 | int x=5; //good 112 | int y,z; //good 113 | \end{verbatim} 114 | \subsection{Compound statements} 115 | Any grouping of statements enclosed in braces is considered a compound statement, and should follow the following rules:\\ 116 | 1) Any statements within the compound statement should be indented an additional two spaces from the surrounding code.\\ 117 | 2) The opening brace should begin the line before the statements in the code block, and the closing brace should begin the line after the statements in the code block. Example: \\ 118 | \begin{verbatim} 119 | if (i==5) 120 | { 121 | //code goes here 122 | } 123 | 124 | //NOT THIS 125 | if (i==5) { /* code */ } 126 | \end{verbatim} 127 | The only exception to this rule is if the compound statement is a one line implementation of a mutator or accessor function in a header file.\\ 128 | 3) Braces should be used around all statements, even if it is a single line following (as in a single command after an if statement). 129 | \subsection{return Statements} 130 | A return statement should not use parentheses unless they are needed to make the return value more obvious. Examples: 131 | \begin{verbatim} 132 | return; 133 | 134 | return my_list.size(); 135 | 136 | return (index. 17 | dnl ############################################# 18 | 19 | AC_PREREQ(2.65) 20 | AC_CONFIG_MACRO_DIR([m4]) 21 | AC_INIT([libbash],[0.1],[powerofazure@gmail.com]) 22 | AM_INIT_AUTOMAKE([foreign parallel-tests subdir-objects]) 23 | AC_PROG_CXX 24 | LT_INIT 25 | AX_BOOST_BASE 26 | AC_PATH_PROG([JAVA],[java],"no") 27 | if test "$JAVA" = "no"; then 28 | AC_MSG_ERROR([No java executable found]) 29 | fi 30 | GTEST_LIB_CHECK(,[:],[:]) 31 | 32 | AC_ARG_WITH(antlr, [],with_antlr=$withval,with_antlr=jc) 33 | AS_IF([test "$with_antlr" = "jc"], [ 34 | AC_PATH_PROG(JAVA_CONFIG, java-config, "no") 35 | if test "$JAVA_CONFIG" = "no"; then 36 | AC_MSG_ERROR([java-config tool not found. Please give the location of an antlr3 jar using --with-antlr]) 37 | fi 38 | AC_SUBST(antlr_cp,["$($JAVA_CONFIG -dp antlr-3)"]) 39 | ], 40 | [test -f "$with_antlr"], [AC_SUBST(antlr_cp,["$with_antlr"])], 41 | [AC_MSG_ERROR([Antlr jar $with_antlr not found])]) 42 | 43 | AC_PATH_PROG([PDFLATEX],[pdflatex],"no") 44 | if test "$PDFLATEX" = "no"; then 45 | AC_MSG_RESULT([pdflatex not found on your system. You will be unable to generate the coding standard]) 46 | fi 47 | 48 | AC_CHECK_LIB([antlr3c],[antlr3AsciiFileStreamNew],[],[AC_MSG_ERROR(libasntlr3c not found. Have you installed the C antlr runtime?)]) 49 | AC_CONFIG_FILES([Makefile]) 50 | DX_HTML_FEATURE(ON) 51 | DX_MAN_FEATURE(OFF) 52 | DX_CHM_FEATURE(OFF) 53 | DX_CHI_FEATURE(OFF) 54 | DX_RTF_FEATURE(OFF) 55 | DX_XML_FEATURE(OFF) 56 | DX_PDF_FEATURE(OFF) 57 | DX_PS_FEATURE(OFF) 58 | DX_INIT_DOXYGEN([$PACKAGE_NAME], [Doxyfile]) 59 | AC_OUTPUT 60 | -------------------------------------------------------------------------------- /doxample.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2004 Oren Ben-Kiki 2 | # This file is distributed under the same terms as the Automake macro files. 3 | 4 | # Generate automatic documentation using Doxygen. Goals and variables values 5 | # are controlled by the various DX_COND_??? conditionals set by autoconf. 6 | # 7 | # The provided goals are: 8 | # doxygen-doc: Generate all doxygen documentation. 9 | # doxygen-run: Run doxygen, which will generate some of the documentation 10 | # (HTML, CHM, CHI, MAN, RTF, XML) but will not do the post 11 | # processing required for the rest of it (PS, PDF, and some MAN). 12 | # doxygen-man: Rename some doxygen generated man pages. 13 | # doxygen-ps: Generate doxygen PostScript documentation. 14 | # doxygen-pdf: Generate doxygen PDF documentation. 15 | # 16 | # Note that by default these are not integrated into the automake goals. If 17 | # doxygen is used to generate man pages, you can achieve this integration by 18 | # setting man3_MANS to the list of man pages generated and then adding the 19 | # dependency: 20 | # 21 | # $(man3_MANS): doxygen-doc 22 | # 23 | # This will cause make to run doxygen and generate all the documentation. 24 | # 25 | # The following variable is intended for use in Makefile.am: 26 | # 27 | # DX_CLEANFILES = everything to clean. 28 | # 29 | # This is usually added to MOSTLYCLEANFILES. 30 | 31 | ## --------------------------------- ## 32 | ## Format-independent Doxygen rules. ## 33 | ## --------------------------------- ## 34 | 35 | if DX_COND_doc 36 | 37 | ## ------------------------------- ## 38 | ## Rules specific for HTML output. ## 39 | ## ------------------------------- ## 40 | 41 | if DX_COND_html 42 | 43 | DX_CLEAN_HTML = @DX_DOCDIR@/html 44 | 45 | endif DX_COND_html 46 | 47 | ## ------------------------------ ## 48 | ## Rules specific for CHM output. ## 49 | ## ------------------------------ ## 50 | 51 | if DX_COND_chm 52 | 53 | DX_CLEAN_CHM = @DX_DOCDIR@/chm 54 | 55 | if DX_COND_chi 56 | 57 | DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi 58 | 59 | endif DX_COND_chi 60 | 61 | endif DX_COND_chm 62 | 63 | ## ------------------------------ ## 64 | ## Rules specific for MAN output. ## 65 | ## ------------------------------ ## 66 | 67 | if DX_COND_man 68 | 69 | DX_CLEAN_MAN = @DX_DOCDIR@/man 70 | 71 | endif DX_COND_man 72 | 73 | ## ------------------------------ ## 74 | ## Rules specific for RTF output. ## 75 | ## ------------------------------ ## 76 | 77 | if DX_COND_rtf 78 | 79 | DX_CLEAN_RTF = @DX_DOCDIR@/rtf 80 | 81 | endif DX_COND_rtf 82 | 83 | ## ------------------------------ ## 84 | ## Rules specific for XML output. ## 85 | ## ------------------------------ ## 86 | 87 | if DX_COND_xml 88 | 89 | DX_CLEAN_XML = @DX_DOCDIR@/xml 90 | 91 | endif DX_COND_xml 92 | 93 | ## ----------------------------- ## 94 | ## Rules specific for PS output. ## 95 | ## ----------------------------- ## 96 | 97 | if DX_COND_ps 98 | 99 | DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps 100 | 101 | DX_PS_GOAL = doxygen-ps 102 | 103 | doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps 104 | 105 | @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag 106 | cd @DX_DOCDIR@/latex; \ 107 | rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ 108 | $(DX_LATEX) refman.tex; \ 109 | $(MAKEINDEX_PATH) refman.idx; \ 110 | $(DX_LATEX) refman.tex; \ 111 | countdown=5; \ 112 | while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ 113 | refman.log > /dev/null 2>&1 \ 114 | && test $$countdown -gt 0; do \ 115 | $(DX_LATEX) refman.tex; \ 116 | countdown=`expr $$countdown - 1`; \ 117 | done; \ 118 | $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi 119 | 120 | endif DX_COND_ps 121 | 122 | ## ------------------------------ ## 123 | ## Rules specific for PDF output. ## 124 | ## ------------------------------ ## 125 | 126 | if DX_COND_pdf 127 | 128 | DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf 129 | 130 | DX_PDF_GOAL = doxygen-pdf 131 | 132 | doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf 133 | 134 | @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag 135 | cd @DX_DOCDIR@/latex; \ 136 | rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ 137 | $(DX_PDFLATEX) refman.tex; \ 138 | $(DX_MAKEINDEX) refman.idx; \ 139 | $(DX_PDFLATEX) refman.tex; \ 140 | countdown=5; \ 141 | while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ 142 | refman.log > /dev/null 2>&1 \ 143 | && test $$countdown -gt 0; do \ 144 | $(DX_PDFLATEX) refman.tex; \ 145 | countdown=`expr $$countdown - 1`; \ 146 | done; \ 147 | mv refman.pdf ../@PACKAGE@.pdf 148 | 149 | endif DX_COND_pdf 150 | 151 | ## ------------------------------------------------- ## 152 | ## Rules specific for LaTeX (shared for PS and PDF). ## 153 | ## ------------------------------------------------- ## 154 | 155 | if DX_COND_latex 156 | 157 | DX_CLEAN_LATEX = @DX_DOCDIR@/latex 158 | 159 | endif DX_COND_latex 160 | 161 | .PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL) 162 | 163 | .INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) 164 | 165 | doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag 166 | 167 | doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) 168 | 169 | @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) 170 | rm -rf @DX_DOCDIR@ 171 | $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) 172 | 173 | DX_CLEANFILES = \ 174 | @DX_DOCDIR@/@PACKAGE@.tag \ 175 | -r \ 176 | $(DX_CLEAN_HTML) \ 177 | $(DX_CLEAN_CHM) \ 178 | $(DX_CLEAN_CHI) \ 179 | $(DX_CLEAN_MAN) \ 180 | $(DX_CLEAN_RTF) \ 181 | $(DX_CLEAN_XML) \ 182 | $(DX_CLEAN_PS) \ 183 | $(DX_CLEAN_PDF) \ 184 | $(DX_CLEAN_LATEX) 185 | 186 | endif DX_COND_doc 187 | -------------------------------------------------------------------------------- /doxygen.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2004 Oren Ben-Kiki 2 | # This file is distributed under the same terms as the Automake macro files. 3 | 4 | # Generate automatic documentation using Doxygen. Goals and variables values 5 | # are controlled by the various DX_COND_??? conditionals set by autoconf. 6 | # 7 | # The provided goals are: 8 | # doxygen-doc: Generate all doxygen documentation. 9 | # doxygen-run: Run doxygen, which will generate some of the documentation 10 | # (HTML, CHM, CHI, MAN, RTF, XML) but will not do the post 11 | # processing required for the rest of it (PS, PDF, and some MAN). 12 | # doxygen-man: Rename some doxygen generated man pages. 13 | # doxygen-ps: Generate doxygen PostScript documentation. 14 | # doxygen-pdf: Generate doxygen PDF documentation. 15 | # 16 | # Note that by default these are not integrated into the automake goals. If 17 | # doxygen is used to generate man pages, you can achieve this integration by 18 | # setting man3_MANS to the list of man pages generated and then adding the 19 | # dependency: 20 | # 21 | # $(man3_MANS): doxygen-doc 22 | # 23 | # This will cause make to run doxygen and generate all the documentation. 24 | # 25 | # The following variable is intended for use in Makefile.am: 26 | # 27 | # DX_CLEANFILES = everything to clean. 28 | # 29 | # This is usually added to MOSTLYCLEANFILES. 30 | 31 | ## --------------------------------- ## 32 | ## Format-independent Doxygen rules. ## 33 | ## --------------------------------- ## 34 | 35 | if DX_COND_doc 36 | 37 | ## ------------------------------- ## 38 | ## Rules specific for HTML output. ## 39 | ## ------------------------------- ## 40 | 41 | if DX_COND_html 42 | 43 | DX_CLEAN_HTML = @DX_DOCDIR@/html 44 | 45 | endif DX_COND_html 46 | 47 | ## ------------------------------ ## 48 | ## Rules specific for CHM output. ## 49 | ## ------------------------------ ## 50 | 51 | if DX_COND_chm 52 | 53 | DX_CLEAN_CHM = @DX_DOCDIR@/chm 54 | 55 | if DX_COND_chi 56 | 57 | DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi 58 | 59 | endif DX_COND_chi 60 | 61 | endif DX_COND_chm 62 | 63 | ## ------------------------------ ## 64 | ## Rules specific for MAN output. ## 65 | ## ------------------------------ ## 66 | 67 | if DX_COND_man 68 | 69 | DX_CLEAN_MAN = @DX_DOCDIR@/man 70 | 71 | endif DX_COND_man 72 | 73 | ## ------------------------------ ## 74 | ## Rules specific for RTF output. ## 75 | ## ------------------------------ ## 76 | 77 | if DX_COND_rtf 78 | 79 | DX_CLEAN_RTF = @DX_DOCDIR@/rtf 80 | 81 | endif DX_COND_rtf 82 | 83 | ## ------------------------------ ## 84 | ## Rules specific for XML output. ## 85 | ## ------------------------------ ## 86 | 87 | if DX_COND_xml 88 | 89 | DX_CLEAN_XML = @DX_DOCDIR@/xml 90 | 91 | endif DX_COND_xml 92 | 93 | ## ----------------------------- ## 94 | ## Rules specific for PS output. ## 95 | ## ----------------------------- ## 96 | 97 | if DX_COND_ps 98 | 99 | DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps 100 | 101 | DX_PS_GOAL = doxygen-ps 102 | 103 | doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps 104 | 105 | @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag 106 | cd @DX_DOCDIR@/latex; \ 107 | rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ 108 | $(DX_LATEX) refman.tex; \ 109 | $(MAKEINDEX_PATH) refman.idx; \ 110 | $(DX_LATEX) refman.tex; \ 111 | countdown=5; \ 112 | while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ 113 | refman.log > /dev/null 2>&1 \ 114 | && test $$countdown -gt 0; do \ 115 | $(DX_LATEX) refman.tex; \ 116 | countdown=`expr $$countdown - 1`; \ 117 | done; \ 118 | $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi 119 | 120 | endif DX_COND_ps 121 | 122 | ## ------------------------------ ## 123 | ## Rules specific for PDF output. ## 124 | ## ------------------------------ ## 125 | 126 | if DX_COND_pdf 127 | 128 | DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf 129 | 130 | DX_PDF_GOAL = doxygen-pdf 131 | 132 | doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf 133 | 134 | @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag 135 | cd @DX_DOCDIR@/latex; \ 136 | rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ 137 | $(DX_PDFLATEX) refman.tex; \ 138 | $(DX_MAKEINDEX) refman.idx; \ 139 | $(DX_PDFLATEX) refman.tex; \ 140 | countdown=5; \ 141 | while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ 142 | refman.log > /dev/null 2>&1 \ 143 | && test $$countdown -gt 0; do \ 144 | $(DX_PDFLATEX) refman.tex; \ 145 | countdown=`expr $$countdown - 1`; \ 146 | done; \ 147 | mv refman.pdf ../@PACKAGE@.pdf 148 | 149 | endif DX_COND_pdf 150 | 151 | ## ------------------------------------------------- ## 152 | ## Rules specific for LaTeX (shared for PS and PDF). ## 153 | ## ------------------------------------------------- ## 154 | 155 | if DX_COND_latex 156 | 157 | DX_CLEAN_LATEX = @DX_DOCDIR@/latex 158 | 159 | endif DX_COND_latex 160 | 161 | .PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL) 162 | 163 | .INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) 164 | 165 | doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag 166 | 167 | doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) 168 | 169 | @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) 170 | rm -rf @DX_DOCDIR@ 171 | $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) 172 | 173 | DX_CLEANFILES = \ 174 | @DX_DOCDIR@/@PACKAGE@.tag \ 175 | -r \ 176 | $(DX_CLEAN_HTML) \ 177 | $(DX_CLEAN_CHM) \ 178 | $(DX_CLEAN_CHI) \ 179 | $(DX_CLEAN_MAN) \ 180 | $(DX_CLEAN_RTF) \ 181 | $(DX_CLEAN_XML) \ 182 | $(DX_CLEAN_PS) \ 183 | $(DX_CLEAN_PDF) \ 184 | $(DX_CLEAN_LATEX) 185 | 186 | endif DX_COND_doc 187 | -------------------------------------------------------------------------------- /m4/ax_boost_base.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_boost_base.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Test for the Boost C++ libraries of a particular version (or newer) 12 | # 13 | # If no path to the installed boost library is given the macro searchs 14 | # under /usr, /usr/local, /opt and /opt/local and evaluates the 15 | # $BOOST_ROOT environment variable. Further documentation is available at 16 | # . 17 | # 18 | # This macro calls: 19 | # 20 | # AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) 21 | # 22 | # And sets: 23 | # 24 | # HAVE_BOOST 25 | # 26 | # LICENSE 27 | # 28 | # Copyright (c) 2008 Thomas Porschberg 29 | # Copyright (c) 2009 Peter Adolphs 30 | # 31 | # Copying and distribution of this file, with or without modification, are 32 | # permitted in any medium without royalty provided the copyright notice 33 | # and this notice are preserved. This file is offered as-is, without any 34 | # warranty. 35 | 36 | #serial 17 37 | 38 | AC_DEFUN([AX_BOOST_BASE], 39 | [ 40 | AC_ARG_WITH([boost], 41 | [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], 42 | [use Boost library from a standard location (ARG=yes), 43 | from the specified location (ARG=), 44 | or disable it (ARG=no) 45 | @<:@ARG=yes@:>@ ])], 46 | [ 47 | if test "$withval" = "no"; then 48 | want_boost="no" 49 | elif test "$withval" = "yes"; then 50 | want_boost="yes" 51 | ac_boost_path="" 52 | else 53 | want_boost="yes" 54 | ac_boost_path="$withval" 55 | fi 56 | ], 57 | [want_boost="yes"]) 58 | 59 | 60 | AC_ARG_WITH([boost-libdir], 61 | AS_HELP_STRING([--with-boost-libdir=LIB_DIR], 62 | [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), 63 | [ 64 | if test -d "$withval" 65 | then 66 | ac_boost_lib_path="$withval" 67 | else 68 | AC_MSG_ERROR(--with-boost-libdir expected directory name) 69 | fi 70 | ], 71 | [ac_boost_lib_path=""] 72 | ) 73 | 74 | if test "x$want_boost" = "xyes"; then 75 | boost_lib_version_req=ifelse([$1], ,1.20.0,$1) 76 | boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` 77 | boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` 78 | boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` 79 | boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` 80 | if test "x$boost_lib_version_req_sub_minor" = "x" ; then 81 | boost_lib_version_req_sub_minor="0" 82 | fi 83 | WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` 84 | AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) 85 | succeeded=no 86 | 87 | dnl On x86_64 systems check for system libraries in both lib64 and lib. 88 | dnl The former is specified by FHS, but e.g. Debian does not adhere to 89 | dnl this (as it rises problems for generic multi-arch support). 90 | dnl The last entry in the list is chosen by default when no libraries 91 | dnl are found, e.g. when only header-only libraries are installed! 92 | libsubdirs="lib" 93 | if test `uname -m` = x86_64; then 94 | libsubdirs="lib64 lib lib64" 95 | fi 96 | 97 | dnl first we check the system location for boost libraries 98 | dnl this location ist chosen if boost libraries are installed with the --layout=system option 99 | dnl or if you install boost with RPM 100 | if test "$ac_boost_path" != ""; then 101 | BOOST_LDFLAGS="-L$ac_boost_path/$libsubdir" 102 | BOOST_CPPFLAGS="-I$ac_boost_path/include" 103 | elif test "$cross_compiling" != yes; then 104 | for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do 105 | if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then 106 | for libsubdir in $libsubdirs ; do 107 | if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi 108 | done 109 | BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" 110 | BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" 111 | break; 112 | fi 113 | done 114 | fi 115 | 116 | dnl overwrite ld flags if we have required special directory with 117 | dnl --with-boost-libdir parameter 118 | if test "$ac_boost_lib_path" != ""; then 119 | BOOST_LDFLAGS="-L$ac_boost_lib_path" 120 | fi 121 | 122 | CPPFLAGS_SAVED="$CPPFLAGS" 123 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 124 | export CPPFLAGS 125 | 126 | LDFLAGS_SAVED="$LDFLAGS" 127 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" 128 | export LDFLAGS 129 | 130 | AC_REQUIRE([AC_PROG_CXX]) 131 | AC_LANG_PUSH(C++) 132 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 133 | @%:@include 134 | ]], [[ 135 | #if BOOST_VERSION >= $WANT_BOOST_VERSION 136 | // Everything is okay 137 | #else 138 | # error Boost version is too old 139 | #endif 140 | ]])],[ 141 | AC_MSG_RESULT(yes) 142 | succeeded=yes 143 | found_system=yes 144 | ],[ 145 | ]) 146 | AC_LANG_POP([C++]) 147 | 148 | 149 | 150 | dnl if we found no boost with system layout we search for boost libraries 151 | dnl built and installed without the --layout=system option or for a staged(not installed) version 152 | if test "x$succeeded" != "xyes"; then 153 | _version=0 154 | if test "$ac_boost_path" != ""; then 155 | if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then 156 | for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do 157 | _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` 158 | V_CHECK=`expr $_version_tmp \> $_version` 159 | if test "$V_CHECK" = "1" ; then 160 | _version=$_version_tmp 161 | fi 162 | VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` 163 | BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" 164 | done 165 | fi 166 | else 167 | if test "$cross_compiling" != yes; then 168 | for ac_boost_path in /usr /usr/local /opt /opt/local ; do 169 | if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then 170 | for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do 171 | _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` 172 | V_CHECK=`expr $_version_tmp \> $_version` 173 | if test "$V_CHECK" = "1" ; then 174 | _version=$_version_tmp 175 | best_path=$ac_boost_path 176 | fi 177 | done 178 | fi 179 | done 180 | 181 | VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` 182 | BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" 183 | if test "$ac_boost_lib_path" = ""; then 184 | for libsubdir in $libsubdirs ; do 185 | if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi 186 | done 187 | BOOST_LDFLAGS="-L$best_path/$libsubdir" 188 | fi 189 | fi 190 | 191 | if test "x$BOOST_ROOT" != "x"; then 192 | for libsubdir in $libsubdirs ; do 193 | if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi 194 | done 195 | if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then 196 | version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` 197 | stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` 198 | stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` 199 | V_CHECK=`expr $stage_version_shorten \>\= $_version` 200 | if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then 201 | AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) 202 | BOOST_CPPFLAGS="-I$BOOST_ROOT" 203 | BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" 204 | fi 205 | fi 206 | fi 207 | fi 208 | 209 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 210 | export CPPFLAGS 211 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" 212 | export LDFLAGS 213 | 214 | AC_LANG_PUSH(C++) 215 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 216 | @%:@include 217 | ]], [[ 218 | #if BOOST_VERSION >= $WANT_BOOST_VERSION 219 | // Everything is okay 220 | #else 221 | # error Boost version is too old 222 | #endif 223 | ]])],[ 224 | AC_MSG_RESULT(yes) 225 | succeeded=yes 226 | found_system=yes 227 | ],[ 228 | ]) 229 | AC_LANG_POP([C++]) 230 | fi 231 | 232 | if test "$succeeded" != "yes" ; then 233 | if test "$_version" = "0" ; then 234 | AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) 235 | else 236 | AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) 237 | fi 238 | # execute ACTION-IF-NOT-FOUND (if present): 239 | ifelse([$3], , :, [$3]) 240 | else 241 | AC_SUBST(BOOST_CPPFLAGS) 242 | AC_SUBST(BOOST_LDFLAGS) 243 | AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) 244 | # execute ACTION-IF-FOUND (if present): 245 | ifelse([$2], , :, [$2]) 246 | fi 247 | 248 | CPPFLAGS="$CPPFLAGS_SAVED" 249 | LDFLAGS="$LDFLAGS_SAVED" 250 | fi 251 | 252 | ]) 253 | -------------------------------------------------------------------------------- /m4/doxample.m4: -------------------------------------------------------------------------------- 1 | # This file is part of Autoconf. -*- Autoconf -*- 2 | 3 | # Copyright (C) 2004 Oren Ben-Kiki 4 | # This file is distributed under the same terms as the Autoconf macro files. 5 | 6 | ########## CHANGELOG ################## 7 | # 2009-01-14 Martin Mann 8 | # * DX_ARG_ABLE : new variable 'DX_FLAG_DX_CURRENT_FEATURE' 9 | # * DX_CLEAR_DEPEND : use of explicit variable 'DX_FLAG_DX_CURRENT_FEATURE' 10 | # in AC_SUBST instead of 'DX_FLAG[]DX_CURRENT_FEATURE' which is rejected by 11 | # newer autotools 12 | 13 | # Generate automatic documentation using Doxygen. Works in concert with the 14 | # aminclude.m4 file and a compatible doxygen configuration file. Defines the 15 | # following public macros: 16 | # 17 | # DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature. 18 | # Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics, 19 | # 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI' 20 | # for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF', 21 | # 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment 22 | # variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide' 23 | # paper size. 24 | # 25 | # By default, HTML, PDF and PS documentation is generated as this seems to be 26 | # the most popular and portable combination. MAN pages created by Doxygen are 27 | # usually problematic, though by picking an appropriate subset and doing some 28 | # massaging they might be better than nothing. CHM and RTF are specific for MS 29 | # (note that you can't generate both HTML and CHM at the same time). The XML is 30 | # rather useless unless you apply specialized post-processing to it. 31 | # 32 | # The macro mainly controls the default state of the feature. The use can 33 | # override the default by specifying --enable or --disable. The macros ensure 34 | # that contradictory flags are not given (e.g., --enable-doxygen-html and 35 | # --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.) 36 | # Finally, each feature will be automatically disabled (with a warning) if the 37 | # required programs are missing. 38 | # 39 | # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with 40 | # the following parameters: a one-word name for the project for use as a 41 | # filename base etc., an optional configuration file name (the default is 42 | # 'Doxyfile', the same as Doxygen's default), and an optional output directory 43 | # name (the default is 'doxygen-doc'). 44 | 45 | ## ----------## 46 | ## Defaults. ## 47 | ## ----------## 48 | 49 | DX_ENV="" 50 | AC_DEFUN([DX_FEATURE_doc], ON) 51 | AC_DEFUN([DX_FEATURE_dot], ON) 52 | AC_DEFUN([DX_FEATURE_man], OFF) 53 | AC_DEFUN([DX_FEATURE_html], ON) 54 | AC_DEFUN([DX_FEATURE_chm], OFF) 55 | AC_DEFUN([DX_FEATURE_chi], OFF) 56 | AC_DEFUN([DX_FEATURE_rtf], OFF) 57 | AC_DEFUN([DX_FEATURE_xml], OFF) 58 | AC_DEFUN([DX_FEATURE_pdf], ON) 59 | AC_DEFUN([DX_FEATURE_ps], ON) 60 | 61 | ## --------------- ## 62 | ## Private macros. ## 63 | ## --------------- ## 64 | 65 | # DX_ENV_APPEND(VARIABLE, VALUE) 66 | # ------------------------------ 67 | # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. 68 | AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) 69 | 70 | # DX_DIRNAME_EXPR 71 | # --------------- 72 | # Expand into a shell expression prints the directory part of a path. 73 | AC_DEFUN([DX_DIRNAME_EXPR], 74 | [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) 75 | 76 | # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) 77 | # ------------------------------------- 78 | # Expands according to the M4 (static) status of the feature. 79 | AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) 80 | 81 | # DX_REQUIRE_PROG(VARIABLE, PROGRAM) 82 | # ---------------------------------- 83 | # Require the specified program to be found for the DX_CURRENT_FEATURE to work. 84 | AC_DEFUN([DX_REQUIRE_PROG], [ 85 | AC_PATH_TOOL([$1], [$2]) 86 | if test "$DX_FLAG_DX_CURRENT_FEATURE$$1" = 1; then 87 | AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) 88 | AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) 89 | fi 90 | ]) 91 | 92 | # DX_TEST_FEATURE(FEATURE) 93 | # ------------------------ 94 | # Expand to a shell expression testing whether the feature is active. 95 | AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) 96 | 97 | # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) 98 | # ------------------------------------------------- 99 | # Verify that a required features has the right state before trying to turn on 100 | # the DX_CURRENT_FEATURE. 101 | AC_DEFUN([DX_CHECK_DEPEND], [ 102 | test "$DX_FLAG_$1" = "$2" \ 103 | || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, 104 | requires, contradicts) doxygen-DX_CURRENT_FEATURE]) 105 | ]) 106 | 107 | # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) 108 | # ---------------------------------------------------------- 109 | # Turn off the DX_CURRENT_FEATURE if the required feature is off. 110 | AC_DEFUN([DX_CLEAR_DEPEND], [ 111 | test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) 112 | ]) 113 | 114 | 115 | # DX_FEATURE_ARG(FEATURE, DESCRIPTION, 116 | # CHECK_DEPEND, CLEAR_DEPEND, 117 | # REQUIRE, DO-IF-ON, DO-IF-OFF) 118 | # -------------------------------------------- 119 | # Parse the command-line option controlling a feature. CHECK_DEPEND is called 120 | # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), 121 | # otherwise CLEAR_DEPEND is called to turn off the default state if a required 122 | # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional 123 | # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and 124 | # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. 125 | AC_DEFUN([DX_ARG_ABLE], [ 126 | AC_DEFUN([DX_CURRENT_FEATURE], [$1]) 127 | AC_DEFUN([DX_FLAG_DX_CURRENT_FEATURE], [DX_FLAG_$1]) 128 | AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) 129 | AC_ARG_ENABLE(doxygen-$1, 130 | [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], 131 | [--enable-doxygen-$1]), 132 | DX_IF_FEATURE([$1], [don't $2], [$2]))], 133 | [ 134 | case "$enableval" in 135 | #( 136 | y|Y|yes|Yes|YES) 137 | AC_SUBST([DX_FLAG_$1], 1) 138 | $3 139 | ;; #( 140 | n|N|no|No|NO) 141 | AC_SUBST([DX_FLAG_$1], 0) 142 | ;; #( 143 | *) 144 | AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) 145 | ;; 146 | esac 147 | ], [ 148 | AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) 149 | $4 150 | ]) 151 | if DX_TEST_FEATURE([$1]); then 152 | $5 153 | : 154 | fi 155 | if DX_TEST_FEATURE([$1]); then 156 | AM_CONDITIONAL(DX_COND_$1, :) 157 | $6 158 | : 159 | else 160 | AM_CONDITIONAL(DX_COND_$1, false) 161 | $7 162 | : 163 | fi 164 | ]) 165 | 166 | ## -------------- ## 167 | ## Public macros. ## 168 | ## -------------- ## 169 | 170 | # DX_XXX_FEATURE(DEFAULT_STATE) 171 | # ----------------------------- 172 | AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) 173 | AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) 174 | AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) 175 | AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) 176 | AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) 177 | AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) 178 | AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) 179 | AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) 180 | AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) 181 | AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) 182 | 183 | # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) 184 | # --------------------------------------------------------- 185 | # PROJECT also serves as the base name for the documentation files. 186 | # The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc". 187 | AC_DEFUN([DX_INIT_DOXYGEN], [ 188 | 189 | # Files: 190 | AC_SUBST([DX_PROJECT], [$1]) 191 | AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) 192 | AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])]) 193 | 194 | # Environment variables used inside doxygen.cfg: 195 | DX_ENV_APPEND(SRCDIR, $srcdir) 196 | DX_ENV_APPEND(PROJECT, $DX_PROJECT) 197 | DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) 198 | DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) 199 | 200 | # Doxygen itself: 201 | DX_ARG_ABLE(doc, [generate any doxygen documentation], 202 | [], 203 | [], 204 | [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) 205 | DX_REQUIRE_PROG([DX_PERL], perl)], 206 | [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) 207 | 208 | # Dot for graphics: 209 | DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], 210 | [DX_CHECK_DEPEND(doc, 1)], 211 | [DX_CLEAR_DEPEND(doc, 1)], 212 | [DX_REQUIRE_PROG([DX_DOT], dot)], 213 | [DX_ENV_APPEND(HAVE_DOT, YES) 214 | DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], 215 | [DX_ENV_APPEND(HAVE_DOT, NO)]) 216 | 217 | # Man pages generation: 218 | DX_ARG_ABLE(man, [generate doxygen manual pages], 219 | [DX_CHECK_DEPEND(doc, 1)], 220 | [DX_CLEAR_DEPEND(doc, 1)], 221 | [], 222 | [DX_ENV_APPEND(GENERATE_MAN, YES)], 223 | [DX_ENV_APPEND(GENERATE_MAN, NO)]) 224 | 225 | # RTF file generation: 226 | DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], 227 | [DX_CHECK_DEPEND(doc, 1)], 228 | [DX_CLEAR_DEPEND(doc, 1)], 229 | [], 230 | [DX_ENV_APPEND(GENERATE_RTF, YES)], 231 | [DX_ENV_APPEND(GENERATE_RTF, NO)]) 232 | 233 | # XML file generation: 234 | DX_ARG_ABLE(xml, [generate doxygen XML documentation], 235 | [DX_CHECK_DEPEND(doc, 1)], 236 | [DX_CLEAR_DEPEND(doc, 1)], 237 | [], 238 | [DX_ENV_APPEND(GENERATE_XML, YES)], 239 | [DX_ENV_APPEND(GENERATE_XML, NO)]) 240 | 241 | # (Compressed) HTML help generation: 242 | DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], 243 | [DX_CHECK_DEPEND(doc, 1)], 244 | [DX_CLEAR_DEPEND(doc, 1)], 245 | [DX_REQUIRE_PROG([DX_HHC], hhc)], 246 | [DX_ENV_APPEND(HHC_PATH, $DX_HHC) 247 | DX_ENV_APPEND(GENERATE_HTML, YES) 248 | DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], 249 | [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) 250 | 251 | # Seperate CHI file generation. 252 | DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], 253 | [DX_CHECK_DEPEND(chm, 1)], 254 | [DX_CLEAR_DEPEND(chm, 1)], 255 | [], 256 | [DX_ENV_APPEND(GENERATE_CHI, YES)], 257 | [DX_ENV_APPEND(GENERATE_CHI, NO)]) 258 | 259 | # Plain HTML pages generation: 260 | DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], 261 | [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], 262 | [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], 263 | [], 264 | [DX_ENV_APPEND(GENERATE_HTML, YES)], 265 | [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) 266 | 267 | # PostScript file generation: 268 | DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], 269 | [DX_CHECK_DEPEND(doc, 1)], 270 | [DX_CLEAR_DEPEND(doc, 1)], 271 | [DX_REQUIRE_PROG([DX_LATEX], latex) 272 | DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) 273 | DX_REQUIRE_PROG([DX_DVIPS], dvips) 274 | DX_REQUIRE_PROG([DX_EGREP], egrep)]) 275 | 276 | # PDF file generation: 277 | DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], 278 | [DX_CHECK_DEPEND(doc, 1)], 279 | [DX_CLEAR_DEPEND(doc, 1)], 280 | [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) 281 | DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) 282 | DX_REQUIRE_PROG([DX_EGREP], egrep)]) 283 | 284 | # LaTeX generation for PS and/or PDF: 285 | if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then 286 | AM_CONDITIONAL(DX_COND_latex, :) 287 | DX_ENV_APPEND(GENERATE_LATEX, YES) 288 | else 289 | AM_CONDITIONAL(DX_COND_latex, false) 290 | DX_ENV_APPEND(GENERATE_LATEX, NO) 291 | fi 292 | 293 | # Paper size for PS and/or PDF: 294 | AC_ARG_VAR(DOXYGEN_PAPER_SIZE, 295 | [a4wide (default), a4, letter, legal or executive]) 296 | case "$DOXYGEN_PAPER_SIZE" in 297 | #( 298 | "") 299 | AC_SUBST(DOXYGEN_PAPER_SIZE, "") 300 | ;; #( 301 | a4wide|a4|letter|legal|executive) 302 | DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) 303 | ;; #( 304 | *) 305 | AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) 306 | ;; 307 | esac 308 | 309 | #For debugging: 310 | #echo DX_FLAG_doc=$DX_FLAG_doc 311 | #echo DX_FLAG_dot=$DX_FLAG_dot 312 | #echo DX_FLAG_man=$DX_FLAG_man 313 | #echo DX_FLAG_html=$DX_FLAG_html 314 | #echo DX_FLAG_chm=$DX_FLAG_chm 315 | #echo DX_FLAG_chi=$DX_FLAG_chi 316 | #echo DX_FLAG_rtf=$DX_FLAG_rtf 317 | #echo DX_FLAG_xml=$DX_FLAG_xml 318 | #echo DX_FLAG_pdf=$DX_FLAG_pdf 319 | #echo DX_FLAG_ps=$DX_FLAG_ps 320 | #echo DX_ENV=$DX_ENV 321 | ]) 322 | -------------------------------------------------------------------------------- /m4/gtest.m4: -------------------------------------------------------------------------------- 1 | dnl GTEST_LIB_CHECK([minimum version [, 2 | dnl action if found [,action if not found]]]) 3 | dnl 4 | dnl Check for the presence of the Google Test library, optionally at a minimum 5 | dnl version, and indicate a viable version with the HAVE_GTEST flag. It defines 6 | dnl standard variables for substitution including GTEST_CPPFLAGS, 7 | dnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines 8 | dnl GTEST_VERSION as the version of Google Test found. Finally, it provides 9 | dnl optional custom action slots in the event GTEST is found or not. 10 | AC_DEFUN([GTEST_LIB_CHECK], 11 | [ 12 | dnl Provide a flag to enable or disable Google Test usage. 13 | AC_ARG_ENABLE([gtest], 14 | [AS_HELP_STRING([--enable-gtest], 15 | [Enable tests using the Google C++ Testing Framework. 16 | (Default is enabled.)])], 17 | [], 18 | [enable_gtest=]) 19 | AC_ARG_VAR([GTEST_CONFIG], 20 | [The exact path of Google Test's 'gtest-config' script.]) 21 | AC_ARG_VAR([GTEST_CPPFLAGS], 22 | [C-like preprocessor flags for Google Test.]) 23 | AC_ARG_VAR([GTEST_CXXFLAGS], 24 | [C++ compile flags for Google Test.]) 25 | AC_ARG_VAR([GTEST_LDFLAGS], 26 | [Linker path and option flags for Google Test.]) 27 | AC_ARG_VAR([GTEST_LIBS], 28 | [Library linking flags for Google Test.]) 29 | AC_ARG_VAR([GTEST_VERSION], 30 | [The version of Google Test available.]) 31 | HAVE_GTEST="no" 32 | AS_IF([test "x${enable_gtest}" != "xno"], 33 | [AC_MSG_CHECKING([for 'gtest-config']) 34 | AS_IF([test "x${enable_gtest}" != "xyes"], 35 | [AS_IF([test -x "${enable_gtest}/scripts/gtest-config"], 36 | [GTEST_CONFIG="${enable_gtest}/scripts/gtest-config"], 37 | [GTEST_CONFIG="${enable_gtest}/bin/gtest-config"]) 38 | AS_IF([test -x "${GTEST_CONFIG}"], [], 39 | [AC_MSG_RESULT([no]) 40 | AC_MSG_ERROR([dnl 41 | Unable to locate either a built or installed Google Test. 42 | The specific location '${enable_gtest}' was provided for a built or installed 43 | Google Test, but no 'gtest-config' script could be found at this location.]) 44 | ])], 45 | [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])]) 46 | AS_IF([test -x "${GTEST_CONFIG}"], 47 | [AC_MSG_RESULT([${GTEST_CONFIG}]) 48 | m4_ifval([$1], 49 | [_gtest_min_version="--min-version=$1" 50 | AC_MSG_CHECKING([for Google Test at least version >= $1])], 51 | [_gtest_min_version="--min-version=0" 52 | AC_MSG_CHECKING([for Google Test])]) 53 | AS_IF([${GTEST_CONFIG} ${_gtest_min_version}], 54 | [AC_MSG_RESULT([yes]) 55 | HAVE_GTEST='yes'], 56 | [AC_MSG_RESULT([no])])], 57 | [AC_MSG_RESULT([no])]) 58 | AS_IF([test "x${HAVE_GTEST}" = "xyes"], 59 | [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags` 60 | GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags` 61 | GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags` 62 | GTEST_LIBS=`${GTEST_CONFIG} --libs` 63 | GTEST_VERSION=`${GTEST_CONFIG} --version` 64 | AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])], 65 | [AS_IF([test "x${enable_gtest}" = "xyes"], 66 | [AC_MSG_ERROR([dnl 67 | Google Test was enabled, but no viable version could be found.]) 68 | ])])]) 69 | AC_SUBST([HAVE_GTEST]) 70 | AM_CONDITIONAL([HAVE_GTEST],[test "x$HAVE_GTEST" = "xyes"]) 71 | AS_IF([test "x$HAVE_GTEST" = "xyes"], 72 | [m4_ifval([$2], [$2])], 73 | [m4_ifval([$3], [$3])]) 74 | ]) 75 | -------------------------------------------------------------------------------- /src/builtins/builtins.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file builtins.h 20 | /// \author Nathan Eloe 21 | /// \brief An include file for all of the builtin implementations 22 | /// 23 | #ifndef BUILTINS_H 24 | #define BUILTINS_H 25 | 26 | #include "echo_builtin.h" 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/builtins/echo_builtin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file echo_builtin.cpp 20 | /// \author Nathan Eloe 21 | /// \brief class that implements the echo builtin 22 | /// 23 | 24 | #include "echo_builtin.h" 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | namespace qi = boost::spirit::qi; 31 | namespace karma = boost::spirit::karma; 32 | namespace phoenix = boost::phoenix; 33 | 34 | class suppress_output 35 | { 36 | }; 37 | 38 | echo_builtin::echo_builtin(std::ostream &outstream, std::ostream &errstream, std::istream&instream) : cppbash_builtin(outstream, errstream, instream) 39 | { 40 | } 41 | 42 | int echo_builtin::exec(const std::vector& bash_args) 43 | { 44 | bool suppress_nl = false; 45 | bool enable_escapes = false; 46 | bool options_parsed = false; 47 | 48 | for(auto i = bash_args.begin(); i != bash_args.end(); i++) 49 | { 50 | const std::string& str = *i; 51 | 52 | if(!options_parsed) 53 | { 54 | options_parsed = determine_options(str, suppress_nl, enable_escapes); 55 | } 56 | 57 | if(options_parsed) 58 | { 59 | if(enable_escapes) 60 | { 61 | for(; i != bash_args.end(); i++) 62 | { 63 | try 64 | { 65 | transform_escapes(*i); 66 | } 67 | catch(suppress_output) 68 | { 69 | return 0; 70 | } 71 | } 72 | } 73 | else 74 | { 75 | this->out_buffer() << karma::format(karma::string % ' ', std::vector(i, bash_args.end())); 76 | } 77 | 78 | if(!suppress_nl) 79 | this->out_buffer() << std::endl; 80 | 81 | return 0; 82 | } 83 | } 84 | 85 | return 0; 86 | } 87 | 88 | bool echo_builtin::determine_options(const std::string &string, bool &suppress_nl, bool &enable_escapes) 89 | { 90 | using phoenix::ref; 91 | using qi::char_; 92 | 93 | bool n_matched = false, e_matched = false, E_matched = false; 94 | 95 | auto options = '-' > 96 | +( 97 | char_('n')[ref(n_matched) = true] | 98 | char_('e')[ref(e_matched) = true, ref(E_matched) = false] | 99 | char_('E')[ref(E_matched) = true, ref(e_matched) = false] 100 | ); 101 | 102 | auto first = string.begin(); 103 | qi::parse(first, string.end(), options); 104 | 105 | if(first != string.end()) { 106 | return true; 107 | } 108 | else 109 | { 110 | if(n_matched) 111 | suppress_nl = true; 112 | 113 | if(e_matched) 114 | enable_escapes = true; 115 | 116 | if(E_matched) 117 | enable_escapes = false; 118 | 119 | return false; 120 | } 121 | } 122 | 123 | void echo_builtin::transform_escapes(const std::string &string) 124 | { 125 | using phoenix::val; 126 | using qi::lit; 127 | 128 | auto escape_parser = 129 | +( 130 | lit('\\') >> 131 | ( 132 | lit('a')[this->out_buffer() << val("\a")] | 133 | lit('b')[this->out_buffer() << val("\b")] | 134 | lit('e')[this->out_buffer() << val("\e")] | 135 | lit('f')[this->out_buffer() << val("\f")] | 136 | lit('n')[this->out_buffer() << val("\n")] | 137 | lit('r')[this->out_buffer() << val("\r")] | 138 | lit('t')[this->out_buffer() << val("\t")] | 139 | lit('v')[this->out_buffer() << val("\v")] | 140 | lit('c')[phoenix::throw_(suppress_output())] | 141 | lit('\\')[this->out_buffer() << val('\\')] | 142 | lit("0") >> qi::uint_parser()[ this->out_buffer() << phoenix::static_cast_(qi::_1)] | 143 | lit("x") >> qi::uint_parser()[ this->out_buffer() << phoenix::static_cast_(qi::_1)] 144 | 145 | ) | 146 | qi::char_[this->out_buffer() << qi::_1] 147 | ); 148 | 149 | auto begin = string.begin(); 150 | qi::parse(begin, string.end(), escape_parser); 151 | } 152 | -------------------------------------------------------------------------------- /src/builtins/echo_builtin.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file echo_builtin.h 20 | /// \author Nathan Eloe 21 | /// \brief class that implements the echo builtin 22 | /// 23 | 24 | #ifndef ECHO_BUILTIN_H 25 | #define ECHO_BUILTIN_H 26 | 27 | #include 28 | #include 29 | #include "../cppbash_builtin.h" 30 | 31 | /// 32 | /// \class echo_builtin 33 | /// \brief the echo builtin for bash 34 | /// 35 | class echo_builtin: public virtual cppbash_builtin 36 | { 37 | public: 38 | /// 39 | /// \brief default constructor, sets default streams 40 | /// \param outstream where to send standard output. Default: cout 41 | /// \param errstream where to send standard error. Default: cerr 42 | /// \param instream where to get standard input from. Default cin 43 | /// 44 | echo_builtin(std::ostream &outstream=std::cout, std::ostream &errstream=std::cerr, std::istream &instream=std::cin); 45 | /// 46 | /// \brief runs the echo plugin on the supplied arguments 47 | /// \param bash_args the arguments to the echo builtin 48 | /// \return exit status of echo 49 | /// 50 | virtual int exec(const std::vector& bash_args); 51 | private: 52 | /// 53 | /// \brief determines the options passed as arguments 54 | /// \param string string to check for arguments 55 | /// \param suppress_nl returns back whether to suppress newlines 56 | /// \param enable_escapes returns back whether to enable escapes 57 | /// \return false if all options have been processed 58 | bool determine_options(const std::string &string, bool &suppress_nl, bool &enable_escapes); 59 | 60 | /// \brief transforms escapes in echo input 61 | /// \return false when further output should be suppressed 62 | void transform_escapes(const std::string &string); 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/builtins/tests/echo_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file echo_tests.cpp 20 | /// \brief series of unit tests for echo built in 21 | /// \author Nathan Eloe 22 | /// 23 | #include 24 | #include "../builtins.h" 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace std; 30 | 31 | static void test_echo(const string& expected, std::initializer_list args) 32 | { 33 | stringstream test_output; 34 | echo_builtin my_echo(test_output,cerr,cin); 35 | my_echo.exec(vector(args)); 36 | ASSERT_EQ(expected, test_output.str()); 37 | } 38 | 39 | #define TEST_ECHO(name, expected, ...) \ 40 | TEST(echo_builtin_test, name) { test_echo(expected, {__VA_ARGS__}); } 41 | 42 | TEST_ECHO(simple_output, "hello world\n", "hello", "world") 43 | TEST_ECHO(suppress_newline, "foo", "-n", "foo") 44 | TEST_ECHO(enable_escape, "foo\t\n", "-e", "foo\\t") 45 | TEST_ECHO(no_escape, "foo\\t\n", "foo\\t") 46 | TEST_ECHO(only_options, "foo -e", "-n", "foo", "-e") 47 | TEST_ECHO(only_options2, "foo -n\n", "foo", "-n") 48 | TEST_ECHO(combined_options, "fo\to", "-ne", "fo\\to") 49 | TEST_ECHO(combined_options2, "fo\\to", "-enE", "fo\\to") 50 | TEST_ECHO(fake_options, "-nea fo\\to\n", "-nea", "fo\\to") 51 | TEST_ECHO(combined_options_alternating_e, "fo\to", "-enEeEe", "fo\\to") 52 | TEST_ECHO(conflicting_options, "fo\\to\n", "-e", "-E", "fo\\to") 53 | TEST_ECHO(conflicting_options2, "fo\to\n", "-e", "-E", "-e", "fo\\to") 54 | TEST_ECHO(oct_escape, "]\n", "-e", "\\0135") 55 | TEST_ECHO(hex_escape, "W\n", "-e", "\\x57") 56 | TEST_ECHO(suppress_escape, "foo", "-e", "foo\\cbar") 57 | -------------------------------------------------------------------------------- /src/builtins/tests/run_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file run_tests.cpp 20 | /// \brief runs unit tests for builtin bash functionality 21 | /// 22 | 23 | #include 24 | 25 | /// 26 | /// \brief runs all the unit tests linked to this file 27 | /// 28 | int main(int argc, char* argv[]) 29 | { 30 | ::testing::InitGoogleTest (&argc, argv); 31 | return RUN_ALL_TESTS(); 32 | } 33 | -------------------------------------------------------------------------------- /src/cppbash_builtin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file cppbash_builtin.cpp 20 | /// \author Nathan Eloe 21 | /// \brief Implementation of class to inherit builtins from 22 | /// 23 | 24 | #include "cppbash_builtin.h" 25 | 26 | cppbash_builtin::cppbash_builtin(std::ostream &outstream, std::ostream &errstream, std::istream &instream): _out_stream(&outstream), _err_stream(&errstream), _inp_stream(&instream) 27 | { 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/cppbash_builtin.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010 Nathan Eloe 3 | 4 | This file is part of libbash. 5 | 6 | libbash is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with libbash. If not, see . 17 | */ 18 | /// 19 | /// \file cppbash_builtin.h 20 | /// \author Nathan Eloe 21 | /// \brief Base class for builtin functions in bash 22 | /// 23 | 24 | #ifndef CPPBASH_BUILTIN_H 25 | #define CPPBASH_BUILTIN_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | /// 32 | /// \class cppbash_builtin 33 | /// \brief a virtual class to inherit builtin functions from 34 | /// 35 | class cppbash_builtin 36 | { 37 | public: 38 | /// 39 | /// \brief Default constructor, sets default streams 40 | /// \param outstream where to send standard output. Default: cout 41 | /// \param errstream where to send standard error. Default: cerr 42 | /// \param instream where to get standard input from. Default: stdin 43 | /// 44 | cppbash_builtin(std::ostream &outstream, std::ostream &errstream, std::istream &instream); 45 | /// 46 | /// \brief executes the code associated with the builtin 47 | /// \param bash_args arguments passed to the builtin 48 | /// \return return status of the command 49 | /// 50 | virtual int exec(const std::vector& bash_args)=0; 51 | /// 52 | /// \brief accessor to the std output stream 53 | /// \return output buffer for the builtin 54 | /// 55 | std::ostream& out_buffer() {return *_out_stream;} 56 | /// 57 | /// \brief accessor to the std error stream 58 | /// \return error buffer for the builtin 59 | /// 60 | std::ostream& err_buffer() {return *_err_stream;} 61 | /// 62 | /// \brief accessor to the std input stream 63 | /// \return input buffer for the builtin 64 | /// 65 | std::istream& input_buffer() {return *_inp_stream;} 66 | protected: 67 | /// 68 | /// \var *_out_stream 69 | /// \brief current standard output stream 70 | /// 71 | std::ostream *_out_stream; 72 | /// 73 | /// \var *_err_stream 74 | /// \brief current standard error stream 75 | /// 76 | std::ostream *_err_stream; 77 | /// 78 | /// \var *_inp_stream 79 | /// \brief current standard input stream 80 | /// 81 | std::istream *_inp_stream; 82 | }; 83 | 84 | #endif 85 | --------------------------------------------------------------------------------