├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── cpp ├── cstdint │ ├── test.txt │ └── test.txt.faceup ├── integer-literal │ ├── test.txt │ └── test.txt.faceup ├── keyword │ ├── test.txt │ └── test.txt.faceup ├── preview │ ├── test.txt │ └── test.txt.faceup ├── raw │ ├── test.txt │ └── test.txt.faceup ├── string-literal │ ├── test.txt │ └── test.txt.faceup └── template │ ├── test.txt │ └── test.txt.faceup ├── img ├── all-operator-on-sample.png ├── attributes-off.png ├── attributes-on.png ├── logo.png ├── mc++fl-on.png └── mode-line.png ├── modern-cpp-font-lock-setup-test.el ├── modern-cpp-font-lock-test.el └── modern-cpp-font-lock.el /.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | *.log 3 | *~ 4 | /faceup/ 5 | README.html 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: emacs-lisp 2 | env: 3 | matrix: 4 | - emacs=emacs-snapshot 5 | 6 | before_install: 7 | - sudo add-apt-repository -y ppa:ubuntu-elisp 8 | - sudo apt-get update -qq 9 | - sudo apt-get install -qq $emacs 10 | 11 | script: 12 | - make test 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing # 2 | 3 | ## Reporting issues and suggesting features ## 4 | 5 | To report bugs and suggest new feature use the [issue tracker][issues]. 6 | 7 | [issues]: https://github.com/ludwigpacifici/modern-cpp-font-lock/issues 8 | 9 | ## Code contributions ## 10 | 11 | If you have some code which you would like to be merged, then open a [pull request][pulls]. Please create atomic commits with descriptive commit messages. 12 | 13 | [pulls]: https://github.com/ludwigpacifici/modern-cpp-font-lock/pulls 14 | 15 | ## Author ## 16 | 17 | - Ludwig PACIFICI - 18 | 19 | ## Contributors ## 20 | 21 | Names below are sorted alphabetically. 22 | 23 | - Mola-T - 24 | - Zhiwei Chen - 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | emacs?=emacs 2 | emacs_options=-Q -batch 3 | faceup_directory=faceup 4 | byte_compilation=byte-compile-file 5 | 6 | all: compile 7 | 8 | compile: 9 | $(emacs) $(emacs_options) --eval="($(byte_compilation) \"modern-cpp-font-lock.el\")" 10 | 11 | prepare_test: 12 | wget --no-clobber --directory-prefix $(faceup_directory) \ 13 | https://raw.githubusercontent.com/Lindydancer/faceup/master/faceup.el 14 | 15 | compile_test: 16 | $(emacs) $(emacs_options) --eval="($(byte_compilation) \"$(wildcard $(faceup_directory)/*.el)\")" 17 | 18 | test: prepare_test compile compile_test 19 | @echo "Using $(shell which $(emacs))" 20 | @echo "$(shell $(emacs) --version)" 21 | $(emacs) $(emacs_options) -l ert -l modern-cpp-font-lock-setup-test.el -f ert-run-tests-batch-and-exit 22 | 23 | clean: 24 | rm -rf *.elc $(faceup_directory) 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | [![License GPL 3](https://img.shields.io/badge/license-GPL_3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt) 4 | [![MELPA](http://melpa.org/packages/modern-cpp-font-lock-badge.svg)](http://melpa.org/#/modern-cpp-font-lock) 5 | [![Build Status](https://travis-ci.org/ludwigpacifici/modern-cpp-font-lock.svg?branch=master)](https://travis-ci.org/ludwigpacifici/modern-cpp-font-lock) 6 | 7 | [![Donate Paypal](https://img.shields.io/badge/Donate-Paypal-lightgrey.svg)](https://www.paypal.me/ludwigpacifici) 8 | 9 | Syntax highlighting support for "Modern C++" - until C++20 and Technical Specification. This package aims to provide a simple highlight of the C++ language without dependency. 10 | 11 | It is recommended to use it in addition with the `c++-mode` major mode for extra highlighting (user defined types, functions, etc.) and indentation. 12 | 13 | # Preview 14 | 15 | With `modern-c++-font-lock-mode`: 16 | 17 |

18 | 19 | Using `GNU Emacs 27.0.50` and `CC Mode version 5.33.2`. 20 | 21 | # Installation 22 | 23 | ## Melpa 24 | 25 | `modern-cpp-font-lock` is available on the major `package.el` community maintained repo - [MELPA](http://melpa.org). 26 | 27 | You can install it with the following command: 28 | 29 | M-x `package-install` [RET] `modern-cpp-font-lock` [RET] 30 | 31 | In your init Emacs file add: 32 | 33 | (add-hook 'c++-mode-hook #'modern-c++-font-lock-mode) 34 | 35 | or: 36 | 37 | (modern-c++-font-lock-global-mode t) 38 | 39 | ## `use-package` 40 | 41 | In your init Emacs file add: 42 | 43 | (use-package modern-cpp-font-lock 44 | :ensure t) 45 | 46 | ## Manual 47 | 48 | ### Global setup 49 | 50 | Download `modern-cpp-font-lock.el` into a directory of your [load-path][load-path]. Place the following lines in a suitable init file: 51 | 52 | (require 'modern-cpp-font-lock) 53 | (modern-c++-font-lock-global-mode t) 54 | 55 | `modern-c++-font-lock-mode` will be activated for buffers using the `c++-mode` major-mode. 56 | 57 | [load-path]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html 58 | 59 | ### Local 60 | 61 | For the current buffer, the minor-mode can be turned on/off via the command: 62 | 63 | M-x `modern-c++-font-lock-mode` [RET] 64 | 65 | # Configuration 66 | 67 | ## C++ Language 68 | 69 | You can modify the following lists to recognize more words or set it to `nil` to partially disable font locking: 70 | 71 | * `modern-c++-attributes` - `[[deprecated]]`, `[[noreturn]]`, [etc](http://en.cppreference.com/w/cpp/language/attributes). 72 | * `modern-c++-keywords` - `if`, `constexpr`, `noexcept`, [etc](http://en.cppreference.com/w/cpp/keyword). 73 | * `modern-c++-operators` - `...` 74 | * `modern-c++-preprocessors` - `#define`, `__LINE__`, `__cplusplus`, [etc](http://en.cppreference.com/w/cpp/preprocessor). 75 | * `modern-c++-types` - `bool`, `char`, `double`, [etc](http://en.cppreference.com/w/cpp/language/type). 76 | 77 | Set to `t` (default value) to enable the following options or otherwise to `nil`: 78 | 79 | * `modern-c++-literal-boolean` - `false`, `true` 80 | * `modern-c++-literal-integer` - `0b101010`, `18446744073709550592LLU`, `0XdeadBABEu`, [etc](http://en.cppreference.com/w/cpp/language/integer_literal). 81 | * `modern-c++-literal-null-pointer` - `nullptr` 82 | * `modern-c++-literal-string` - `R"xyz()")xyz"`, `L"hello\ngoodbye"`, `"abcd"`, [etc](http://en.cppreference.com/w/cpp/language/string_literal). 83 | 84 | Configure the following list to customize font locking for literal integers: 85 | 86 | * `modern-c++-literal-binary-prefix-face` 87 | * `modern-c++-literal-binary-infix-face` 88 | * `modern-c++-literal-binary-suffix-face` 89 | * `modern-c++-literal-octal-prefix-face` 90 | * `modern-c++-literal-octal-infix-face` 91 | * `modern-c++-literal-octal-suffix-face` 92 | * `modern-c++-literal-hex-prefix-face` 93 | * `modern-c++-literal-hex-infix-face` 94 | * `modern-c++-literal-hex-suffix-face` 95 | * `modern-c++-literal-dec-infix-face` 96 | * `modern-c++-literal-dec-suffix-face` 97 | 98 | ## C++ standard library 99 | 100 | Set to `t` (default value) to enable the following font lock options. Otherwise use `nil`: 101 | 102 | * `modern-c++-stl-cstdint` - Define the header [``](http://en.cppreference.com/w/cpp/header/cstdint) 103 | 104 | # Mode line 105 | 106 | When `modern-c++-font-lock-mode` is activated, `mc++fl` is displayed. 107 | 108 |

109 | 110 | # [Wiki](https://github.com/ludwigpacifici/modern-cpp-font-lock/wiki) 111 | 112 | The Wiki is available: https://github.com/ludwigpacifici/modern-cpp-font-lock/wiki 113 | 114 | # Testing 115 | 116 | Font-lock keywords are tested with the [faceup](https://github.com/Lindydancer/faceup) package of [Anders Lindgren](https://github.com/Lindydancer). 117 | 118 | # Feedback 119 | 120 | If you find a bug, please check if you can reproduce with `c++-mode` only. If it is the case, send your bug upstream to [CC Mode](http://cc-mode.sourceforge.net/) 121 | 122 | Do not hesitate to ask questions or share suggestions. 123 | 124 | Happy coding! 125 | 126 | [Lud](https://lud.cc) 127 | -------------------------------------------------------------------------------- /cpp/cstdint/test.txt: -------------------------------------------------------------------------------- 1 | int8_t 2 | int16_t 3 | int32_t 4 | int64_t 5 | int_fast8_t 6 | int_fast16_t 7 | int_fast32_t 8 | int_fast64_t 9 | int_least8_t 10 | int_least16_t 11 | int_least32_t 12 | int_least64_t 13 | intmax_t 14 | intptr_t 15 | uint8_t 16 | uint16_t 17 | uint32_t 18 | uint64_t 19 | uint_fast8_t 20 | uint_fast16_t 21 | uint_fast32_t 22 | uint_fast64_t 23 | uint_least8_t 24 | uint_least16_t 25 | uint_least32_t 26 | uint_least64_t 27 | uintmax_t 28 | uintptr_t 29 | std::int8_t 30 | std::int16_t 31 | std::int32_t 32 | std::int64_t 33 | std::int_fast8_t 34 | std::int_fast16_t 35 | std::int_fast32_t 36 | std::int_fast64_t 37 | std::int_least8_t 38 | std::int_least16_t 39 | std::int_least32_t 40 | std::int_least64_t 41 | std::intmax_t 42 | std::intptr_t 43 | std::uint8_t 44 | std::uint16_t 45 | std::uint32_t 46 | std::uint64_t 47 | std::uint_fast8_t 48 | std::uint_fast16_t 49 | std::uint_fast32_t 50 | std::uint_fast64_t 51 | std::uint_least8_t 52 | std::uint_least16_t 53 | std::uint_least32_t 54 | std::uint_least64_t 55 | std::uintmax_t 56 | std::uintptr_t 57 | 58 | INT16_C 59 | INT16_MAX 60 | INT16_MIN 61 | INT32_C 62 | INT32_MAX 63 | INT32_MIN 64 | INT64_C 65 | INT64_MAX 66 | INT64_MIN 67 | INT8_C 68 | INT8_MAX 69 | INT8_MIN 70 | INTMAX_C 71 | INTMAX_MAX 72 | INTMAX_MIN 73 | INTPTR_MAX 74 | INTPTR_MIN 75 | INT_FAST16_MAX 76 | INT_FAST16_MIN 77 | INT_FAST32_MAX 78 | INT_FAST32_MIN 79 | INT_FAST64_MAX 80 | INT_FAST64_MIN 81 | INT_FAST8_MAX 82 | INT_FAST8_MIN 83 | INT_LEAST16_MAX 84 | INT_LEAST16_MIN 85 | INT_LEAST32_MAX 86 | INT_LEAST32_MIN 87 | INT_LEAST64_MAX 88 | INT_LEAST64_MIN 89 | INT_LEAST8_MAX 90 | INT_LEAST8_MIN 91 | PTRDIFF_MAX 92 | PTRDIFF_MIN 93 | SIG_ATOMIC_MAX 94 | SIG_ATOMIC_MIN 95 | SIZE_MAX 96 | UINT16_C 97 | UINT16_MAX 98 | UINT32_C 99 | UINT32_MAX 100 | UINT64_C 101 | UINT64_MAX 102 | UINT8_C 103 | UINT8_MAX 104 | UINTMAX_C 105 | UINTMAX_MAX 106 | UINTPTR_MAX 107 | UINT_FAST16_MAX 108 | UINT_FAST32_MAX 109 | UINT_FAST64_MAX 110 | UINT_FAST8_MAX 111 | UINT_LEAST16_MAX 112 | UINT_LEAST32_MAX 113 | UINT_LEAST64_MAX 114 | UINT_LEAST8_MAX 115 | WCHAR_MAX 116 | WCHAR_MIN 117 | WINT_MAX 118 | WINT_MIN 119 | -------------------------------------------------------------------------------- /cpp/cstdint/test.txt.faceup: -------------------------------------------------------------------------------- 1 | int8_t 2 | int16_t 3 | int32_t 4 | int64_t 5 | int_fast8_t 6 | int_fast16_t 7 | int_fast32_t 8 | int_fast64_t 9 | int_least8_t 10 | int_least16_t 11 | int_least32_t 12 | int_least64_t 13 | intmax_t 14 | intptr_t 15 | uint8_t 16 | uint16_t 17 | uint32_t 18 | uint64_t 19 | uint_fast8_t 20 | uint_fast16_t 21 | uint_fast32_t 22 | uint_fast64_t 23 | uint_least8_t 24 | uint_least16_t 25 | uint_least32_t 26 | uint_least64_t 27 | uintmax_t 28 | uintptr_t 29 | «t:std::int8_t» 30 | «t:std::int16_t» 31 | «t:std::int32_t» 32 | «t:std::int64_t» 33 | «t:std::int_fast8_t» 34 | «t:std::int_fast16_t» 35 | «t:std::int_fast32_t» 36 | «t:std::int_fast64_t» 37 | «t:std::int_least8_t» 38 | «t:std::int_least16_t» 39 | «t:std::int_least32_t» 40 | «t:std::int_least64_t» 41 | «t:std::intmax_t» 42 | «t:std::intptr_t» 43 | «t:std::uint8_t» 44 | «t:std::uint16_t» 45 | «t:std::uint32_t» 46 | «t:std::uint64_t» 47 | «t:std::uint_fast8_t» 48 | «t:std::uint_fast16_t» 49 | «t:std::uint_fast32_t» 50 | «t:std::uint_fast64_t» 51 | «t:std::uint_least8_t» 52 | «t:std::uint_least16_t» 53 | «t:std::uint_least32_t» 54 | «t:std::uint_least64_t» 55 | «t:std::uintmax_t» 56 | «t:std::uintptr_t» 57 | 58 | «p:INT16_C» 59 | «p:INT16_MAX» 60 | «p:INT16_MIN» 61 | «p:INT32_C» 62 | «p:INT32_MAX» 63 | «p:INT32_MIN» 64 | «p:INT64_C» 65 | «p:INT64_MAX» 66 | «p:INT64_MIN» 67 | «p:INT8_C» 68 | «p:INT8_MAX» 69 | «p:INT8_MIN» 70 | «p:INTMAX_C» 71 | «p:INTMAX_MAX» 72 | «p:INTMAX_MIN» 73 | «p:INTPTR_MAX» 74 | «p:INTPTR_MIN» 75 | «p:INT_FAST16_MAX» 76 | «p:INT_FAST16_MIN» 77 | «p:INT_FAST32_MAX» 78 | «p:INT_FAST32_MIN» 79 | «p:INT_FAST64_MAX» 80 | «p:INT_FAST64_MIN» 81 | «p:INT_FAST8_MAX» 82 | «p:INT_FAST8_MIN» 83 | «p:INT_LEAST16_MAX» 84 | «p:INT_LEAST16_MIN» 85 | «p:INT_LEAST32_MAX» 86 | «p:INT_LEAST32_MIN» 87 | «p:INT_LEAST64_MAX» 88 | «p:INT_LEAST64_MIN» 89 | «p:INT_LEAST8_MAX» 90 | «p:INT_LEAST8_MIN» 91 | «p:PTRDIFF_MAX» 92 | «p:PTRDIFF_MIN» 93 | «p:SIG_ATOMIC_MAX» 94 | «p:SIG_ATOMIC_MIN» 95 | «p:SIZE_MAX» 96 | «p:UINT16_C» 97 | «p:UINT16_MAX» 98 | «p:UINT32_C» 99 | «p:UINT32_MAX» 100 | «p:UINT64_C» 101 | «p:UINT64_MAX» 102 | «p:UINT8_C» 103 | «p:UINT8_MAX» 104 | «p:UINTMAX_C» 105 | «p:UINTMAX_MAX» 106 | «p:UINTPTR_MAX» 107 | «p:UINT_FAST16_MAX» 108 | «p:UINT_FAST32_MAX» 109 | «p:UINT_FAST64_MAX» 110 | «p:UINT_FAST8_MAX» 111 | «p:UINT_LEAST16_MAX» 112 | «p:UINT_LEAST32_MAX» 113 | «p:UINT_LEAST64_MAX» 114 | «p:UINT_LEAST8_MAX» 115 | «p:WCHAR_MAX» 116 | «p:WCHAR_MIN» 117 | «p:WINT_MAX» 118 | «p:WINT_MIN» 119 | -------------------------------------------------------------------------------- /cpp/integer-literal/test.txt: -------------------------------------------------------------------------------- 1 | auto i = 42; 2 | auto i = 052; 3 | auto i = 0x2a; 4 | auto i = 0X2A; 5 | auto i = 0b101010; 6 | auto i = 18446744073709550592ull; 7 | auto i = 0xDeAdBaBeU; 8 | auto i = 0XdeadBABEu; 9 | auto i = -9223372036854775808u; 10 | auto i = -9223372036854775807 - 1; 11 | auto i = 12345678901234567890u; 12 | auto i = 42ull; 13 | auto i = 42LLu; 14 | auto i = 42LLU; 15 | auto i = 42llu; 16 | auto i = 42llU; 17 | auto i = 42uLL; 18 | auto i = 42ULL; 19 | auto i = 42Ull; 20 | auto i = 42ll; 21 | auto i = 42LL; 22 | auto i = 42ul; 23 | auto i = 42uL; 24 | auto i = 42Ul; 25 | auto i = 42UL; 26 | auto i = 42lu; 27 | auto i = 42lU; 28 | auto i = 42LU; 29 | auto i = 42Lu; 30 | auto i = 42u; 31 | auto i = 42U; 32 | auto i = 42l; 33 | auto i = 42L; 34 | auto i = 042ull; 35 | auto i = 042LLu; 36 | auto i = 042LLU; 37 | auto i = 042llu; 38 | auto i = 042llU; 39 | auto i = 042uLL; 40 | auto i = 042ULL; 41 | auto i = 042Ull; 42 | auto i = 042ll; 43 | auto i = 042LL; 44 | auto i = 042ul; 45 | auto i = 042uL; 46 | auto i = 042Ul; 47 | auto i = 042UL; 48 | auto i = 042lu; 49 | auto i = 042lU; 50 | auto i = 042LU; 51 | auto i = 042Lu; 52 | auto i = 042u; 53 | auto i = 042U; 54 | auto i = 042l; 55 | auto i = 042L; 56 | auto i = 0x42ull; 57 | auto i = 0X42LLu; 58 | auto i = 0x42LLU; 59 | auto i = 0x42llu; 60 | auto i = 0x42llU; 61 | auto i = 0x42uLL; 62 | auto i = 0x42ULL; 63 | auto i = 0x42Ull; 64 | auto i = 0x42ll; 65 | auto i = 0x42LL; 66 | auto i = 0x42ul; 67 | auto i = 0x42uL; 68 | auto i = 0x42Ul; 69 | auto i = 0x42UL; 70 | auto i = 0x42lu; 71 | auto i = 0x42lU; 72 | auto i = 0x42LU; 73 | auto i = 0x42Lu; 74 | auto i = 0x42u; 75 | auto i = 0x42U; 76 | auto i = 0x42l; 77 | auto i = 0x42L; 78 | auto i = 0b10ull; 79 | auto i = 0b10LLu; 80 | auto i = 0B10LLU; 81 | auto i = 0b10llu; 82 | auto i = 0b10llU; 83 | auto i = 0b10uLL; 84 | auto i = 0b10ULL; 85 | auto i = 0b10Ull; 86 | auto i = 0b10ll; 87 | auto i = 0b10LL; 88 | auto i = 0b10ul; 89 | auto i = 0b10uL; 90 | auto i = 0b10Ul; 91 | auto i = 0b10UL; 92 | auto i = 0b10lu; 93 | auto i = 0b10lU; 94 | auto i = 0b10LU; 95 | auto i = 0b10Lu; 96 | auto i = 0b10u; 97 | auto i = 0b10U; 98 | auto i = 0b10l; 99 | auto i = 0b10L; 100 | auto i = 42lL; 101 | auto i = 42Ll; 102 | auto i = 157; 103 | auto i = 0198; 104 | auto i = 0365; 105 | auto i = 36'000'000; 106 | auto i = 0x3fff; 107 | auto i = 0X3FFF; 108 | auto i = 328u; 109 | auto i = 0x7FFFFFL; 110 | auto i = 0776745ul; 111 | auto i = 108LL; 112 | auto i = 0x8000000000000000ULL << 16; 113 | auto i = 0B001101; 114 | auto i = 0b000001; 115 | auto i = 24'847'458'121; 116 | auto i = 1'000'000; 117 | auto i = 0.000'015'3; 118 | auto i = 0b0100'1100'0110; 119 | auto i = 1'0'0'000'00; 120 | auto i_0x123 = foo_0X123(); 121 | auto i_0123 = foo_0123(); 122 | auto i_0b101 = foo_0B010(); 123 | auto i_123 = foo_123(); 124 | -------------------------------------------------------------------------------- /cpp/integer-literal/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «k:auto» i = 42; 2 | «k:auto» i = «k:0»«c:52»; 3 | «k:auto» i = «k:0x»«c:2a»; 4 | «k:auto» i = «k:0X»«c:2A»; 5 | «k:auto» i = «k:0b»«c:101010»; 6 | «k:auto» i = «c:18446744073709550592»«k:ull»; 7 | «k:auto» i = «k:0x»«c:DeAdBaBe»«k:U»; 8 | «k:auto» i = «k:0X»«c:deadBABE»«k:u»; 9 | «k:auto» i = -«c:9223372036854775808»«k:u»; 10 | «k:auto» i = -9223372036854775807 - 1; 11 | «k:auto» i = «c:12345678901234567890»«k:u»; 12 | «k:auto» i = «c:42»«k:ull»; 13 | «k:auto» i = «c:42»«k:LLu»; 14 | «k:auto» i = «c:42»«k:LLU»; 15 | «k:auto» i = «c:42»«k:llu»; 16 | «k:auto» i = «c:42»«k:llU»; 17 | «k:auto» i = «c:42»«k:uLL»; 18 | «k:auto» i = «c:42»«k:ULL»; 19 | «k:auto» i = «c:42»«k:Ull»; 20 | «k:auto» i = «c:42»«k:ll»; 21 | «k:auto» i = «c:42»«k:LL»; 22 | «k:auto» i = «c:42»«k:ul»; 23 | «k:auto» i = «c:42»«k:uL»; 24 | «k:auto» i = «c:42»«k:Ul»; 25 | «k:auto» i = «c:42»«k:UL»; 26 | «k:auto» i = «c:42»«k:lu»; 27 | «k:auto» i = «c:42»«k:lU»; 28 | «k:auto» i = «c:42»«k:LU»; 29 | «k:auto» i = «c:42»«k:Lu»; 30 | «k:auto» i = «c:42»«k:u»; 31 | «k:auto» i = «c:42»«k:U»; 32 | «k:auto» i = «c:42»«k:l»; 33 | «k:auto» i = «c:42»«k:L»; 34 | «k:auto» i = «k:0»«c:42»«k:ull»; 35 | «k:auto» i = «k:0»«c:42»«k:LLu»; 36 | «k:auto» i = «k:0»«c:42»«k:LLU»; 37 | «k:auto» i = «k:0»«c:42»«k:llu»; 38 | «k:auto» i = «k:0»«c:42»«k:llU»; 39 | «k:auto» i = «k:0»«c:42»«k:uLL»; 40 | «k:auto» i = «k:0»«c:42»«k:ULL»; 41 | «k:auto» i = «k:0»«c:42»«k:Ull»; 42 | «k:auto» i = «k:0»«c:42»«k:ll»; 43 | «k:auto» i = «k:0»«c:42»«k:LL»; 44 | «k:auto» i = «k:0»«c:42»«k:ul»; 45 | «k:auto» i = «k:0»«c:42»«k:uL»; 46 | «k:auto» i = «k:0»«c:42»«k:Ul»; 47 | «k:auto» i = «k:0»«c:42»«k:UL»; 48 | «k:auto» i = «k:0»«c:42»«k:lu»; 49 | «k:auto» i = «k:0»«c:42»«k:lU»; 50 | «k:auto» i = «k:0»«c:42»«k:LU»; 51 | «k:auto» i = «k:0»«c:42»«k:Lu»; 52 | «k:auto» i = «k:0»«c:42»«k:u»; 53 | «k:auto» i = «k:0»«c:42»«k:U»; 54 | «k:auto» i = «k:0»«c:42»«k:l»; 55 | «k:auto» i = «k:0»«c:42»«k:L»; 56 | «k:auto» i = «k:0x»«c:42»«k:ull»; 57 | «k:auto» i = «k:0X»«c:42»«k:LLu»; 58 | «k:auto» i = «k:0x»«c:42»«k:LLU»; 59 | «k:auto» i = «k:0x»«c:42»«k:llu»; 60 | «k:auto» i = «k:0x»«c:42»«k:llU»; 61 | «k:auto» i = «k:0x»«c:42»«k:uLL»; 62 | «k:auto» i = «k:0x»«c:42»«k:ULL»; 63 | «k:auto» i = «k:0x»«c:42»«k:Ull»; 64 | «k:auto» i = «k:0x»«c:42»«k:ll»; 65 | «k:auto» i = «k:0x»«c:42»«k:LL»; 66 | «k:auto» i = «k:0x»«c:42»«k:ul»; 67 | «k:auto» i = «k:0x»«c:42»«k:uL»; 68 | «k:auto» i = «k:0x»«c:42»«k:Ul»; 69 | «k:auto» i = «k:0x»«c:42»«k:UL»; 70 | «k:auto» i = «k:0x»«c:42»«k:lu»; 71 | «k:auto» i = «k:0x»«c:42»«k:lU»; 72 | «k:auto» i = «k:0x»«c:42»«k:LU»; 73 | «k:auto» i = «k:0x»«c:42»«k:Lu»; 74 | «k:auto» i = «k:0x»«c:42»«k:u»; 75 | «k:auto» i = «k:0x»«c:42»«k:U»; 76 | «k:auto» i = «k:0x»«c:42»«k:l»; 77 | «k:auto» i = «k:0x»«c:42»«k:L»; 78 | «k:auto» i = «k:0b»«c:10»«k:ull»; 79 | «k:auto» i = «k:0b»«c:10»«k:LLu»; 80 | «k:auto» i = «k:0B»«c:10»«k:LLU»; 81 | «k:auto» i = «k:0b»«c:10»«k:llu»; 82 | «k:auto» i = «k:0b»«c:10»«k:llU»; 83 | «k:auto» i = «k:0b»«c:10»«k:uLL»; 84 | «k:auto» i = «k:0b»«c:10»«k:ULL»; 85 | «k:auto» i = «k:0b»«c:10»«k:Ull»; 86 | «k:auto» i = «k:0b»«c:10»«k:ll»; 87 | «k:auto» i = «k:0b»«c:10»«k:LL»; 88 | «k:auto» i = «k:0b»«c:10»«k:ul»; 89 | «k:auto» i = «k:0b»«c:10»«k:uL»; 90 | «k:auto» i = «k:0b»«c:10»«k:Ul»; 91 | «k:auto» i = «k:0b»«c:10»«k:UL»; 92 | «k:auto» i = «k:0b»«c:10»«k:lu»; 93 | «k:auto» i = «k:0b»«c:10»«k:lU»; 94 | «k:auto» i = «k:0b»«c:10»«k:LU»; 95 | «k:auto» i = «k:0b»«c:10»«k:Lu»; 96 | «k:auto» i = «k:0b»«c:10»«k:u»; 97 | «k:auto» i = «k:0b»«c:10»«k:U»; 98 | «k:auto» i = «k:0b»«c:10»«k:l»; 99 | «k:auto» i = «k:0b»«c:10»«k:L»; 100 | «k:auto» i = «c:42»«k:l»L; 101 | «k:auto» i = «c:42»«k:L»l; 102 | «k:auto» i = 157; 103 | «k:auto» i = «k:0»«c:1»98; 104 | «k:auto» i = «k:0»«c:365»; 105 | «k:auto» i = 36'000'000; 106 | «k:auto» i = «k:0x»«c:3fff»; 107 | «k:auto» i = «k:0X»«c:3FFF»; 108 | «k:auto» i = «c:328»«k:u»; 109 | «k:auto» i = «k:0x»«c:7FFFFF»«k:L»; 110 | «k:auto» i = «k:0»«c:776745»«k:ul»; 111 | «k:auto» i = «c:108»«k:LL»; 112 | «k:auto» i = «k:0x»«c:8000000000000000»«k:ULL» << 16; 113 | «k:auto» i = «k:0B»«c:001101»; 114 | «k:auto» i = «k:0b»«c:000001»; 115 | «k:auto» i = 24'847'458'121; 116 | «k:auto» i = 1'000'000; 117 | «k:auto» i = 0.000'015'3; 118 | «k:auto» i = «k:0b»«c:0100'1100'0110»; 119 | «k:auto» i = 1'0'0'000'00; 120 | «k:auto» i_0x123 = foo_0X123(); 121 | «k:auto» i_0123 = foo_0123(); 122 | «k:auto» i_0b101 = foo_0B010(); 123 | «k:auto» i_123 = foo_123(); 124 | -------------------------------------------------------------------------------- /cpp/keyword/test.txt: -------------------------------------------------------------------------------- 1 | alignas 2 | alignof 3 | and 4 | and_eq 5 | asm 6 | atomic_cancel 7 | atomic_commit 8 | atomic_noexcept 9 | auto 10 | bitand 11 | bitor 12 | break 13 | case 14 | catch 15 | class 16 | co_await 17 | co_return 18 | co_yield 19 | compl 20 | concept 21 | const 22 | const_cast 23 | constexpr 24 | consteval 25 | continue 26 | decltype 27 | default 28 | delete 29 | do 30 | dynamic_cast 31 | else 32 | enum 33 | explicit 34 | export 35 | extern 36 | final 37 | for 38 | friend 39 | goto 40 | if 41 | import 42 | inline 43 | module 44 | mutable 45 | namespace 46 | new 47 | noexcept 48 | not 49 | not_eq 50 | operator 51 | or 52 | or_eq 53 | override 54 | private 55 | protected 56 | public 57 | register 58 | reinterpret_cast 59 | requires 60 | return 61 | sizeof 62 | sizeof... 63 | static 64 | static_assert 65 | static_cast 66 | struct 67 | switch 68 | synchronized 69 | template 70 | this 71 | thread_local 72 | throw 73 | audit 74 | axiom 75 | transaction_safe 76 | transaction_safe_dynamic 77 | try 78 | typedef 79 | typeid 80 | typename 81 | union 82 | using 83 | virtual 84 | volatile 85 | while 86 | xor 87 | xor_eq 88 | 89 | true 90 | false 91 | nullptr 92 | 93 | bool 94 | char 95 | char16_t 96 | char32_t 97 | double 98 | float 99 | int 100 | long 101 | short 102 | signed 103 | unsigned 104 | void 105 | wchar_t 106 | -------------------------------------------------------------------------------- /cpp/keyword/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «k:alignas» 2 | «k:alignof» 3 | «k:and» 4 | «k:and_eq» 5 | «k:asm» 6 | «k:atomic_cancel» 7 | «k:atomic_commit» 8 | «k:atomic_noexcept» 9 | «k:auto» 10 | «k:bitand» 11 | «k:bitor» 12 | «k:break» 13 | «k:case» 14 | «k:catch» 15 | «k:class» 16 | «k:co_await» 17 | «k:co_return» 18 | «k:co_yield» 19 | «k:compl» 20 | «k:concept» 21 | «k:const» 22 | «k:const_cast» 23 | «k:constexpr» 24 | «k:consteval» 25 | «k:continue» 26 | «k:decltype» 27 | «k:default» 28 | «k:delete» 29 | «k:do» 30 | «k:dynamic_cast» 31 | «k:else» 32 | «k:enum» 33 | «k:explicit» 34 | «k:export» 35 | «k:extern» 36 | «k:final» 37 | «k:for» 38 | «k:friend» 39 | «k:goto» 40 | «k:if» 41 | «k:import» 42 | «k:inline» 43 | «k:module» 44 | «k:mutable» 45 | «k:namespace» 46 | «k:new» 47 | «k:noexcept» 48 | «k:not» 49 | «k:not_eq» 50 | «k:operator» 51 | «k:or» 52 | «k:or_eq» 53 | «k:override» 54 | «k:private» 55 | «k:protected» 56 | «k:public» 57 | «k:register» 58 | «k:reinterpret_cast» 59 | «k:requires» 60 | «k:return» 61 | «k:sizeof» 62 | «k:sizeof»«f:...» 63 | «k:static» 64 | «k:static_assert» 65 | «k:static_cast» 66 | «k:struct» 67 | «k:switch» 68 | «k:synchronized» 69 | «k:template» 70 | «k:this» 71 | «k:thread_local» 72 | «k:throw» 73 | «k:audit» 74 | «k:axiom» 75 | «k:transaction_safe» 76 | «k:transaction_safe_dynamic» 77 | «k:try» 78 | «k:typedef» 79 | «k:typeid» 80 | «k:typename» 81 | «k:union» 82 | «k:using» 83 | «k:virtual» 84 | «k:volatile» 85 | «k:while» 86 | «k:xor» 87 | «k:xor_eq» 88 | 89 | «c:true» 90 | «c:false» 91 | «c:nullptr» 92 | 93 | «t:bool» 94 | «t:char» 95 | «t:char16_t» 96 | «t:char32_t» 97 | «t:double» 98 | «t:float» 99 | «t:int» 100 | «t:long» 101 | «t:short» 102 | «t:signed» 103 | «t:unsigned» 104 | «t:void» 105 | «t:wchar_t» 106 | -------------------------------------------------------------------------------- /cpp/preview/test.txt: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define EXPAND_ME __FILE__ " : " __LINE__ 4 | 5 | constexpr auto pi = 314LLu; 6 | thread_local decltype(pi) rage = 0b10; 7 | 8 | [[deprecated("abc")]] char16_t *f() noexcept { return nullptr; } 9 | 10 | template struct Foo { 11 | static_assert(std::is_floating_point::value, 12 | "Foo: T must be floating point"); 13 | }; 14 | 15 | struct A final : Foo { 16 | A() = default; 17 | [[noreturn]] virtual void foo() override; 18 | }; 19 | 20 | template concept bool EqualityComparable = requires(T a, T b) { 21 | { a == b } -> bool; 22 | }; 23 | -------------------------------------------------------------------------------- /cpp/preview/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «p:#pragma once» 2 | 3 | «p:#define» EXPAND_ME «p:__FILE__» «s:" : "» «p:__LINE__» 4 | 5 | «k:constexpr» «k:auto» pi = «c:314»«k:LLu»; 6 | «k:thread_local» «k:decltype»(pi) rage = «k:0b»«c:10»; 7 | 8 | [[«c:deprecated»(«s:"abc"»)]] «t:char16_t» *f() «k:noexcept» { «k:return» «c:nullptr»; } 9 | 10 | «k:template» <«k:typename» T> «k:struct» Foo { 11 | «k:static_assert»(std::is_floating_point::value, 12 | «s:"Foo: T must be floating point"»); 13 | }; 14 | 15 | «k:struct» A «k:final» : Foo { 16 | A() = «k:default»; 17 | [[«c:noreturn»]] «k:virtual» «t:void» foo() «k:override»; 18 | }; 19 | 20 | «k:template» <«k:typename» T> «k:concept» «t:bool» EqualityComparable = «k:requires»(T a, T b) { 21 | { a == b } -> «t:bool»; 22 | }; 23 | -------------------------------------------------------------------------------- /cpp/raw/test.txt: -------------------------------------------------------------------------------- 1 | bool 2 | char 3 | char8_t 4 | char16_t 5 | char32_t 6 | double 7 | float 8 | int 9 | long 10 | short 11 | signed 12 | unsigned 13 | void 14 | wchar_t 15 | 16 | false 17 | nullptr 18 | true 19 | 20 | #define 21 | #defined 22 | #elif 23 | #else 24 | #endif 25 | #error 26 | #if 27 | #ifdef 28 | #ifndef 29 | #include 30 | #line 31 | #pragma STDC CX_LIMITED_RANGE 32 | #pragma STDC FENV_ACCESS 33 | #pragma STDC FP_CONTRACT 34 | #pragma once 35 | #pragma pack 36 | #pragma 37 | #undef 38 | _Pragma 39 | __DATE__ 40 | __FILE__ 41 | __LINE__ 42 | __STDCPP_STRICT_POINTER_SAFETY__ 43 | __STDCPP_THREADS__ 44 | __STDC_HOSTED__ 45 | __STDC_ISO_10646__ 46 | __STDC_MB_MIGHT_NEQ_WC__ 47 | __STDC_VERSION__ 48 | __STDC__ 49 | __TIME__ 50 | __VA_ARGS__ 51 | __VA_OPT__ 52 | __cplusplus 53 | __has_include 54 | __has_cpp_attribute 55 | 56 | alignas 57 | alignof 58 | and 59 | and_eq 60 | asm 61 | atomic_cancel 62 | atomic_commit 63 | atomic_noexcept 64 | auto 65 | bitand 66 | bitor 67 | break 68 | case 69 | catch 70 | class 71 | compl 72 | concept 73 | const 74 | const_cast 75 | consteval 76 | constexpr 77 | constinit 78 | continue 79 | decltype 80 | default 81 | delete 82 | do 83 | dynamic_cast 84 | else 85 | enum 86 | explicit 87 | export 88 | extern 89 | final 90 | for 91 | friend 92 | goto 93 | if 94 | import 95 | inline 96 | module 97 | mutable 98 | namespace 99 | new 100 | noexcept 101 | not 102 | not_eq 103 | operator 104 | or 105 | or_eq 106 | override 107 | private 108 | protected 109 | public 110 | register 111 | reinterpret_cast 112 | requires 113 | return 114 | sizeof 115 | sizeof... 116 | static 117 | static_assert 118 | static_cast 119 | struct 120 | switch 121 | synchronized 122 | template 123 | this 124 | thread_local 125 | throw 126 | audit 127 | axiom 128 | transaction_safe 129 | transaction_safe_dynamic 130 | try 131 | typedef 132 | typeid 133 | typename 134 | union 135 | using 136 | virtual 137 | volatile 138 | while 139 | xor 140 | xor_eq 141 | 142 | [[carries_dependency]] 143 | [[deprecated]] 144 | [[deprecated("abc")]] 145 | [[fallthrough]] 146 | [[maybe_unused]] 147 | [[nodiscard]] 148 | [[noreturn]] 149 | [[optimize_for_synchronized]] 150 | [[likely]] 151 | [[unlikely]] 152 | [[no_unique_address]] 153 | [[expects]] 154 | [[ensures]] 155 | [[assert]] 156 | 157 | ... 158 | 159 | 00 160 | 01 161 | 03 162 | 02 163 | 03 164 | 04 165 | 05 166 | 06 167 | 07 168 | 169 | 0B101 + 01234567L; 170 | 171 | 0b10Ul + 0B1 == 123; 172 | 173 | 0x12A= 0X2A 174 | 175 | 0b1; 176 | 0b1u; 177 | 0b1ul; 178 | 0b1ull; 179 | 0b1llu; 180 | 0b1U; 181 | 0b1LU; 182 | 0x1 183 | 0x2 184 | int d = 42; 185 | int o = 052; 186 | int x = 0x2a; 187 | int X = 0X2A; 188 | int b = 0b101010; 189 | unsigned long long l1 = 18446744073709550592ull; 190 | unsigned long long l2 = 18446744073709550592llu; 191 | unsigned long long l3 = 18446744073709550592uLL; 192 | unsigned long long l4 = 18'446'744'073'709'550'592LLU; 193 | 1U 194 | 0xDeAdBaBeU == 0XdeadBABEu 195 | 196 | abool 197 | achar 198 | achar16_t 199 | achar32_t 200 | adouble 201 | afloat 202 | aint 203 | along 204 | ashort 205 | asigned 206 | aunsigned 207 | avoid 208 | awchar_t 209 | boola 210 | chara 211 | char16_ta 212 | char32_ta 213 | doublea 214 | floata 215 | inta 216 | longa 217 | shorta 218 | signeda 219 | unsigneda 220 | voida 221 | wchar_ta 222 | 223 | afalse 224 | anullptr 225 | atrue 226 | falsea 227 | nullptra 228 | truea 229 | 230 | a#define 231 | a#defined 232 | a#elif 233 | a#else 234 | a#endif 235 | a#error 236 | a#if 237 | a#ifdef 238 | a#ifndef 239 | a#include 240 | a#line 241 | a#pragma STDC CX_LIMITED_RANGE 242 | a#pragma STDC FENV_ACCESS 243 | a#pragma STDC FP_CONTRACT 244 | a#pragma once 245 | a#pragma pack 246 | a#pragma 247 | a#undef 248 | a_Pragma 249 | a__DATE__ 250 | a__FILE__ 251 | a__LINE__ 252 | a__STDCPP_STRICT_POINTER_SAFETY__ 253 | a__STDCPP_THREADS__ 254 | a__STDC_HOSTED__ 255 | a__STDC_ISO_10646__ 256 | a__STDC_MB_MIGHT_NEQ_WC__ 257 | a__STDC_VERSION__ 258 | a__STDC__ 259 | a__TIME__ 260 | a__VA_ARGS__ 261 | a__VA_OPT__ 262 | a__cplusplus 263 | a__has_include 264 | #definea 265 | #defineda 266 | #elifa 267 | #elsea 268 | #endifa 269 | #errora 270 | #ifa 271 | #ifdefa 272 | #ifndefa 273 | #includea 274 | #linea 275 | #pragma STDC CX_LIMITED_RANGEa 276 | #pragma STDC FENV_ACCESSa 277 | #pragma STDC FP_CONTRACTa 278 | #pragma oncea 279 | #pragma packa 280 | #pragmaa 281 | #undefa 282 | _Pragmaa 283 | __DATE__a 284 | __FILE__a 285 | __LINE__a 286 | __STDCPP_STRICT_POINTER_SAFETY__a 287 | __STDCPP_THREADS__a 288 | __STDC_HOSTED__a 289 | __STDC_ISO_10646__a 290 | __STDC_MB_MIGHT_NEQ_WC__a 291 | __STDC_VERSION__a 292 | __STDC__a 293 | __TIME__a 294 | __VA_ARGS__a 295 | __cplusplusa 296 | __has_includea 297 | 298 | aalignas 299 | aalignof 300 | aand 301 | aand_eq 302 | aasm 303 | aatomic_cancel 304 | aatomic_commit 305 | aatomic_noexcept 306 | aauto 307 | abitand 308 | abitor 309 | abreak 310 | acase 311 | acatch 312 | aclass 313 | acompl 314 | aconcept 315 | aconst 316 | aconst_cast 317 | aconstexpr 318 | aconsteval 319 | aconstinit 320 | acontinue 321 | adecltype 322 | adefault 323 | adelete 324 | ado 325 | adynamic_cast 326 | aelse 327 | aenum 328 | aexplicit 329 | aexport 330 | aextern 331 | afinal 332 | afor 333 | afriend 334 | agoto 335 | aif 336 | aimport 337 | ainline 338 | amodule 339 | amutable 340 | anamespace 341 | anew 342 | anoexcept 343 | anot 344 | anot_eq 345 | aoperator 346 | aor 347 | aor_eq 348 | aoverride 349 | aprivate 350 | aprotected 351 | apublic 352 | aregister 353 | areinterpret_cast 354 | arequires 355 | areturn 356 | asizeof 357 | asizeof... 358 | astatic 359 | astatic_assert 360 | astatic_cast 361 | astruct 362 | aswitch 363 | asynchronized 364 | atemplate 365 | athis 366 | athread_local 367 | athrow 368 | aaudit 369 | aaxiom 370 | atransaction_safe 371 | atransaction_safe_dynamic 372 | atry 373 | atypedef 374 | atypeid 375 | atypename 376 | aunion 377 | ausing 378 | avirtual 379 | avolatile 380 | awhile 381 | axor 382 | axor_eq 383 | alignasa 384 | alignofa 385 | anda 386 | and_eqa 387 | asma 388 | atomic_cancela 389 | atomic_commita 390 | atomic_noexcepta 391 | autoa 392 | bitanda 393 | bitora 394 | breaka 395 | casea 396 | catcha 397 | classa 398 | compla 399 | concepta 400 | consta 401 | const_casta 402 | constexpra 403 | constevala 404 | continuea 405 | decltypea 406 | defaulta 407 | deletea 408 | doa 409 | dynamic_casta 410 | elsea 411 | enuma 412 | explicita 413 | exporta 414 | externa 415 | finala 416 | fora 417 | frienda 418 | gotoa 419 | ifa 420 | importa 421 | inlinea 422 | modulea 423 | mutablea 424 | namespacea 425 | newa 426 | noexcepta 427 | nota 428 | not_eqa 429 | operatora 430 | ora 431 | or_eqa 432 | overridea 433 | privatea 434 | protecteda 435 | publica 436 | registera 437 | reinterpret_casta 438 | requiresa 439 | returna 440 | sizeofa 441 | sizeof...a 442 | statica 443 | static_asserta 444 | static_casta 445 | structa 446 | switcha 447 | synchronizeda 448 | templatea 449 | thisa 450 | thread_locala 451 | throwa 452 | audita 453 | axioma 454 | transaction_safea 455 | transaction_safe_dynamica 456 | trya 457 | typedefa 458 | typeida 459 | typenamea 460 | uniona 461 | usinga 462 | virtuala 463 | volatilea 464 | whilea 465 | xora 466 | xor_eqa 467 | 468 | carries_dependency]] 469 | deprecated]] 470 | fallthrough]] 471 | maybe_unused]] 472 | nodiscard]] 473 | noreturn]] 474 | optimize_for_synchronized]] 475 | likely]] 476 | unlikely]] 477 | no_unique_address]] 478 | expects]] 479 | ensures]] 480 | assert]] 481 | 482 | [[carries_dependency 483 | [[deprecated 484 | [[fallthrough 485 | [[maybe_unused 486 | [[nodiscard 487 | [[noreturn 488 | [[optimize_for_synchronized 489 | [[likely 490 | [[unlikely 491 | [[no_unique_address 492 | [[expects 493 | [[ensures 494 | [[assert 495 | 496 | 08 497 | 09 498 | 019 499 | 10b1 500 | 10xa 501 | 01234567889 502 | 0x3Ulll 503 | -------------------------------------------------------------------------------- /cpp/raw/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «t:bool» 2 | «t:char» 3 | «t:char8_t» 4 | «t:char16_t» 5 | «t:char32_t» 6 | «t:double» 7 | «t:float» 8 | «t:int» 9 | «t:long» 10 | «t:short» 11 | «t:signed» 12 | «t:unsigned» 13 | «t:void» 14 | «t:wchar_t» 15 | 16 | «c:false» 17 | «c:nullptr» 18 | «c:true» 19 | 20 | «p:#define» 21 | «p:#defined» 22 | «p:#elif» 23 | «p:#else» 24 | «p:#endif» 25 | «p:#error» 26 | «p:#if» 27 | «p:#ifdef» 28 | «p:#ifndef» 29 | «p:#include» 30 | «p:#line» 31 | «p:#pragma STDC CX_LIMITED_RANGE» 32 | «p:#pragma STDC FENV_ACCESS» 33 | «p:#pragma STDC FP_CONTRACT» 34 | «p:#pragma once» 35 | «p:#pragma pack» 36 | «p:#pragma» 37 | «p:#undef» 38 | «p:_Pragma» 39 | «p:__DATE__» 40 | «p:__FILE__» 41 | «p:__LINE__» 42 | «p:__STDCPP_STRICT_POINTER_SAFETY__» 43 | «p:__STDCPP_THREADS__» 44 | «p:__STDC_HOSTED__» 45 | «p:__STDC_ISO_10646__» 46 | «p:__STDC_MB_MIGHT_NEQ_WC__» 47 | «p:__STDC_VERSION__» 48 | «p:__STDC__» 49 | «p:__TIME__» 50 | «p:__VA_ARGS__» 51 | «p:__VA_OPT__» 52 | «p:__cplusplus» 53 | «p:__has_include» 54 | «p:__has_cpp_attribute» 55 | 56 | «k:alignas» 57 | «k:alignof» 58 | «k:and» 59 | «k:and_eq» 60 | «k:asm» 61 | «k:atomic_cancel» 62 | «k:atomic_commit» 63 | «k:atomic_noexcept» 64 | «k:auto» 65 | «k:bitand» 66 | «k:bitor» 67 | «k:break» 68 | «k:case» 69 | «k:catch» 70 | «k:class» 71 | «k:compl» 72 | «k:concept» 73 | «k:const» 74 | «k:const_cast» 75 | «k:consteval» 76 | «k:constexpr» 77 | «k:constinit» 78 | «k:continue» 79 | «k:decltype» 80 | «k:default» 81 | «k:delete» 82 | «k:do» 83 | «k:dynamic_cast» 84 | «k:else» 85 | «k:enum» 86 | «k:explicit» 87 | «k:export» 88 | «k:extern» 89 | «k:final» 90 | «k:for» 91 | «k:friend» 92 | «k:goto» 93 | «k:if» 94 | «k:import» 95 | «k:inline» 96 | «k:module» 97 | «k:mutable» 98 | «k:namespace» 99 | «k:new» 100 | «k:noexcept» 101 | «k:not» 102 | «k:not_eq» 103 | «k:operator» 104 | «k:or» 105 | «k:or_eq» 106 | «k:override» 107 | «k:private» 108 | «k:protected» 109 | «k:public» 110 | «k:register» 111 | «k:reinterpret_cast» 112 | «k:requires» 113 | «k:return» 114 | «k:sizeof» 115 | «k:sizeof»«f:...» 116 | «k:static» 117 | «k:static_assert» 118 | «k:static_cast» 119 | «k:struct» 120 | «k:switch» 121 | «k:synchronized» 122 | «k:template» 123 | «k:this» 124 | «k:thread_local» 125 | «k:throw» 126 | «k:audit» 127 | «k:axiom» 128 | «k:transaction_safe» 129 | «k:transaction_safe_dynamic» 130 | «k:try» 131 | «k:typedef» 132 | «k:typeid» 133 | «k:typename» 134 | «k:union» 135 | «k:using» 136 | «k:virtual» 137 | «k:volatile» 138 | «k:while» 139 | «k:xor» 140 | «k:xor_eq» 141 | 142 | [[«c:carries_dependency»]] 143 | [[«c:deprecated»]] 144 | [[«c:deprecated»(«s:"abc"»)]] 145 | [[«c:fallthrough»]] 146 | [[«c:maybe_unused»]] 147 | [[«c:nodiscard»]] 148 | [[«c:noreturn»]] 149 | [[«c:optimize_for_synchronized»]] 150 | [[«c:likely»]] 151 | [[«c:unlikely»]] 152 | [[«c:no_unique_address»]] 153 | [[«c:expects»]] 154 | [[«c:ensures»]] 155 | [[«c:assert»]] 156 | 157 | «f:...» 158 | 159 | «k:0»«c:0» 160 | «k:0»«c:1» 161 | «k:0»«c:3» 162 | «k:0»«c:2» 163 | «k:0»«c:3» 164 | «k:0»«c:4» 165 | «k:0»«c:5» 166 | «k:0»«c:6» 167 | «k:0»«c:7» 168 | 169 | «k:0B»«c:101» + «k:0»«c:1234567»«k:L»; 170 | 171 | «k:0b»«c:10»«k:Ul» + «k:0B»«c:1» == 123; 172 | 173 | «k:0x»«c:12A»= «k:0X»«c:2A» 174 | 175 | «k:0b»«c:1»; 176 | «k:0b»«c:1»«k:u»; 177 | «k:0b»«c:1»«k:ul»; 178 | «k:0b»«c:1»«k:ull»; 179 | «k:0b»«c:1»«k:llu»; 180 | «k:0b»«c:1»«k:U»; 181 | «k:0b»«c:1»«k:LU»; 182 | «k:0x»«c:1» 183 | «k:0x»«c:2» 184 | «t:int» d = 42; 185 | «t:int» o = «k:0»«c:52»; 186 | «t:int» x = «k:0x»«c:2a»; 187 | «t:int» X = «k:0X»«c:2A»; 188 | «t:int» b = «k:0b»«c:101010»; 189 | «t:unsigned» «t:long» «t:long» l1 = «c:18446744073709550592»«k:ull»; 190 | «t:unsigned» «t:long» «t:long» l2 = «c:18446744073709550592»«k:llu»; 191 | «t:unsigned» «t:long» «t:long» l3 = «c:18446744073709550592»«k:uLL»; 192 | «t:unsigned» «t:long» «t:long» l4 = «c:18'446'744'073'709'550'592»«k:LLU»; 193 | «c:1»«k:U» 194 | «k:0x»«c:DeAdBaBe»«k:U» == «k:0X»«c:deadBABE»«k:u» 195 | 196 | abool 197 | achar 198 | achar16_t 199 | achar32_t 200 | adouble 201 | afloat 202 | aint 203 | along 204 | ashort 205 | asigned 206 | aunsigned 207 | avoid 208 | awchar_t 209 | boola 210 | chara 211 | char16_ta 212 | char32_ta 213 | doublea 214 | floata 215 | inta 216 | longa 217 | shorta 218 | signeda 219 | unsigneda 220 | voida 221 | wchar_ta 222 | 223 | afalse 224 | anullptr 225 | atrue 226 | falsea 227 | nullptra 228 | truea 229 | 230 | a«p:#define» 231 | a«p:#defined» 232 | a«p:#elif» 233 | a«p:#else» 234 | a«p:#endif» 235 | a«p:#error» 236 | a«p:#if» 237 | a«p:#ifdef» 238 | a«p:#ifndef» 239 | a«p:#include» 240 | a«p:#line» 241 | a«p:#pragma STDC CX_LIMITED_RANGE» 242 | a«p:#pragma STDC FENV_ACCESS» 243 | a«p:#pragma STDC FP_CONTRACT» 244 | a«p:#pragma once» 245 | a«p:#pragma pack» 246 | a«p:#pragma» 247 | a«p:#undef» 248 | a«p:_Pragma» 249 | a«p:__DATE__» 250 | a«p:__FILE__» 251 | a«p:__LINE__» 252 | a«p:__STDCPP_STRICT_POINTER_SAFETY__» 253 | a«p:__STDCPP_THREADS__» 254 | a«p:__STDC_HOSTED__» 255 | a«p:__STDC_ISO_10646__» 256 | a«p:__STDC_MB_MIGHT_NEQ_WC__» 257 | a«p:__STDC_VERSION__» 258 | a«p:__STDC__» 259 | a«p:__TIME__» 260 | a«p:__VA_ARGS__» 261 | a«p:__VA_OPT__» 262 | a«p:__cplusplus» 263 | a«p:__has_include» 264 | «p:#define»a 265 | «p:#defined»a 266 | «p:#elif»a 267 | «p:#else»a 268 | «p:#endif»a 269 | «p:#error»a 270 | «p:#if»a 271 | «p:#ifdef»a 272 | «p:#ifndef»a 273 | «p:#include»a 274 | «p:#line»a 275 | «p:#pragma STDC CX_LIMITED_RANGE»a 276 | «p:#pragma STDC FENV_ACCESS»a 277 | «p:#pragma STDC FP_CONTRACT»a 278 | «p:#pragma once»a 279 | «p:#pragma pack»a 280 | «p:#pragma»a 281 | «p:#undef»a 282 | «p:_Pragma»a 283 | «p:__DATE__»a 284 | «p:__FILE__»a 285 | «p:__LINE__»a 286 | «p:__STDCPP_STRICT_POINTER_SAFETY__»a 287 | «p:__STDCPP_THREADS__»a 288 | «p:__STDC_HOSTED__»a 289 | «p:__STDC_ISO_10646__»a 290 | «p:__STDC_MB_MIGHT_NEQ_WC__»a 291 | «p:__STDC_VERSION__»a 292 | «p:__STDC__»a 293 | «p:__TIME__»a 294 | «p:__VA_ARGS__»a 295 | «p:__cplusplus»a 296 | «p:__has_include»a 297 | 298 | aalignas 299 | aalignof 300 | aand 301 | aand_eq 302 | aasm 303 | aatomic_cancel 304 | aatomic_commit 305 | aatomic_«k:noexcept» 306 | aauto 307 | abitand 308 | abitor 309 | abreak 310 | acase 311 | acatch 312 | aclass 313 | acompl 314 | aconcept 315 | aconst 316 | aconst_cast 317 | aconstexpr 318 | aconsteval 319 | aconstinit 320 | acontinue 321 | adecltype 322 | adefault 323 | adelete 324 | ado 325 | adynamic_cast 326 | aelse 327 | aenum 328 | aexplicit 329 | aexport 330 | aextern 331 | afinal 332 | afor 333 | afriend 334 | agoto 335 | aif 336 | aimport 337 | ainline 338 | amodule 339 | amutable 340 | anamespace 341 | anew 342 | anoexcept 343 | anot 344 | anot_eq 345 | aoperator 346 | aor 347 | aor_eq 348 | aoverride 349 | aprivate 350 | aprotected 351 | apublic 352 | aregister 353 | areinterpret_cast 354 | arequires 355 | areturn 356 | asizeof 357 | asizeof«f:...» 358 | astatic 359 | astatic_assert 360 | astatic_cast 361 | astruct 362 | aswitch 363 | asynchronized 364 | atemplate 365 | athis 366 | athread_local 367 | athrow 368 | aaudit 369 | aaxiom 370 | atransaction_safe 371 | atransaction_safe_dynamic 372 | atry 373 | atypedef 374 | atypeid 375 | atypename 376 | aunion 377 | ausing 378 | avirtual 379 | avolatile 380 | awhile 381 | axor 382 | axor_eq 383 | alignasa 384 | alignofa 385 | anda 386 | «k:and»_eqa 387 | asma 388 | atomic_cancela 389 | atomic_commita 390 | atomic_noexcepta 391 | autoa 392 | bitanda 393 | bitora 394 | breaka 395 | casea 396 | catcha 397 | classa 398 | compla 399 | concepta 400 | consta 401 | «k:const»_casta 402 | constexpra 403 | constevala 404 | continuea 405 | decltypea 406 | defaulta 407 | deletea 408 | doa 409 | dynamic_casta 410 | elsea 411 | enuma 412 | explicita 413 | exporta 414 | externa 415 | finala 416 | fora 417 | frienda 418 | gotoa 419 | ifa 420 | importa 421 | inlinea 422 | modulea 423 | mutablea 424 | namespacea 425 | newa 426 | noexcepta 427 | nota 428 | «k:not»_eqa 429 | operatora 430 | ora 431 | «k:or»_eqa 432 | overridea 433 | privatea 434 | protecteda 435 | publica 436 | registera 437 | reinterpret_casta 438 | requiresa 439 | returna 440 | sizeofa 441 | «k:sizeof»«f:...»a 442 | statica 443 | «k:static»_asserta 444 | «k:static»_casta 445 | structa 446 | switcha 447 | synchronizeda 448 | templatea 449 | thisa 450 | thread_locala 451 | throwa 452 | audita 453 | axioma 454 | transaction_safea 455 | «k:transaction_safe»_dynamica 456 | trya 457 | typedefa 458 | typeida 459 | typenamea 460 | uniona 461 | usinga 462 | virtuala 463 | volatilea 464 | whilea 465 | xora 466 | «k:xor»_eqa 467 | 468 | carries_dependency]] 469 | deprecated]] 470 | fallthrough]] 471 | maybe_unused]] 472 | nodiscard]] 473 | noreturn]] 474 | optimize_«k:for»_«k:synchronized»]] 475 | likely]] 476 | unlikely]] 477 | no_unique_address]] 478 | expects]] 479 | ensures]] 480 | assert]] 481 | 482 | [[carries_dependency 483 | [[deprecated 484 | [[fallthrough 485 | [[maybe_unused 486 | [[nodiscard 487 | [[noreturn 488 | [[optimize_«k:for»_«k:synchronized» 489 | [[likely 490 | [[unlikely 491 | [[no_unique_address 492 | [[expects 493 | [[ensures 494 | [[assert 495 | 496 | 08 497 | 09 498 | «k:0»«c:1»9 499 | 10b1 500 | 10xa 501 | «k:0»«c:1234567»889 502 | «k:0x»«c:3»«k:Ull»l 503 | -------------------------------------------------------------------------------- /cpp/string-literal/test.txt: -------------------------------------------------------------------------------- 1 | auto c = "hello"; 2 | auto c = u8"hello"; 3 | auto c = L"hello"; 4 | auto c = u"hello"; 5 | auto c = U"hello"; 6 | auto c = R"("Hello \ world")"; 7 | auto c = u8R"("Hello \ world")"; 8 | auto c = LR"("Hello \ world")"; 9 | auto c = uR"("Hello \ world")"; 10 | auto c = UR"("Hello \ world")"; 11 | auto c = "hello"s; 12 | auto c = u8"hello"s; 13 | auto c = L"hello"s; 14 | auto c = u"hello"s; 15 | auto c = U"hello"s; 16 | auto c = R"("Hello \ world")"s; 17 | auto c = u8R"("Hello \ world")"s; 18 | auto c = LR"("Hello \ world")"s; 19 | auto c = uR"("Hello \ world")"s; 20 | auto c = UR"("Hello \ world")"s; 21 | auto c = uR"foo(ahah)foo"; 22 | auto c = "hello"; 23 | auto c = uR"foo( 24 | Hello 25 | World 26 | )foo"; 27 | auto c = "abcd"; 28 | auto c = "yes\\no"; 29 | auto c = u8"Hello World"; 30 | auto c = u8"\U0001F607 is O:-)"; 31 | auto c = L"zyxw"; 32 | auto c = L"hello\ngoodbye"; 33 | auto c = u"hello"; 34 | auto c = U"hello"; 35 | auto c = R"(An unescaped \ character)"; 36 | auto c = LR"(An unescaped \ character)"; 37 | auto c = u8R"(An unescaped \ character)"; 38 | auto c = uR"(An unescaped \ character)"; 39 | auto c = UR"(An unescaped \ character)"; 40 | auto c = LR"(hello 41 | goodbye)"; 42 | auto c{"hello"s}; 43 | auto c{u8"Hello World"}; 44 | auto c{L"hello"s}; 45 | auto c{u"hello"s}; 46 | auto c{U"hello"s}; 47 | auto c{UR"(She said "hello.")"s}; 48 | auto c = L"Hello!"; 49 | auto c = (wcslen(str) + 1) * sizeof(wchar_t); 50 | auto c = L"hello"; 51 | auto c = "12" "34"; 52 | auto c = "12\ 53 | 34"; 54 | auto c = "hello" " " " world"; 55 | auto c = u8"hello" " "s u8"world"s; 56 | auto c = ":-)"; 57 | auto c = L"😉 = \U0001F609 is ;-)"; 58 | auto c = u8"😇 = \U0001F607 is O:-)"; 59 | auto c = u"😃 = \U0001F603 is :-D"; 60 | auto c = U"😎 = \U0001F60E is B-)"; 61 | auto c = R"xyz()")xyz"; 62 | auto c = R"()")"; 63 | -------------------------------------------------------------------------------- /cpp/string-literal/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «k:auto» c = «s:"hello"»; 2 | «k:auto» c = «c:u8»«s:"hello"»; 3 | «k:auto» c = «c:L»«s:"hello"»; 4 | «k:auto» c = «c:u»«s:"hello"»; 5 | «k:auto» c = «c:U»«s:"hello"»; 6 | «k:auto» c = «c:R"(»«s:"Hello \ world"»«c:)"»; 7 | «k:auto» c = «c:u8R"(»«s:"Hello \ world"»«c:)"»; 8 | «k:auto» c = «c:LR"(»«s:"Hello \ world"»«c:)"»; 9 | «k:auto» c = «c:uR"(»«s:"Hello \ world"»«c:)"»; 10 | «k:auto» c = «c:UR"(»«s:"Hello \ world"»«c:)"»; 11 | «k:auto» c = «s:"hello"»«c:s»; 12 | «k:auto» c = «c:u8»«s:"hello"»«c:s»; 13 | «k:auto» c = «c:L»«s:"hello"»«c:s»; 14 | «k:auto» c = «c:u»«s:"hello"»«c:s»; 15 | «k:auto» c = «c:U»«s:"hello"»«c:s»; 16 | «k:auto» c = «c:R"(»«s:"Hello \ world"»«c:)"s»; 17 | «k:auto» c = «c:u8R"(»«s:"Hello \ world"»«c:)"s»; 18 | «k:auto» c = «c:LR"(»«s:"Hello \ world"»«c:)"s»; 19 | «k:auto» c = «c:uR"(»«s:"Hello \ world"»«c:)"s»; 20 | «k:auto» c = «c:UR"(»«s:"Hello \ world"»«c:)"s»; 21 | «k:auto» c = «c:uR"foo(»«s:ahah»«c:)foo"»; 22 | «k:auto» c = «s:"hello"»; 23 | «k:auto» c = «c:uR"foo(»«s: 24 | Hello 25 | World 26 | »«c:)foo"»; 27 | «k:auto» c = «s:"abcd"»; 28 | «k:auto» c = «s:"yes\\no"»; 29 | «k:auto» c = «c:u8»«s:"Hello World"»; 30 | «k:auto» c = «c:u8»«s:"\U0001F607 is O:-)"»; 31 | «k:auto» c = «c:L»«s:"zyxw"»; 32 | «k:auto» c = «c:L»«s:"hello\ngoodbye"»; 33 | «k:auto» c = «c:u»«s:"hello"»; 34 | «k:auto» c = «c:U»«s:"hello"»; 35 | «k:auto» c = «c:R"(»«s:An unescaped \ character»«c:)"»; 36 | «k:auto» c = «c:LR"(»«s:An unescaped \ character»«c:)"»; 37 | «k:auto» c = «c:u8R"(»«s:An unescaped \ character»«c:)"»; 38 | «k:auto» c = «c:uR"(»«s:An unescaped \ character»«c:)"»; 39 | «k:auto» c = «c:UR"(»«s:An unescaped \ character»«c:)"»; 40 | «k:auto» c = «c:LR"(»«s:hello 41 | goodbye»«c:)"»; 42 | «k:auto» c{«s:"hello"»«c:s»}; 43 | «k:auto» c{«c:u8»«s:"Hello World"»}; 44 | «k:auto» c{«c:L»«s:"hello"»«c:s»}; 45 | «k:auto» c{«c:u»«s:"hello"»«c:s»}; 46 | «k:auto» c{«c:U»«s:"hello"»«c:s»}; 47 | «k:auto» c{«c:UR"(»«s:She said "hello."»«c:)"s»}; 48 | «k:auto» c = «c:L»«s:"Hello!"»; 49 | «k:auto» c = (wcslen(str) + 1) * «k:sizeof»(«t:wchar_t»); 50 | «k:auto» c = «c:L»«s:"hello"»; 51 | «k:auto» c = «s:"12"» «s:"34"»; 52 | «k:auto» c = «s:"12\ 53 | 34"»; 54 | «k:auto» c = «s:"hello"» «s:" "» «s:" world"»; 55 | «k:auto» c = «c:u8»«s:"hello"» «s:" "»«c:s» «c:u8»«s:"world"»«c:s»; 56 | «k:auto» c = «s:":-)"»; 57 | «k:auto» c = «c:L»«s:"😉 = \U0001F609 is ;-)"»; 58 | «k:auto» c = «c:u8»«s:"😇 = \U0001F607 is O:-)"»; 59 | «k:auto» c = «c:u»«s:"😃 = \U0001F603 is :-D"»; 60 | «k:auto» c = «c:U»«s:"😎 = \U0001F60E is B-)"»; 61 | «k:auto» c = «c:R"xyz(»«s:)"»«c:)xyz"»; 62 | «k:auto» c = «c:R"()"»)"; 63 | -------------------------------------------------------------------------------- /cpp/template/test.txt: -------------------------------------------------------------------------------- 1 | template class X {}; 2 | templateclass X {}; 3 | templateclass X {}; 4 | template< class T1,class T2>class X {}; 5 | template < class T1,class T2>class X {}; 6 | template class X {}; 7 | template class X {}; 8 | templateclass X {}; 9 | templateclass X {}; 10 | template< typename T1,typename T2>class X {}; 11 | template < typename T1,typename T2>class X {}; 12 | template class X {}; 13 | template class T>struct X{}; 14 | -------------------------------------------------------------------------------- /cpp/template/test.txt.faceup: -------------------------------------------------------------------------------- 1 | «k:template»<«k:class» T1, «k:class» T2 > «k:class» X {}; 2 | «k:template»<«k:class» T1, «k:class» T2 >«k:class» X {}; 3 | «k:template»<«k:class» T1,«k:class» T2>«k:class» X {}; 4 | «k:template»< «k:class» T1,«k:class» T2>«k:class» X {}; 5 | «k:template» < «k:class» T1,«k:class» T2>«k:class» X {}; 6 | «k:template» <«k:class» T1,«k:class» T2>«k:class» X {}; 7 | «k:template»<«k:typename» T1, «k:typename» T2 > «k:class» X {}; 8 | «k:template»<«k:typename» T1, «k:typename» T2 >«k:class» X {}; 9 | «k:template»<«k:typename» T1,«k:typename» T2>«k:class» X {}; 10 | «k:template»< «k:typename» T1,«k:typename» T2>«k:class» X {}; 11 | «k:template» < «k:typename» T1,«k:typename» T2>«k:class» X {}; 12 | «k:template» <«k:typename» T1,«k:typename» T2>«k:class» X {}; 13 | «k:template» <«k:template»<«k:class» A>«k:class» T>«k:struct» X{}; 14 | -------------------------------------------------------------------------------- /img/all-operator-on-sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/all-operator-on-sample.png -------------------------------------------------------------------------------- /img/attributes-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/attributes-off.png -------------------------------------------------------------------------------- /img/attributes-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/attributes-on.png -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/logo.png -------------------------------------------------------------------------------- /img/mc++fl-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/mc++fl-on.png -------------------------------------------------------------------------------- /img/mode-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/43c6b68ff58fccdf9deef11674a172e4eaa8455c/img/mode-line.png -------------------------------------------------------------------------------- /modern-cpp-font-lock-setup-test.el: -------------------------------------------------------------------------------- 1 | ;;; modern-cpp-font-lock-test-setup.el --- Setup and execute all tests 2 | 3 | ;;; Commentary: 4 | 5 | ;; This package sets up a suitable enviroment for testing 6 | ;; modern-cpp-font-lock, and executes the tests. 7 | ;; 8 | ;; Usage: 9 | ;; 10 | ;; emacs -q -l modern-cpp-font-lock-test-setup.el 11 | ;; 12 | ;; Note that this package assumes that some packages are located in 13 | ;; specific locations. 14 | 15 | ;;; Code: 16 | 17 | (prefer-coding-system 'utf-8) 18 | 19 | (defvar modern-cpp-font-lock-test-setup-directory 20 | (if load-file-name 21 | (file-name-directory load-file-name) 22 | default-directory)) 23 | 24 | (dolist (dir '("." "./faceup")) 25 | (add-to-list 'load-path 26 | (concat modern-cpp-font-lock-test-setup-directory dir))) 27 | 28 | (require 'modern-cpp-font-lock) 29 | (add-hook 'text-mode-hook #'modern-c++-font-lock-mode) 30 | 31 | (require 'modern-cpp-font-lock-test) 32 | 33 | (ert t) 34 | 35 | ;;; modern-cpp-font-lock-test-setup.el ends here 36 | -------------------------------------------------------------------------------- /modern-cpp-font-lock-test.el: -------------------------------------------------------------------------------- 1 | (require 'faceup) 2 | 3 | (defconst project-directory (faceup-this-file-directory) 4 | "Directory where the project lives") 5 | 6 | (defconst test-directory "cpp" 7 | "Directory name where facit tests are") 8 | 9 | (defconst cpp-filename "test.txt" 10 | "C++ filename that will be tested for font lock") 11 | 12 | (defun facit-test-paths (root directory file) 13 | (mapcar (lambda (d) (concat root directory "/" d "/" file)) 14 | (directory-files directory nil "^[^\\.].*"))) 15 | 16 | (defun facit-tests (root directory file) 17 | (mapcar (lambda (path) (should (faceup-test-font-lock-file 'text-mode path))) 18 | (facit-test-paths root directory file))) 19 | 20 | (faceup-defexplainer facit-tests) 21 | 22 | (ert-deftest modern-cpp-font-lock-file-test () 23 | (facit-tests project-directory test-directory cpp-filename)) 24 | 25 | (provide 'modern-cpp-font-lock-test) 26 | -------------------------------------------------------------------------------- /modern-cpp-font-lock.el: -------------------------------------------------------------------------------- 1 | ;;; modern-cpp-font-lock.el --- Font-locking for "Modern C++" -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright © 2016, by Ludwig PACIFICI 4 | 5 | ;; Author: Ludwig PACIFICI 6 | ;; URL: https://github.com/ludwigpacifici/modern-cpp-font-lock 7 | ;; Version: 0.1.3 8 | ;; Created: 12 May 2016 9 | ;; Keywords: languages, c++, cpp, font-lock 10 | 11 | ;; This file is not part of GNU Emacs. 12 | 13 | ;;; Commentary: 14 | 15 | ;; Syntax highlighting support for "Modern C++" - until C++20 and 16 | ;; Technical Specification. This package aims to provide a simple 17 | ;; highlight of the C++ language without dependency. 18 | 19 | ;; It is recommended to use it in addition with the c++-mode major 20 | ;; mode for extra highlighting (user defined types, functions, etc.) 21 | ;; and indentation. 22 | 23 | ;; Melpa: [M-x] package-install [RET] modern-cpp-font-lock [RET] 24 | ;; In your init Emacs file add: 25 | ;; (add-hook 'c++-mode-hook #'modern-c++-font-lock-mode) 26 | ;; or: 27 | ;; (modern-c++-font-lock-global-mode t) 28 | 29 | ;; For the current buffer, the minor-mode can be turned on/off via the 30 | ;; command: 31 | ;; [M-x] modern-c++-font-lock-mode [RET] 32 | 33 | ;; More documentation: 34 | ;; https://github.com/ludwigpacifici/modern-cpp-font-lock/blob/master/README.md 35 | 36 | ;; Feedback is welcome! 37 | 38 | ;;; License: 39 | 40 | ;; This program is free software; you can redistribute it and/or 41 | ;; modify it under the terms of the GNU General Public License 42 | ;; as published by the Free Software Foundation; either version 3 43 | ;; of the License, or (at your option) any later version. 44 | ;; 45 | ;; This program is distributed in the hope that it will be useful, 46 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 47 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48 | ;; GNU General Public License for more details. 49 | ;; 50 | ;; You should have received a copy of the GNU General Public License 51 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 52 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 53 | ;; Boston, MA 02110-1301, USA. 54 | 55 | ;;; Code: 56 | 57 | (defgroup modern-c++-font-lock nil 58 | "Provides font-locking as a Minor Mode for Modern C++" 59 | :group 'faces) 60 | 61 | (eval-and-compile 62 | (defun modern-c++-string-lenght< (a b) (< (length a) (length b))) 63 | (defun modern-c++-string-lenght> (a b) (not (modern-c++-string-lenght< a b)))) 64 | 65 | (defcustom modern-c++-types 66 | (eval-when-compile 67 | (sort '("bool" "char" "char8_t" "char16_t" "char32_t" "double" "float" "int" "long" "short" "signed" "unsigned" "void" "wchar_t") 68 | 'modern-c++-string-lenght>)) 69 | "List of C++ types. See doc: 70 | http://en.cppreference.com/w/cpp/language/types" 71 | :type '(choice (const :tag "Disabled" nil) 72 | (repeat string)) 73 | :group 'modern-c++-font-lock) 74 | 75 | (defcustom modern-c++-preprocessors 76 | (eval-when-compile 77 | (sort '("#define" "#defined" "#elif" "#else" "#endif" "#error" "#if" "#ifdef" "#ifndef" "#include" "#line" "#pragma STDC CX_LIMITED_RANGE" "#pragma STDC FENV_ACCESS" "#pragma STDC FP_CONTRACT" "#pragma once" "#pragma pack" "#pragma" "#undef" "_Pragma" "__DATE__" "__FILE__" "__LINE__" "__STDCPP_STRICT_POINTER_SAFETY__" "__STDCPP_THREADS__" "__STDC_HOSTED__" "__STDC_ISO_10646__" "__STDC_MB_MIGHT_NEQ_WC__" "__STDC_VERSION__" "__STDC__" "__TIME__" "__VA_ARGS__" "__VA_OPT__" "__cplusplus" "__has_include" "__has_cpp_attribute") 78 | 'modern-c++-string-lenght>)) 79 | "List of C++ preprocessor words. See doc: 80 | http://en.cppreference.com/w/cpp/keyword and 81 | http://en.cppreference.com/w/cpp/preprocessor" 82 | :type '(choice (const :tag "Disabled" nil) 83 | (repeat string)) 84 | :group 'modern-c++-font-lock) 85 | 86 | (defcustom modern-c++-keywords 87 | (eval-when-compile 88 | (sort '("alignas" "alignof" "and" "and_eq" "asm" "atomic_cancel" "atomic_commit" "atomic_noexcept" "audit" "auto" "axiom" "bitand" "bitor" "break" "case" "catch" "class" "compl" "concept" "const" "constexpr" "consteval" "constinit" "const_cast" "continue" "co_await" "co_return" "co_yield" "decltype" "default" "delete" "do" "dynamic_cast" "else" "enum" "explicit" "export" "extern" "final" "for" "friend" "goto" "if" "import" "inline" "module" "mutable" "namespace" "new" "noexcept" "not" "not_eq" "operator" "or" "or_eq" "override" "private" "protected" "public" "register" "reinterpret_cast" "requires" "return" "sizeof" "static" "static_assert" "static_cast" "struct" "switch" "synchronized" "template" "this" "thread_local" "throw" "transaction_safe" "transaction_safe_dynamic" "try" "typedef" "typeid" "typename" "union" "using" "virtual" "volatile" "while" "xor" "xor_eq") 89 | 'modern-c++-string-lenght>)) 90 | "List of C++ keywords. See doc: 91 | http://en.cppreference.com/w/cpp/keyword" 92 | :type '(choice (const :tag "Disabled" nil) 93 | (repeat string)) 94 | :group 'modern-c++-font-lock) 95 | 96 | (defcustom modern-c++-attributes 97 | (eval-when-compile 98 | (sort '("carries_dependency" "deprecated" "fallthrough" "maybe_unused" "nodiscard" "noreturn" "optimize_for_synchronized" "likely" "unlikely" "no_unique_address" "expects" "ensures" "assert") 99 | 'modern-c++-string-lenght>)) 100 | "List of C++ attributes. See doc: 101 | http://en.cppreference.com/w/cpp/language/attributes" 102 | :type '(choice (const :tag "Disabled" nil) 103 | (repeat string)) 104 | :group 'modern-c++-font-lock) 105 | 106 | (defcustom modern-c++-operators 107 | (eval-when-compile 108 | (sort '("...") 109 | 'modern-c++-string-lenght>)) 110 | "List of C++ assignment operators. Left Intentionally almost 111 | empty. The user will choose what should be font-locked. By 112 | default I want to avoid a 'christmas tree' C++ code. For more 113 | information, see doc: 114 | http://en.cppreference.com/w/cpp/language/operators" 115 | :type '(choice (const :tag "Disabled" nil) 116 | (repeat string)) 117 | :group 'modern-c++-font-lock) 118 | 119 | (defvar modern-c++-font-lock-keywords nil) 120 | 121 | (defun modern-c++-generate-font-lock-keywords () 122 | (let ((types-regexp (regexp-opt modern-c++-types 'symbols)) 123 | (preprocessors-regexp (regexp-opt modern-c++-preprocessors)) 124 | (keywords-regexp (regexp-opt modern-c++-keywords 'words)) 125 | (attributes-regexp 126 | (concat "\\[\\[\\(" (regexp-opt modern-c++-attributes 'words) "\\).*\\]\\]")) 127 | (operators-regexp (regexp-opt modern-c++-operators))) 128 | (setq modern-c++-font-lock-keywords 129 | `( 130 | ;; Note: order below matters, because once colored, that part 131 | ;; won't change. In general, longer words first 132 | (,types-regexp (0 font-lock-type-face)) 133 | (,preprocessors-regexp (0 font-lock-preprocessor-face)) 134 | (,attributes-regexp (1 font-lock-constant-face)) 135 | (,operators-regexp (0 font-lock-function-name-face)) 136 | (,keywords-regexp (0 font-lock-keyword-face)))))) 137 | 138 | (defcustom modern-c++-literal-boolean 139 | t 140 | "Enable font-lock for boolean literals. For more information, 141 | see documentation: 142 | http://en.cppreference.com/w/cpp/language/bool_literal" 143 | :type 'boolean 144 | :group 'modern-c++-font-lock) 145 | 146 | (defvar modern-c++-font-lock-literal-boolean nil) 147 | 148 | (defun modern-c++-generate-font-lock-literal-boolean () 149 | (let ((literal-boolean-regexp (regexp-opt 150 | (eval-when-compile (sort '("false" "true") 'modern-c++-string-lenght>)) 151 | 'words))) 152 | (setq modern-c++-font-lock-literal-boolean 153 | `( 154 | ;; Note: order below matters, because once colored, that part 155 | ;; won't change. In general, longer words first 156 | (,literal-boolean-regexp (0 font-lock-constant-face)))))) 157 | 158 | (defcustom modern-c++-literal-integer 159 | t 160 | "Enable font-lock for integer literals. For more information, 161 | see documentation: 162 | http://en.cppreference.com/w/cpp/language/integer_literal" 163 | :type 'boolean 164 | :group 'modern-c++-font-lock) 165 | 166 | (defcustom modern-c++-literal-binary-prefix-face 'font-lock-keyword-face 167 | "Face for displaying binary literal integer prefix." 168 | :type 'symbol 169 | :group 'modern-c++-font-lock) 170 | 171 | (defcustom modern-c++-literal-binary-infix-face 'font-lock-constant-face 172 | "Face for displaying binary literal integer infix." 173 | :type 'symbol 174 | :group 'modern-c++-font-lock) 175 | 176 | (defcustom modern-c++-literal-binary-suffix-face 'font-lock-keyword-face 177 | "Face for displaying binary literal integer suffix." 178 | :type 'symbol 179 | :group 'modern-c++-font-lock) 180 | 181 | (defcustom modern-c++-literal-octal-prefix-face 'font-lock-keyword-face 182 | "Face for displaying octal literal integer prefix." 183 | :type 'symbol 184 | :group 'modern-c++-font-lock) 185 | 186 | (defcustom modern-c++-literal-octal-infix-face 'font-lock-constant-face 187 | "Face for displaying octal literal integer infix." 188 | :type 'symbol 189 | :group 'modern-c++-font-lock) 190 | 191 | (defcustom modern-c++-literal-octal-suffix-face 'font-lock-keyword-face 192 | "Face for displaying octal literal integer suffix." 193 | :type 'symbol 194 | :group 'modern-c++-font-lock) 195 | 196 | (defcustom modern-c++-literal-hex-prefix-face 'font-lock-keyword-face 197 | "Face for displaying hexadecimal literal integer prefix." 198 | :type 'symbol 199 | :group 'modern-c++-font-lock) 200 | 201 | (defcustom modern-c++-literal-hex-infix-face 'font-lock-constant-face 202 | "Face for displaying hexadecimal literal integer infix." 203 | :type 'symbol 204 | :group 'modern-c++-font-lock) 205 | 206 | (defcustom modern-c++-literal-hex-suffix-face 'font-lock-keyword-face 207 | "Face for displaying hexadecimal literal integer suffix." 208 | :type 'symbol 209 | :group 'modern-c++-font-lock) 210 | 211 | (defcustom modern-c++-literal-dec-infix-face 'font-lock-constant-face 212 | "Face for displaying decimal literal integer infix." 213 | :type 'symbol 214 | :group 'modern-c++-font-lock) 215 | 216 | (defcustom modern-c++-literal-dec-suffix-face 'font-lock-keyword-face 217 | "Face for displaying decimal literal integer suffix." 218 | :type 'symbol 219 | :group 'modern-c++-font-lock) 220 | 221 | (defvar modern-c++-font-lock-literal-integer nil) 222 | 223 | (defun modern-c++-generate-font-lock-literal-integer () 224 | (eval-when-compile 225 | (let* ((integer-suffix-regexp (regexp-opt (sort '("ull" "LLu" "LLU" "llu" "llU" "uLL" "ULL" "Ull" "ll" "LL" "ul" "uL" "Ul" "UL" "lu" "lU" "LU" "Lu" "u" "U" "l" "L") 'modern-c++-string-lenght>))) 226 | (not-alpha-numeric-regexp "[^0-9a-zA-Z'\\\._]") 227 | (literal-binary-regexp (concat not-alpha-numeric-regexp "\\(0[bB]\\)\\([01']+\\)\\(" integer-suffix-regexp "?\\)")) 228 | (literal-octal-regexp (concat not-alpha-numeric-regexp "\\(0\\)\\([0-7']+\\)\\(" integer-suffix-regexp "?\\)")) 229 | (literal-hex-regexp (concat not-alpha-numeric-regexp "\\(0[xX]\\)\\([0-9a-fA-F']+\\)\\(" integer-suffix-regexp "?\\)")) 230 | (literal-dec-regexp (concat not-alpha-numeric-regexp "\\([1-9][0-9']*\\)\\(" integer-suffix-regexp "\\)"))) 231 | (setq modern-c++-font-lock-literal-integer 232 | `( 233 | ;; Note: order below matters, because once colored, that part 234 | ;; won't change. In general, longer words first 235 | (,literal-binary-regexp (1 modern-c++-literal-binary-prefix-face) 236 | (2 modern-c++-literal-binary-infix-face) 237 | (3 modern-c++-literal-binary-suffix-face)) 238 | (,literal-octal-regexp (1 modern-c++-literal-octal-prefix-face) 239 | (2 modern-c++-literal-octal-infix-face) 240 | (3 modern-c++-literal-octal-suffix-face)) 241 | (,literal-hex-regexp (1 modern-c++-literal-hex-prefix-face) 242 | (2 modern-c++-literal-hex-infix-face) 243 | (3 modern-c++-literal-hex-suffix-face)) 244 | (,literal-dec-regexp (1 modern-c++-literal-dec-infix-face) 245 | (2 modern-c++-literal-dec-suffix-face))))))) 246 | 247 | (defcustom modern-c++-literal-null-pointer 248 | t 249 | "Enable font-lock for null pointer literals. For more information, 250 | see documentation: 251 | http://en.cppreference.com/w/cpp/language/nullptr" 252 | :type 'boolean 253 | :group 'modern-c++-font-lock) 254 | 255 | (defvar modern-c++-font-lock-literal-null-pointer nil) 256 | 257 | (defun modern-c++-generate-font-lock-literal-null-pointer () 258 | (let ((literal-null-pointer-regexp (regexp-opt 259 | (eval-when-compile (sort '("nullptr") 'modern-c++-string-lenght>)) 260 | 'words))) 261 | (setq modern-c++-font-lock-literal-null-pointer 262 | `( 263 | ;; Note: order below matters, because once colored, that part 264 | ;; won't change. In general, longer words first 265 | (,literal-null-pointer-regexp (0 font-lock-constant-face)))))) 266 | 267 | (defcustom modern-c++-literal-string 268 | t 269 | "Enable font-lock for string literals. For more information, 270 | see documentation: 271 | http://en.cppreference.com/w/cpp/language/string_literal" 272 | :type 'boolean 273 | :group 'modern-c++-font-lock) 274 | 275 | (defvar modern-c++-font-lock-literal-string nil) 276 | 277 | (defun modern-c++-generate-font-lock-literal-string () 278 | (eval-when-compile 279 | (let* ((simple-string-regexp "\"[^\"]*\"") 280 | (raw "R") 281 | (prefix-regexp 282 | (regexp-opt (sort '("L" "u8" "u" "U") 'modern-c++-string-lenght>))) 283 | (literal-string-regexp 284 | (concat "\\(" prefix-regexp "?\\)\\(" simple-string-regexp "\\)\\(s?\\)")) 285 | (delimiter-group-regexp "\\([^\\s-\\\\()]\\{1,16\\}\\)") 286 | (raw-delimiter-literal-string-regexp 287 | (concat "\\(" prefix-regexp "?" raw 288 | "\"" delimiter-group-regexp "(\\)" 289 | "\\(\\(.\\|\n\\)*?\\)" 290 | "\\()\\2\"s?\\)")) 291 | (raw-literal-string-regexp 292 | (concat "\\(" prefix-regexp "?" raw "\"(\\)" 293 | "\\(\\(.\\|\n\\)*?\\)" 294 | "\\()\"s?\\)"))) 295 | (setq modern-c++-font-lock-literal-string 296 | `( 297 | ;; Note: order below matters, because once colored, that part 298 | ;; won't change. In general, longer words first 299 | (,raw-delimiter-literal-string-regexp (1 font-lock-constant-face) 300 | (3 font-lock-string-face) 301 | (5 font-lock-constant-face)) 302 | (,raw-literal-string-regexp (1 font-lock-constant-face) 303 | (2 font-lock-string-face) 304 | (4 font-lock-constant-face)) 305 | (,literal-string-regexp (1 font-lock-constant-face) 306 | (2 font-lock-string-face) 307 | (3 font-lock-constant-face))))))) 308 | 309 | (defcustom modern-c++-stl-cstdint 310 | t 311 | "Enable font-lock for header . For more information, 312 | see documentation: 313 | http://en.cppreference.com/w/cpp/header/cstdint" 314 | :type 'boolean 315 | :group 'modern-c++-font-lock) 316 | 317 | (defvar modern-c++-font-lock-stl-cstdint nil) 318 | 319 | (defun modern-c++-generate-font-lock-stl-cstdint () 320 | (let ((stl-cstdint-types (regexp-opt 321 | (eval-when-compile 322 | (sort (mapcar (function (lambda (x) (concat "std::" x))) 323 | '("int8_t" "int16_t" "int32_t" "int64_t" "int_fast8_t" "int_fast16_t" "int_fast32_t" "int_fast64_t" "int_least8_t" "int_least16_t" "int_least32_t" "int_least64_t" "intmax_t" "intptr_t" "uint8_t" "uint16_t" "uint32_t" "uint64_t" "uint_fast8_t" "uint_fast16_t" "uint_fast32_t" "uint_fast64_t" "uint_least8_t" "uint_least16_t" "uint_least32_t" "uint_least64_t" "uintmax_t" "uintptr_t")) 324 | 'modern-c++-string-lenght>)) 325 | 'symbols)) 326 | (stl-cstdint-macro (regexp-opt 327 | (eval-when-compile 328 | (sort '("INT8_MIN" "INT16_MIN" "INT32_MIN" "INT64_MIN" "INT_FAST8_MIN" "INT_FAST16_MIN" "INT_FAST32_MIN" "INT_FAST64_MIN" "INT_LEAST8_MIN" "INT_LEAST16_MIN" "INT_LEAST32_MIN" "INT_LEAST64_MIN" "INTPTR_MIN" "INTMAX_MIN" "INT8_MAX" "INT16_MAX" "INT32_MAX" "INT64_MAX" "INT_FAST8_MAX" "INT_FAST16_MAX" "INT_FAST32_MAX" "INT_FAST64_MAX" "INT_LEAST8_MAX" "INT_LEAST16_MAX" "INT_LEAST32_MAX" "INT_LEAST64_MAX" "INTPTR_MAX" "INTMAX_MAX" "UINT8_MAX" "UINT16_MAX" "UINT32_MAX" "UINT64_MAX" "UINT_FAST8_MAX" "UINT_FAST16_MAX" "UINT_FAST32_MAX" "UINT_FAST64_MAX" "UINT_LEAST8_MAX" "UINT_LEAST16_MAX" "UINT_LEAST32_MAX" "UINT_LEAST64_MAX" "UINTPTR_MAX" "UINTMAX_MAX" "INT8_C" "INT16_C" "INT32_C" "INT64_C" "INTMAX_C" "UINT8_C" "UINT16_C" "UINT32_C" "UINT64_C" "UINTMAX_C" "PTRDIFF_MIN" "PTRDIFF_MAX" "SIZE_MAX" "SIG_ATOMIC_MIN" "SIG_ATOMIC_MAX" "WCHAR_MIN" "WCHAR_MAX" "WINT_MIN" "WINT_MAX") 329 | 'modern-c++-string-lenght>)) 330 | 'symbols))) 331 | (setq modern-c++-font-lock-stl-cstdint 332 | `( 333 | ;; Note: order below matters, because once colored, that part 334 | ;; won't change. In general, longer words first 335 | (,stl-cstdint-types (0 font-lock-type-face)) 336 | (,stl-cstdint-macro (0 font-lock-preprocessor-face)))))) 337 | 338 | (defun modern-c++-font-lock-add-keywords (&optional mode) 339 | "Install keywords into major MODE, or into current buffer if nil." 340 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-keywords) nil) 341 | (when modern-c++-literal-boolean 342 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-literal-boolean) nil)) 343 | (when modern-c++-literal-integer 344 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-literal-integer) nil)) 345 | (when modern-c++-literal-null-pointer 346 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-literal-null-pointer) nil)) 347 | (when modern-c++-literal-string 348 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-literal-string) nil)) 349 | (when modern-c++-stl-cstdint 350 | (font-lock-add-keywords mode (modern-c++-generate-font-lock-stl-cstdint) nil))) 351 | 352 | (defun modern-c++-font-lock-remove-keywords (&optional mode) 353 | "Remove keywords from major MODE, or from current buffer if nil." 354 | (font-lock-remove-keywords mode modern-c++-font-lock-keywords) 355 | (when modern-c++-literal-boolean 356 | (font-lock-remove-keywords mode modern-c++-font-lock-literal-boolean)) 357 | (when modern-c++-literal-integer 358 | (font-lock-remove-keywords mode modern-c++-font-lock-literal-integer)) 359 | (when modern-c++-literal-null-pointer 360 | (font-lock-remove-keywords mode modern-c++-font-lock-literal-null-pointer)) 361 | (when modern-c++-literal-string 362 | (font-lock-remove-keywords mode modern-c++-font-lock-literal-string)) 363 | (when modern-c++-stl-cstdint 364 | (font-lock-remove-keywords mode modern-c++-font-lock-stl-cstdint))) 365 | 366 | ;;;###autoload 367 | (define-minor-mode modern-c++-font-lock-mode 368 | "Provides font-locking as a Minor Mode for Modern C++" 369 | :init-value nil 370 | :lighter " mc++fl" 371 | :group 'modern-c++-font-lock 372 | (if modern-c++-font-lock-mode 373 | (modern-c++-font-lock-add-keywords) 374 | (modern-c++-font-lock-remove-keywords)) 375 | ;; As of Emacs 24.4, `font-lock-fontify-buffer' is not legal to 376 | ;; call, instead `font-lock-flush' should be used. 377 | (if (fboundp 'font-lock-flush) 378 | (font-lock-flush) 379 | (when font-lock-mode 380 | (with-no-warnings 381 | (font-lock-fontify-buffer))))) 382 | 383 | ;;;###autoload 384 | (define-global-minor-mode modern-c++-font-lock-global-mode modern-c++-font-lock-mode 385 | (lambda () 386 | (when (apply 'derived-mode-p '(c++-mode)) 387 | (modern-c++-font-lock-mode 1))) 388 | :group 'modern-c++-font-lock) 389 | 390 | (provide 'modern-cpp-font-lock) 391 | 392 | ;; coding: utf-8 393 | 394 | ;;; modern-cpp-font-lock.el ends here 395 | --------------------------------------------------------------------------------