├── .gitignore ├── LICENSE ├── README.md ├── build.py ├── etc └── archive │ ├── gutter_marks │ ├── twilight-illegal.png │ ├── twilight-violation.png │ └── twilight-warning.png │ ├── js │ └── Python.js │ └── to_css.py ├── img └── preview.png ├── langs ├── Comments(Cython).tmPreferences ├── Comments(Python3).tmPreferences ├── Cython.tmLanguage └── Python3.tmLanguage ├── src ├── common.py ├── cython.py ├── gloom.py └── python.py ├── tests ├── Python3.py ├── test.html └── test.py └── themes └── Gloom.tmTheme /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.pyc 3 | *.pyo 4 | *.sublime-workspace 5 | *.sublime-project 6 | *.idraw 7 | 8 | __old__.json 9 | __old__.xml 10 | 11 | .ccom_cache 12 | .clic_cache 13 | .cdoc_cache 14 | 15 | .ccom_todo 16 | .cdoc_toc 17 | 18 | build 19 | readme.html 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Python and Cython language bundles 2 | ================================== 3 | 4 | ***THE MOST POPULAR AND MOST FEATURE RICH PYTHON SYNTAX HIGHLIGHTER FOR 5 | SUBLIME TEXT WITH [OVER 450,000+ DOWNLOADS AND BEING IN THE TOP 100 PACKAGES]( 6 | https://sublime.wbond.net/packages/Python%203))!*** 7 | 8 | Bleeding-egde Python and Cython syntax highlighters and other goodies for 9 | Sublime Text 2/3 and TextMate editors. 10 | 11 | *(Or for any other editor, that is using the `.tmLanguage` syntax definition)* 12 | 13 | ![Preview](img/preview.png) 14 | 15 | 16 | 17 | State of the Art 18 | ---------------- 19 | 20 | Below are some of the most important improvements compared to the existing 21 | syntax highlighters: 22 | 23 | - Added better number highlighting: 24 | - All types of floating point notations are working now; 25 | - All types of complex number notations are working now; 26 | - New types of binary and octal-number notations are supported; 27 | - Long integer is removed. 28 | - The `...` syntax notation of `Ellipsis` is supported now. 29 | - Declaration rules are extended with `nonlocal`. 30 | - *Ex-statements-now-functions* (like `print`) are updated. 31 | - New Exception highlighting added. 32 | - New keywords `async` and `await` added. 33 | - Function annotations are now supported. 34 | - Conventional-language variable `cls` added. 35 | - Optional-comment-based string highlighting: 36 | - Better regex support (multiline, grouping, comments and more are improved). 37 | - Format specifier mini-language 38 | - Template strings 39 | - Matrix multiplication operator 40 | - String and byte literals: 41 | - Byte notation added; 42 | - Proper string prefixes added. 43 | - All the unused built-in and magic functions/methods are now removed. 44 | - All the unused keywords and notations are now removed. 45 | 46 | 47 | 48 | Future plans 49 | ------------ 50 | 51 | - Create a better Twilight-based theme file. 52 | 53 | 54 | 55 | Installation 56 | ------------ 57 | 58 | ***Via Package Control*** 59 | 60 | The fastest and easiest way to install these packages for Sublime Text is the 61 | following: 62 | 63 | 1. Install [Package Control](https://sublime.wbond.net/installation) 64 | 2. Open `Tools` → `Command Palette` 65 | 3. Select `Package Control: Install Package` 66 | 4. Search for `Python 3` and `Cython+` packages and install them 67 | 5. Happy coding ;) 68 | 69 | ***Set as default*** 70 | 71 | After you installed the language definition file successfully, all you have to 72 | do is assign the `.py` files to always open with this syntax highlighter. Go to 73 | 74 | `View` → `Syntax` → `Open all with current extension as...` → `Python 3` 75 | 76 | To remove this setting, you can always overwrite this preference. 77 | 78 | ***Manual installation*** 79 | 80 | Download the `tmLanguage` files from the python and Cython branches of this 81 | repository. Navigate to your `Packages` folder and create a `Python3` and/or a 82 | `Cython` folder(s) and copy the `tmLanguage` and sublime-build files into. 83 | 84 | ***Theme file*** 85 | 86 | *If you want to use my Work-In-Progress theme file: navigate to `Packages/User` 87 | folder and copy `Gloom.tmTheme` into it. Then go to user-settings, and change 88 | your old color theme to the new one.* 89 | 90 | 91 | 92 | Contribute 93 | ---------- 94 | 95 | Any help is appreciated and more than welcome -- my goal is to make this the 96 | *'de facto'* language bundle for python 3. If you want to submit a change, 97 | please use the following conventions when editing the original python files: 98 | 99 | - variables uses `underscore_separated_names`; 100 | - all files uses 4 spaces for indentation; 101 | - `=` and `:` operators are aligned if length of variable names are similar; 102 | - `(`, `[` and `{` start a new line, if possible and reasonable; 103 | - each line must fit in the width 80 columns (code, text, etc.); 104 | - comment separators can be easily generated with the `src.utils.separator()` 105 | function 106 | 107 | 108 | 109 | Appreciation 110 | ------------ 111 | 112 | Thank you very much [@joncle](https://github.com/joncle) (Jon Clements) for all 113 | the support in general, [@kms70847](https://github.com/kms70847) (Kevin), 114 | [@Ffisegydd](https://github.com/Ffisegydd) (Keiron Pizzey), 115 | [@schesis](https://github.com/schesis) (Zero Piraeus) and 116 | [@poke](https://github.com/poke) (Patrick Westerhoff) for the feedbacks, and of 117 | course thanks for all the wonderful members of the 118 | [sopython](http://sopython.com) chat room for supporting me in any ways! *May 119 | the Cabbage be with us ;)* 120 | 121 | I also want to thank for all the loyal users of this package, and especially 122 | [@rahul-ramadas](https://github.com/rahul-ramadas) (Rahul Ramadas) and 123 | [@bordaigorl](https://github.com/bordaigorl) (Emanuele D'Osualdo) who were 124 | very active on giving me feedbacks, reports, etc. 125 | 126 | 127 | 128 | License 129 | ------- 130 | 131 | Copyright (C) 2013 - 2017 Peter Varo 132 | 133 | This program is free software: you can redistribute it and/or modify it under 134 | the terms of the GNU General Public License as published by the Free Software 135 | Foundation, either version 3 of the License, or (at your option) any later 136 | version. 137 | 138 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 139 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 140 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 141 | 142 | You should have received a copy of the GNU General Public License along with 143 | this program, most likely a file in the root directory, called 'LICENSE'. If 144 | not, see http://www.gnu.org/licenses. 145 | -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | ## INFO ## 3 | ## INFO ## 4 | 5 | # Import python modules 6 | from os.path import join 7 | 8 | # Module level constants 9 | CURRENT_DIR = '.' 10 | LANG_PATH = join(CURRENT_DIR, 'langs') 11 | THEME_PATH = join(CURRENT_DIR, 'themes') 12 | LOCAL_PATH = join('~', '.config', 'sublime-text-3', 'Packages', 'User') 13 | 14 | # Import tmtools modules 15 | try: 16 | from tmtools.convert import Language, Theme 17 | except ImportError: 18 | from sys import exit 19 | print('[ ERROR ] tmtools modules are missing: ' 20 | 'install it from http://github.com/petervaro/tmtools') 21 | exit(-1) 22 | 23 | #------------------------------------------------------------------------------# 24 | # Import user modules 25 | from src.python import syntax as py_syntax 26 | from src.cython import syntax as cy_syntax 27 | from src.gloom import style as gl_style 28 | 29 | # I/O Details of languages and themes 30 | py_details = {'name' : 'Python3', 31 | 'path' : LANG_PATH, 32 | 'scope': 'python.3', 33 | 'comments' : {'line_comments': ('#',)}, 34 | 'test_name': 'Python3_TEST', 35 | 'test_path': join(LOCAL_PATH, 'Python3_TEST')} 36 | 37 | cy_details = {'name' : 'Cython', 38 | 'path' : LANG_PATH, 39 | 'scope': 'cython', 40 | 'comments' : {'line_comments': ('#',)}, 41 | 'test_name': 'Cython_TEST', 42 | 'test_path': join(LOCAL_PATH, 'Cython_TEST')} 43 | 44 | gl_details = {'name': 'Gloom', 45 | 'path': THEME_PATH, 46 | 'test_name': 'Gloom_TEST', 47 | 'test_path': join(LOCAL_PATH, 'Gloom_TEST')} 48 | 49 | # NOTE: Old path to theme files => DO NOT SUPPORT IT: 50 | # '~/Library/Application Support/Sublime Text 3/Packages/Color Scheme - Default' 51 | 52 | #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 53 | # Process language files 54 | for details, syntax in zip((py_details, cy_details), (py_syntax, cy_syntax)): 55 | # Setup names and locations 56 | lang = Language(**details) 57 | # Convert and save language file 58 | lang.from_dict(syntax) 59 | lang.write() 60 | 61 | #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 62 | # Setup names and locations 63 | theme = Theme(**gl_details) 64 | # Convert and save theme file 65 | theme.from_dict(gl_style) 66 | theme.write() 67 | -------------------------------------------------------------------------------- /etc/archive/gutter_marks/twilight-illegal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/petervaro/python/b8ecda33067ad41b897d1d4425abca6e94618980/etc/archive/gutter_marks/twilight-illegal.png -------------------------------------------------------------------------------- /etc/archive/gutter_marks/twilight-violation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/petervaro/python/b8ecda33067ad41b897d1d4425abca6e94618980/etc/archive/gutter_marks/twilight-violation.png -------------------------------------------------------------------------------- /etc/archive/gutter_marks/twilight-warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/petervaro/python/b8ecda33067ad41b897d1d4425abca6e94618980/etc/archive/gutter_marks/twilight-warning.png -------------------------------------------------------------------------------- /etc/archive/js/Python.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Python 3 Regular Expressions 3 | * 4 | * @author Peter Varo 5 | * @version 2.0.0 6 | */ 7 | 8 | var self = [ 9 | //- COMMENT ------------------------------------------------------------------// 10 | { 11 | 'name' : 'comment.line.hashmark.python', 12 | 'pattern': /#.*/g 13 | }, 14 | 15 | 16 | //- LAMBDA -------------------------------------------------------------------// 17 | { 18 | 'pattern': /\b(lambda)(\s+(\*{0,2}[A-z_]\w*\s*(,|=.+(?=,|:))?\s*)*)?(?=:)/g, 19 | 'matches': 20 | { 21 | 1: 'storage.type.function.anonymous.python', 22 | 2: 23 | { 24 | 'pattern': /\*{0,2}([A-z_]\w*)\s*(,|=.+(?=,|:))?\s*/g, 25 | 'matches': 26 | { 27 | 1: 'variable.parameter.function.python', 28 | 2: 29 | { 30 | 'pattern': /(=)(.+)(?=,|:)/g, 31 | 'matches': 32 | { 33 | 1: 'keyword.operator.assignment.python', 34 | 2: 35 | { 36 | 'language': 'python' 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | }, 44 | 45 | 46 | //- NUMBERS ------------------------------------------------------------------// 47 | { 48 | 'name' : 'constant.numeric.integer.binary.python', 49 | 'pattern': /\b0b[01]+/g 50 | }, 51 | { 52 | 'name' : 'constant.numeric.integer.hexadecimal.python', 53 | 'pattern': /\b0x[0-9a-fA-F]+/g 54 | }, 55 | { 56 | 'name' : 'constant.numeric.integer.octal.python', 57 | 'pattern': /\b0o[0-7]+/g 58 | }, 59 | { 60 | //.001 .1e6 .1E6 .1e+6 .1E+6 .1e-6 .1E-6 61 | 'name' : 'constant.numeric.float_and_complex.decimal.floatnumber.python', 62 | 'pattern': /(?=\W)\.\d+([eE][+-]?\d+)?[jJ]?/g 63 | }, 64 | { 65 | //1. 1.0 1.1e6 1.1E6 1.1e+6 1.1E+6 1.1e-6 1.1E-6 66 | 'name' : 'constant.numeric.float_and_complex.decimal.pointfloat.python', 67 | 'pattern': /\d+\.(\d+([eE][+-]?\d+)?)?[jJ]?/g 68 | }, 69 | { 70 | //1e6 1E6 1e+6 1E+6 1e-6 1E-6 71 | 'name' : 'constant.numeric.float_and_complex.decimal.exponent.python', 72 | 'pattern': /\b(?!\.)\d+[eE][+-]?\d+[jJ]?/g 73 | }, 74 | { 75 | 'name' : 'constant.numeric.integer_and_complex.decimal.python', 76 | 'pattern': /\b(?!\.)([1-9]\d*|0)[jJ]?/g 77 | }, 78 | 79 | 80 | //- KEYWORDS -----------------------------------------------------------------// 81 | { 82 | 'name' : 'storage.modifier.declaration.python', 83 | 'pattern': /\b(global|nonlocal)\b/g 84 | }, 85 | { 86 | 'name' : 'keyword.control.import_and_import_from.python', 87 | 'pattern': /\b(import|from)\b/g 88 | }, 89 | { 90 | 'name' : 'keyword.control.flow_block_delimiters.python', 91 | 'pattern': /\b(elif|else|except|finally|for|if|try|while|with|break|continue|pass|raise|return|yield)\b/g 92 | }, 93 | { 94 | 'name' : 'keyword.operator.bool.logical.python', 95 | 'pattern': /\b(and|in|is|not|or)\b/g 96 | }, 97 | { 98 | 'name' : 'keyword.other.python', 99 | 'pattern': /\b(as|assert|del)\b/g 100 | }, 101 | 102 | 103 | //- OPERATORS ----------------------------------------------------------------// 104 | { 105 | 'name' : 'keyword.operator.comparison.python', 106 | 'pattern': /<=|>=|==|<|>|!=/g 107 | }, 108 | { 109 | 'name' : 'keyword.operator.assignment.augmented.python', 110 | 'pattern': /\+=|-=|\*=|\/=|\/\/=|%=|&=|\|=|\^=|<<=|>>=|\*\*=/g 111 | }, 112 | { 113 | 'name' : 'keyword.operator.arithmetic.python', 114 | 'pattern': /\+|-|\*|\*\*|\/|\/\/|%|<<|>>|&|\||\^|~/g 115 | }, 116 | { 117 | 'name' : 'keyword.operator.value_and_annotation_assignment.python', 118 | 'pattern': /=|->/g 119 | }, 120 | 121 | 122 | //- CLASS --------------------------------------------------------------------// 123 | { 124 | 'pattern': /\s*(class)\s+([A-z_]\w*)(\s*\((([A-z_]\w*\s*,?\s*)|([A-z_]\w*\s*=\s*[A-z_]\w*))*\))?:/g, 125 | 'matches': 126 | { 127 | 1: 'storage.type.class.python', 128 | 2: 'entity.name.type.class.python', 129 | 3: 130 | { 131 | 'pattern': /([A-z_]\w*\s*,?\s*)|([A-z_]\w*\s*=\s*[A-z_]\w*)/g, 132 | 'matches': 133 | { 134 | 1: 135 | { 136 | 'pattern': /([A-z_]\w*)\s*,?\s*/g, 137 | 'matches': 138 | { 139 | //todo: invalid.illegal names (reserved keywords) 140 | 1: 'entity.other.inherited-class.python' 141 | } 142 | }, 143 | 2: 144 | { 145 | 'pattern': /([A-z_]\w*)\s*(=)\s*([A-z_]\w*)/g, 146 | 'matches': 147 | { 148 | 1: 'entity.other.inherited-class.python', 149 | 2: 'keyword.operator.assignment.python', 150 | 3: 'entity.other.inherited-class.python' 151 | } 152 | } 153 | } 154 | } 155 | } 156 | }, 157 | 158 | 159 | //- FUNCTION -----------------------------------------------------------------// 160 | { 161 | //'pattern': /\s*(def)\s+([A-z_]\w*)\s*\((([A-z_]\w*\s*(?=,|[\n)])\s*)*(\*[A-z_]\w*\s*(?=,|[\n)])\s*)?([A-z_]\w*\s*=\s*.+(?=,|[\n)])\s*)*(\*\*[A-z_]\w*(?=[\n)])\s*)?)\):/g, 162 | 'pattern': /\s*(def)\s+([A-z_]\w*)\s*\((\*?\*?([A-z_]\w*)\s*(:.+(?=,|=|[\n)]))?\s*(=.+(?=,|[\n)]))?\s*)*\)\s*(->.+)?(?=:)/g, 163 | 'matches': 164 | { 165 | 1: 'storage.type.function.python', 166 | 2: 'entity.name.function.python', 167 | 3: 168 | { 169 | 'pattern': /\*?\*?([A-z_]\w*)\s*(?=:.+(?=,|=|[\n)]))?\s*(?==.+(?=,|[\n)]))?\s*/g, 170 | 'matches': 171 | { 172 | 1: 'variable.parameter.function.python' 173 | } 174 | }, 175 | 4: 176 | { 177 | 'pattern': /(->).+/g, 178 | 'matches': 179 | { 180 | 1: 'keyword.operator.assignment.python' 181 | } 182 | } 183 | // 3: 184 | // { 185 | // 'pattern': /([A-z_]\w*\s*(?=,|[\n)])\s*)*(\*[A-z_]\w*\s*(?=,|[\n)])\s*)?([A-z_]\w*\s*=\s*.+(?=,|[\n)])\s*)*(\*\*[A-z_]\w*(?=[\n)])\s*)?/g, 186 | // 'matches': 187 | // { 188 | // 1: 189 | // { 190 | // 'pattern': /([A-z_]\w*)\s*(?=,|[\n)])\s*/g, 191 | // 'matches': 192 | // { 193 | // 1: 'variable.parameter.function.python', 194 | // 3: /(\*{0,2}([A-z_]\w*)\s*(:.+(?=,|=|[\n)]))?\s*(=.+(?=,|[\n)]))?)*/ 195 | // } 196 | // }, 197 | // 2: 198 | // { 199 | // 'pattern': /\*([A-z_]\w*)\s*(?=,|[\n)])\s*/g, 200 | // 'matches': 201 | // { 202 | // 1: 'variable.parameter.function.python' 203 | // } 204 | // }, 205 | // 3: 206 | // { 207 | // 'pattern': /([A-z_]\w*)\s*=\s*.+(?=,|[\n)])\s*/g, 208 | // 'matches': 209 | // { 210 | // 1: 'variable.parameter.function.python', 211 | // 2: 'keyword.operator.assignment.python' 212 | // } 213 | // }, 214 | // 4: 215 | // { 216 | // 'pattern': /\*\*([A-z_]\w*)(?=[\n)])\s*/g, 217 | // 'matches': 218 | // { 219 | // 1: 'variable.parameter.function.python' 220 | // } 221 | // } 222 | // } 223 | // } 224 | } 225 | } 226 | ]; 227 | 228 | Rainbow.extend('python', self, true); 229 | -------------------------------------------------------------------------------- /etc/archive/to_css.py: -------------------------------------------------------------------------------- 1 | # TODO: Add this functionality src.convert.Theme 2 | 3 | # Convert dictionary to css 4 | def dict_to_css(dictionary, name, local): 5 | # todo: decide if we need `word-wrap: break-word;` or not? 6 | KEYS = { 7 | 'fontStyle' : 'font-style', 8 | 'foreground': 'color', 9 | 'background': 'background-color' 10 | } 11 | output = [] 12 | output.append('/*\n*{auth}\n*{name} syntax highlight theme\n*\n*{comm}\n*/\n'.format( 13 | auth = dictionary['author'], 14 | name = dictionary['name'], 15 | comm = dictionary['comment'] 16 | ) 17 | ) 18 | output.append('body\n{\n\tbackground: #282828;\n}\n') 19 | pre = dictionary['settings'][0]['settings'] 20 | output.append('pre, code\n{{\n{default}{dynamic}\n}}\n'.format( 21 | default = ( 22 | '\tmargin: 0px;\n' 23 | '\tpadding-left: 20px;\n' 24 | '\tfont-size: 12.5px;\n' 25 | "\tfont-family: 'Menlo', monospace;\n" 26 | ), 27 | dynamic = '\n'.join( 28 | [ 29 | '\tbackground: {};'.format(pre['background']), 30 | '\tcolor: {};'.format(pre['foreground']), 31 | ] 32 | ) 33 | ) 34 | ) 35 | output.append('::selection\n{{\n\tbackground: {};\n}}\n'.format( 36 | hex_to_rgba(pre['selection'])) 37 | ) 38 | for item in dictionary['settings'][1:]: 39 | try: 40 | _name = item['scope'] 41 | prefs = [] 42 | for key, value in item['settings'].items(): 43 | try: 44 | k = KEYS[key] 45 | except KeyError: 46 | k = key 47 | if value.startswith('#') and len(value) == 9: 48 | v = hex_to_rgba(value) 49 | else: 50 | v = value 51 | prefs.append('\t{}: {};'.format(k, v)) 52 | output.append('pre .{}\n{{\n{}\n}}\n'.format(_name, '\n'.join(prefs))) 53 | except KeyError: 54 | pass 55 | with open(os.path.join(os.pardir, local, '{}.css'.format(name)), 'w') as f: 56 | f.write('\n'.join(output)) 57 | print(name, 'style dictionary has been converted and placed.') 58 | -------------------------------------------------------------------------------- /img/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/petervaro/python/b8ecda33067ad41b897d1d4425abca6e94618980/img/preview.png -------------------------------------------------------------------------------- /langs/Comments(Cython).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.cython 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | # 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /langs/Comments(Python3).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.python.3 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | # 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/common.py: -------------------------------------------------------------------------------- 1 | ## INFO ## 2 | ## INFO ## 3 | 4 | #-- CHEATSHEET ----------------------------------------------------------------# 5 | # HOWTO: http://sublimetext.info/docs/en/reference/syntaxdefs.html 6 | # REGEX: http://manual.macromates.com/en/regular_expressions 7 | 8 | # Syntax Definition 9 | syntax = { 10 | 'name': '{NAME}', 11 | 'comment': ('\n\t\tCopyright (C) 2013 - 2017 Peter Varo' 12 | '\n\t\t' 13 | '\n' 14 | '\n\t\tThis program is free software: you can redistribute it' 15 | '\n\t\tand/or modify it under the terms of the GNU General' 16 | '\n\t\tPublic License as published by the Free Software' 17 | '\n\t\tFoundation, either version 3 of the License, or (at your' 18 | '\n\t\toption) any later version.' 19 | '\n' 20 | '\n\t\tThis program is distributed in the hope that it will be' 21 | '\n\t\tuseful, but WITHOUT ANY WARRANTY; without even the' 22 | '\n\t\timplied warranty of MERCHANTABILITY or FITNESS FOR A' 23 | '\n\t\tPARTICULAR PURPOSE. See the GNU General Public License' 24 | '\n\t\tfor more details.' 25 | '\n' 26 | '\n\t\tYou should have received a copy of the GNU General Public' 27 | '\n\t\tLicense along with this program, most likely a file in' 28 | '\n\t\tthe root directory, called "LICENSE". If not, see' 29 | '\n\t\t.' 30 | '\n\t'), 31 | 'scopeName': 'source.{SCOPE}', 32 | # Patterns 33 | 'patterns': 34 | { 35 | #-- COMMENT -------------------------------------------------------------------# 36 | 0x0000: 37 | { 38 | 'include': '#comment' 39 | }, 40 | 41 | 42 | #-- NUMBERS -------------------------------------------------------------------# 43 | 0x0010: 44 | { 45 | 'name' : 'constant.numeric.integer.binary.{SCOPE}', 46 | 'match': r'\b0b[01]+' 47 | }, 48 | 49 | 0x0020: 50 | { 51 | 'name' : 'constant.numeric.integer.hexadecimal.{SCOPE}', 52 | 'match': r'\b0x\h+' 53 | }, 54 | 55 | 0x0030: 56 | { 57 | 'name' : 'constant.numeric.integer.octal.{SCOPE}', 58 | 'match': r'\b0o[0-7]+' 59 | }, 60 | 61 | 0x0040: 62 | { 63 | # .001 .1e6 .1E6 .1e+6 .1E+6 .1e-6 .1E-6 64 | 'name' : 'constant.numeric.float_and_complex.decimal.floatnumber.{SCOPE}', 65 | 'match': r'(?<=\W|^)\.\d+([eE][+-]?\d+)?[jJ]?' 66 | }, 67 | 68 | 0x0050: 69 | { 70 | # 1. 1.0 1.e10 1.1e6 1.1E6 1.1e+6 1.1E+6 1.1e-6 1.1E-6 71 | 'name' : 'constant.numeric.float_and_complex.decimal.pointfloat.{SCOPE}', 72 | 'match': r'\d+\.(\d*([eE][+-]?\d+)?)?[jJ]?(?=\W)' 73 | }, 74 | 75 | 0x0060: 76 | { 77 | # 1e6 1E6 1e+6 1E+6 1e-6 1E-6 78 | 'name' : 'constant.numeric.float_and_complex.decimal.exponent.{SCOPE}', 79 | 'match': r'(?=|==|<|>|!=' 116 | }, 117 | 118 | 0x00E0: 119 | { 120 | 'name' : 'keyword.operator.assignment.augmented.{SCOPE}', 121 | 'match': r'\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|<<=|>>=|\*\*=' 122 | }, 123 | 124 | 0x00F0: 125 | { 126 | 'name' : 'keyword.operator.arithmetic.{SCOPE}', 127 | 'match': r'\+|-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~' 128 | }, 129 | 130 | 0x0100: 131 | { 132 | 'name' : 'keyword.operator.value_and_annotation_assignment.{SCOPE}', 133 | 'match': r'=|->' 134 | }, 135 | 136 | 137 | #-- CLASS ---------------------------------------------------------------------# 138 | # 0x0110: meta.class 139 | 140 | #-- FUNCTION ------------------------------------------------------------------# 141 | # 0x0120: meta.function 142 | 143 | #-- LAMBDA --------------------------------------------------------------------# 144 | 0x0130: 145 | { 146 | 'name' : 'meta.function.anonymous.{SCOPE}', 147 | 'begin': r'\b(lambda)\b', 148 | 'beginCaptures': 149 | { 150 | 1: {'name': 'storage.type.function.anonymous.{SCOPE}'} 151 | }, 152 | 'patterns': 153 | [ 154 | { 155 | 'begin': r'\s+', 156 | 'patterns': 157 | [ 158 | # Keyword arguments 159 | { 160 | 'begin': r'\b([a-zA-Z_]\w*)\s*(=)', 161 | 'beginCaptures': 162 | { 163 | 1: {'name': 'variable.parameter.function.{SCOPE}'}, 164 | 2: {'name': 'keyword.operator.assignment.{SCOPE}'} 165 | }, 166 | 'patterns': 167 | [ 168 | {'include': '$self'} 169 | ], 170 | 'end': r'(?=,|:)' 171 | }, 172 | # Positional arguments 173 | { 174 | 'name' : 'variable.parameter.function.{SCOPE}', 175 | 'match': r'\b[a-zA-Z_]\w*' 176 | } 177 | ], 178 | 'end': r'(?=:)' 179 | } 180 | ], 181 | 'end': r':' 182 | }, 183 | 184 | 185 | #-- DECORATOR -----------------------------------------------------------------# 186 | # Decorator with arguments 187 | 0x0140: 188 | { 189 | 'name' : 'meta.function.decorator.with_arguments.{SCOPE}', 190 | 'begin': r'^\s*(@\s*[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*)\s*\(', 191 | 'beginCaptures': 192 | { 193 | 1: {'name': 'support.function.decorator.{SCOPE}'} 194 | }, 195 | 'patterns': 196 | [ 197 | {'include': '#keyword_arguments'}, 198 | {'include': '$self'} 199 | ], 200 | 'end': r'\)' 201 | }, 202 | 203 | # Decorator without arguments 204 | 0x0150: 205 | { 206 | 'name' : 'meta.function.decorator.without_arguments.{SCOPE}', 207 | 'begin': r'^\s*(@\s*[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*)', 208 | 'beginCaptures': 209 | { 210 | 1: {'name': 'support.function.decorator.{SCOPE}'} 211 | }, 212 | 'end': r'(?=\s|$\n?|#)' 213 | }, 214 | 215 | #-- MATRIX OPERATOR -----------------------------------------------------------# 216 | 0x0151: 217 | { 218 | 'name' : 'keyword.operator.arithmetic.{SCOPE}', 219 | 'match': r'@' 220 | }, 221 | 222 | #-- CONSTANTS -----------------------------------------------------------------# 223 | # 0x0160: constant.language.word_like 224 | 225 | 0x0170: 226 | { 227 | 'name' : 'constant.language.symbol_like.{SCOPE}', 228 | 'match': r'(?<=\W|^)\.\.\.(?=\W|$)' 229 | }, 230 | 231 | 232 | #-- STORAGES ------------------------------------------------------------------# 233 | # 0x0180: storage.type.function 234 | 235 | 0x0190: 236 | { 237 | 'name' : 'storage.type.class.{SCOPE}', 238 | 'match': r'\b(class)\b' 239 | }, 240 | 241 | 242 | #-- BUILTINS ------------------------------------------------------------------# 243 | 0x01A0: 244 | { 245 | 'include': '#builtin_types' 246 | }, 247 | 248 | 0x01B0: 249 | { 250 | 'include': '#builtin_functions' 251 | }, 252 | 253 | 0x01C0: 254 | { 255 | 'include': '#builtin_exceptions' 256 | }, 257 | 258 | 259 | #-- MAGIC STUFFS --------------------------------------------------------------# 260 | 0x01D0: 261 | { 262 | 'include': '#magic_function_names' 263 | }, 264 | 265 | 0x01F0: 266 | { 267 | 'include': '#magic_variable_names' 268 | }, 269 | 270 | 271 | #-- ETC -----------------------------------------------------------------------# 272 | 0x0200: 273 | { 274 | 'include': '#line_continuation' 275 | }, 276 | 277 | 0x0210: 278 | { 279 | 'include': '#language_variables' 280 | }, 281 | 282 | 283 | #-- STRUCTURES ----------------------------------------------------------------# 284 | # LIST 285 | 0x0220: 286 | { 287 | 'name': 'meta.structure.list.{SCOPE}', 288 | 'begin': r'\[', 289 | 'patterns': 290 | [ 291 | { 292 | 'begin': r'(?<=\[|,)\s*(?![\],])', 293 | 'patterns': 294 | [ 295 | {'include': '$self'} 296 | ], 297 | 'end' : r'\s*(?:,|(?=\]))' 298 | } 299 | ], 300 | 'end' : r'\]' 301 | }, 302 | 303 | # DICTIONARY 304 | 0x0230: 305 | { 306 | 'name': 'meta.structure.dictionary.{SCOPE}', 307 | 'begin': r'\{', 308 | 'patterns': 309 | [ 310 | { 311 | 'begin': r'(?<=\{|,|^)\s*(?![,}])', 312 | 'patterns': 313 | [ 314 | {'include': '$self'} 315 | ], 316 | 'end' : r'\s*(?:(?=\})|:)' 317 | }, 318 | { 319 | 'begin': r'(?<=:|^)\s*', 320 | 'patterns': 321 | [ 322 | {'include': '$self'} 323 | ], 324 | 'end' : r'\s*(?:(?=\})|,)' 325 | } 326 | ], 327 | 'end' : r'\}' 328 | }, 329 | 330 | 0x0240: 331 | # GROUPS, TUPLES 332 | { 333 | 'name' : 'meta.structure.group.{SCOPE}', 334 | 'begin': r'(?<=,|;|=|\+|-|\*|/|\||:|<|>|~|%|\^|\\)\s*\(', 335 | 'patterns': 336 | [ 337 | {'include': '$self'} 338 | ], 339 | 'end': r'\)' 340 | }, 341 | 342 | 343 | #-- ACCESS --------------------------------------------------------------------# 344 | 0x0250: 345 | { 346 | 'name' : 'meta.function_call.{SCOPE}', 347 | 'begin': r'(?|~|%|\^|\\|\n)\s*\(', 348 | 'patterns': 349 | [ 350 | {'include': '#keyword_arguments'}, 351 | {'include': '$self'} 352 | ], 353 | 'end': r'\)' 354 | }, 355 | 356 | 357 | #-- STRING --------------------------------------------------------------------# 358 | 0x0260: 359 | { 360 | 'include': '#f_string_quoted' 361 | }, 362 | 363 | 0x0270: 364 | { 365 | 'include': '#string_quoted_regex' 366 | }, 367 | 368 | 0x0280: 369 | { 370 | 'include': '#string_quoted' 371 | }, 372 | }, 373 | 374 | #-- REPOSITORY ----------------------------------------------------------------# 375 | 'repository': 376 | { 377 | #-- COMMENTS ------------------------------------------------------------------# 378 | 'comment': 379 | { 380 | 'patterns': 381 | [ 382 | { 383 | 'name' : 'comment.line.hashmark.{SCOPE}', 384 | 'match': r'#.*$\n?' 385 | } 386 | ] 387 | }, 388 | 389 | # Optional Regular Expressions Highlighting 390 | 'comment_extended_re': 391 | { 392 | 'name' : 'meta.syntax.comment.line.hashmark.extended.re.{SCOPE}', 393 | 'begin': r"(?i)(#(#|\s)*syntax:re)$", 394 | 'beginCaptures': 395 | { 396 | 1: {'name': 'comment.line.hashmark.extended.re.open.{SCOPE}'} 397 | }, 398 | 'patterns': 399 | [ 400 | {'include': '#string_quoted_regex'}, 401 | {'include': '$self'} 402 | ], 403 | 'end': r"(?i)(#(#|\s)*end:re)$", 404 | 'endCaptures': 405 | { 406 | 1: {'name': 'comment.line.hashmark.extended.re.close.{SCOPE}'} 407 | }, 408 | }, 409 | 410 | # Optional Formatting Mini-langauge Highlighting 411 | 'comment_extended_old': 412 | { 413 | 'name' : 'meta.syntax.comment.line.hashmark.extended.fmt.{SCOPE}', 414 | 'begin': r"(?i)(#(#|\s)*syntax:old)$", 415 | 'beginCaptures': 416 | { 417 | 1: {'name': 'comment.line.hashmark.extended.fmt.open.{SCOPE}'} 418 | }, 419 | 'patterns': 420 | [ 421 | {'include': '#string_quoted_old'}, 422 | {'include': '$self'} 423 | ], 424 | 'end': r"(?i)(#(#|\s)*end:old)$", 425 | 'endCaptures': 426 | { 427 | 1: {'name': 'comment.line.hashmark.extended.fmt.close.{SCOPE}'} 428 | }, 429 | }, 430 | 431 | # Optional Formatting Mini-langauge Highlighting 432 | 'comment_extended_fmt': 433 | { 434 | 'name' : 'meta.syntax.comment.line.hashmark.extended.fmt.{SCOPE}', 435 | 'begin': r"(?i)(#(#|\s)*syntax:fmt)$", 436 | 'beginCaptures': 437 | { 438 | 1: {'name': 'comment.line.hashmark.extended.fmt.open.{SCOPE}'} 439 | }, 440 | 'patterns': 441 | [ 442 | {'include': '#string_quoted_format'}, 443 | {'include': '$self'} 444 | ], 445 | 'end': r"(?i)(#(#|\s)*end:fmt)$", 446 | 'endCaptures': 447 | { 448 | 1: {'name': 'comment.line.hashmark.extended.fmt.close.{SCOPE}'} 449 | }, 450 | }, 451 | 452 | 453 | # Optional Templating Strings 454 | 'comment_extended_tmp': 455 | { 456 | 'name' : 'meta.syntax.comment.line.hashmark.extended.tmp.{SCOPE}', 457 | 'begin': r"(?i)(#(#|\s)*syntax:tmp)$", 458 | 'beginCaptures': 459 | { 460 | 1: {'name': 'comment.line.hashmark.extended.tmp.open.{SCOPE}'} 461 | }, 462 | 'patterns': 463 | [ 464 | {'include': '#string_quoted_template'}, 465 | {'include': '$self'} 466 | ], 467 | 'end': r"(?i)(#(#|\s)*end:tmp)$", 468 | 'endCaptures': 469 | { 470 | 1: {'name': 'comment.line.hashmark.extended.tmp.close.{SCOPE}'} 471 | }, 472 | }, 473 | 474 | #-- CLASS ---------------------------------------------------------------------# 475 | 'class_entity_name': 476 | { 477 | 'contentName': 'entity.name.type.class.{SCOPE}', 478 | 'begin': r'(?=[a-zA-Z_]\w*)', 479 | 'patterns': 480 | [ 481 | {'include': '#entity_name_class'} 482 | ], 483 | 'end': r'(?!\w)' 484 | }, 485 | 'class_inheritance': 486 | { 487 | 'contentName': 'meta.class.inheritance.{SCOPE}', 488 | 'begin': r'\(', 489 | 'patterns': 490 | [ 491 | { 492 | 'contentName': 'entity.other.inherited-class.{SCOPE}', 493 | 'begin': r'(?<=\(|,)\s*', 494 | 'patterns': 495 | [ 496 | {'include': '$self'} 497 | ], 498 | 'end': r'\s*(?:,|(?=\)))', 499 | 'endCaptures': 500 | { 501 | 1: {'name': 'punctuation.separator.inheritance.{SCOPE}'} 502 | } 503 | } 504 | ], 505 | 'end': r'\)|:' 506 | }, 507 | 508 | 509 | #-- FUNCTION ------------------------------------------------------------------# 510 | 'function_entity_name': 511 | { 512 | 'contentName': 'entity.name.function.{SCOPE}', 513 | 'begin': r'(?=[a-zA-Z_]\w*)', 514 | 'patterns': 515 | [ 516 | {'include': '#entity_name_function'} 517 | ], 518 | 'end': r'(?!\w)' 519 | }, 520 | 'function_arguments': 521 | { 522 | 'begin': r'\(', 523 | 'patterns': 524 | [ 525 | # 'Inline' comments 526 | {'include': '#comment'}, 527 | # Keyword arguments 528 | { 529 | 'begin': r'\b([a-zA-Z_]\w*)\s*(=)', 530 | 'beginCaptures': 531 | { 532 | 1: {'name': 'variable.parameter.function.{SCOPE}'}, 533 | 2: {'name': 'keyword.operator.assignment.{SCOPE}'} 534 | }, 535 | 'patterns': 536 | [ 537 | # Keyword assignment 538 | { 539 | 'begin': r'(?<=(=))\s*', 540 | 'beginCaptures': 541 | { 542 | 1: {'name': 'keyword.operator.assignment.{SCOPE}'} 543 | }, 544 | 'patterns': 545 | [ 546 | {'include': '$self'} 547 | ], 548 | 'end': r'(?=,|[\n)])', 549 | }, 550 | # Annotation assignment (kwargs) 551 | { 552 | 'begin': r'(?<=:)\s*', 553 | 'patterns': 554 | [ 555 | {'include': '$self'} 556 | ], 557 | 'end': r'(?=,|(=)|[\n)])', 558 | 'endCaptures': 559 | { 560 | 1: {'name': 'keyword.operator.assignment.{SCOPE}'} 561 | } 562 | } 563 | ], 564 | 'end': r'(?=,|[\n)])' 565 | }, 566 | # Positional arguments 567 | { 568 | 'begin': r'\b([a-zA-Z_]\w*)\s*', 569 | 'beginCaptures': 570 | { 571 | 1: {'name': 'variable.parameter.function.{SCOPE}'} 572 | }, 573 | 'patterns': 574 | [ 575 | # Annotation assignment (args) 576 | { 577 | 'begin': r'(?<=:)\s*', 578 | 'patterns': 579 | [ 580 | {'include': '$self'} 581 | ], 582 | 'end': r'(?=,|[\n)])', 583 | } 584 | ], 585 | 'end': r'(?=,|[\n)])' 586 | } 587 | ], 588 | 'end': r'(?=\))' 589 | }, 590 | 'function_annotation': 591 | { 592 | 'begin': r'(?<=\))\s*(->)\s*', 593 | 'beginCaptures': 594 | { 595 | 1: {'name': 'keyword.operator.annotation.assignment.{SCOPE}'} 596 | }, 597 | 'patterns': 598 | [ 599 | {'include': '$self'} 600 | ], 601 | 'end': r'(?=\s*:)' 602 | }, 603 | 604 | 605 | #-- BUILTINS ------------------------------------------------------------------# 606 | 'builtin_exceptions': 607 | { 608 | 'name' : 'support.type.exception.{SCOPE}', 609 | 'match': 610 | ( 611 | r'(? what is magic function and what is magic variable? 671 | 'magic_variable_names': 672 | { 673 | 'name' : 'support.variable.magic.{SCOPE}', 674 | 'match': 675 | ( 676 | r'\b__(' 677 | r'all|annotations|bases|builtins|class|debug|dict|doc|file|' 678 | r'members|metaclass|mro|name|qualname|slots|weakref' 679 | r')__\b' 680 | ) 681 | }, 682 | # conventions 683 | 'language_variables': 684 | { 685 | 'name' : 'variable.language.{SCOPE}', 686 | 'match': r'(? group) 1574 | # (?(id/name)yes-pattern|no-pattern) 1575 | 'name' : 'constant.character.escape.{SCOPE}', 1576 | 'match': r'(?<=\()\?(=|!|<=||' 1577 | r'\(([1-9]\d?|[a-zA-Z_]\w*)\))' 1578 | # NOTE: the problem of making this to be a begin/end block 1579 | # is that the patterns needs to include the multiline- 1580 | # comments only if the expression is in multline 1581 | # quotes otherwise it should be exclude it... 1582 | }, 1583 | { 1584 | # (?P=this_is_a_group) 1585 | 'name' : 'keyword.other.group_reference_name.regex.{SCOPE}', 1586 | 'match': r'\((\?P=)([a-zA-Z_]\w*)\)', 1587 | 'captures': 1588 | { 1589 | 1: {'name': 'constant.character.escape.{SCOPE}'} 1590 | } 1591 | }, 1592 | { 1593 | # \g 1594 | 'name' : 'keyword.other.group_reference_name.regex.{SCOPE}', 1595 | 'match': r'(\\g)<([a-zA-Z_]\w*|[1-9]\d*)>', 1596 | 'captures': 1597 | { 1598 | 1: {'name': 'constant.character.escape.{SCOPE}'} 1599 | } 1600 | }, 1601 | { 1602 | 'name' : 'keyword.control.anchor.regex.{SCOPE}', 1603 | 'match': r'\\[bBAZzG]|\^|\$' 1604 | }, 1605 | { 1606 | # \number 1607 | 'name' : 'keyword.other.group_reference_order.regex.{SCOPE}', 1608 | 'match': r'\\[1-9]\d*' 1609 | }, 1610 | { 1611 | # {2}, {2,}, {,2}, {2,3}, {2,3}? 1612 | 'name' : 'keyword.operator.quantifier.regex.{SCOPE}', 1613 | 'match': r'[?+*][?+]?|\{(\d+,\d+|\d+,|,\d+|\d+)\}\??' 1614 | }, 1615 | { 1616 | 'name' : 'keyword.operator.or.regex.{SCOPE}', 1617 | 'match': r'\|' 1618 | }, 1619 | { 1620 | # (?# comment) 1621 | 'name' : 'comment.block.regex.{SCOPE}', 1622 | 'begin': r'\(\?#', 1623 | 'end' : r'\)' 1624 | }, 1625 | { 1626 | # flags: a: ASCII-only matching) 1627 | # i: ignore case 1628 | # L: locale dependent 1629 | # m: multi-line 1630 | # s: dot matches all 1631 | # u: unicode 1632 | # x: extended form (verbose) 1633 | 'name' : 'keyword.other.option_toggle.regex.{SCOPE}', 1634 | 'match': r'\(\?[aiLmsux]+\)' 1635 | }, 1636 | { 1637 | 'include': '#regular_expressions_escaped_characters' 1638 | }, 1639 | { 1640 | 'include': '#regular_expressions_character_classes' 1641 | }, 1642 | { 1643 | 'name' : 'keyword.operator.group.regex.{SCOPE}', 1644 | 'match': r'[()]' 1645 | } 1646 | ] 1647 | }, 1648 | 'regular_expressions_character_classes': 1649 | { 1650 | 'patterns': 1651 | [ 1652 | { 1653 | # \w, \W, \s, \S, \d, \D, . 1654 | 'name' : 'constant.character.character_class.regex.{SCOPE}', 1655 | 'match': r'\\[wWsSdD]|\.' 1656 | }, 1657 | { 1658 | # [set of characters] 1659 | 'name' : 'constant.other.character_class.set.regex.{SCOPE}', 1660 | 'begin': r'\[(\^)?(\](?=.*\]))?', 1661 | 'beginCaptures': 1662 | { 1663 | 1: {'name': 'keyword.operator.negation.regex.{SCOPE}'} 1664 | }, 1665 | 'patterns': 1666 | [ 1667 | { 1668 | 'name' : 'constant.character.escaped.special.regex.except.{SCOPE}', 1669 | 'match': r'\[|\\\\|\\\]' 1670 | }, 1671 | {'include': '#regular_expressions_character_classes'}, 1672 | {'include': '#regular_expressions_escaped_characters'} 1673 | ], 1674 | 'end': r'\]' 1675 | } 1676 | ] 1677 | }, 1678 | 'regular_expressions_escaped_characters': 1679 | { 1680 | 'name' : 'constant.character.escaped.special.regex.{SCOPE}', 1681 | 'match': r'\\(\\|\?|\.|\*|\+|\{|\}|\||\(|\)|\[|\]|\^|\$)' 1682 | }, 1683 | 1684 | 1685 | #-- FORMAT --------------------------------------------------------------------# 1686 | 'format_specifier': 1687 | { 1688 | # TODO: type-specific formatting 1689 | # >>> import datetime 1690 | # >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58) 1691 | # >>> '{:%Y-%m-%d %H:%M:%S}'.format(d) 1692 | 'patterns': 1693 | [ 1694 | {'include': '#format_escape'}, 1695 | { 1696 | 'name' : 'meta.interpolated.format.string.{SCOPE}', 1697 | 'begin': r'({)(\w*(\.\w+)*)?(!(a|r|s))?', 1698 | 'beginCaptures': 1699 | { 1700 | 1: {'name': 'string.interpolated.brace.fmt.{SCOPE}'}, 1701 | 2: {'name': 'variable.parameter.subscriptor.fmt.{SCOPE}'}, 1702 | 4: {'name': 'keyword.operator.exclamation.fmt.{SCOPE}'}, 1703 | 5: {'name': 'support.constant.ascii_repr_str.fmt.{SCOPE}'}, 1704 | }, 1705 | 'patterns': 1706 | [ 1707 | { 1708 | 'name' : 'meta.interpolated.format.specifier.{SCOPE}', 1709 | 'begin': r'(:)', 1710 | 'beginCaptures': 1711 | { 1712 | 1: {'name': 'keyword.operator.colon.fmt.{SCOPE}'}, 1713 | }, 1714 | 'patterns': 1715 | [ 1716 | {'include': '#format_specifier_fill_align'}, 1717 | {'include': '#format_specifier_sign'}, 1718 | {'include': '#format_specifier_alternate_form'}, 1719 | {'include': '#format_specifier_zero_padding'}, 1720 | {'include': '#format_specifier_width'}, 1721 | {'include': '#format_specifier_thousand_separator'}, 1722 | {'include': '#format_specifier_precision'}, 1723 | {'include': '#format_specifier_type'}, 1724 | {'include': '#format_specifier'} 1725 | ], 1726 | 'end': r'(?=})' 1727 | }, 1728 | {'include': '#format_specifier'} 1729 | ], 1730 | 'end': r'(})', 1731 | 'endCaptures': 1732 | { 1733 | 1: {'name': 'string.interpolated.brace.fmt.{SCOPE}'} 1734 | } 1735 | }, 1736 | ] 1737 | }, 1738 | 'format_specifier_fill_align': 1739 | { 1740 | 'name' : 'meta.fill_char.fmt.{SCOPE}', 1741 | 'begin': r'([^{}]?(<|>|=|\^))', 1742 | 'beginCaptures': 1743 | { 1744 | 1: {'name': 'string.quoted.fill_char.fmt.{SCOPE}'}, 1745 | 2: {'name': 'keyword.operator.align.fmt.{SCOPE}'} 1746 | }, 1747 | 'patterns': 1748 | [ 1749 | {'include': '#format_specifier_sign'}, 1750 | {'include': '#format_specifier_alternate_form'}, 1751 | {'include': '#format_specifier_zero_padding'}, 1752 | {'include': '#format_specifier_width'}, 1753 | {'include': '#format_specifier_thousand_separator'}, 1754 | {'include': '#format_specifier_precision'}, 1755 | {'include': '#format_specifier_type'}, 1756 | {'include': '#format_specifier'} 1757 | ], 1758 | 'end': r'(?=})' 1759 | }, 1760 | 'format_specifier_sign': 1761 | { 1762 | 'name' : 'meta.sign.fmt.{SCOPE}', 1763 | 'begin': r'(\+|-|\s)', 1764 | 'beginCaptures': 1765 | { 1766 | 1: {'name': 'keyword.operator.sign.fmt.{SCOPE}'} 1767 | }, 1768 | 'patterns': 1769 | [ 1770 | {'include': '#format_specifier_alternate_form'}, 1771 | {'include': '#format_specifier_zero_padding'}, 1772 | {'include': '#format_specifier_width'}, 1773 | {'include': '#format_specifier_thousand_separator'}, 1774 | {'include': '#format_specifier_precision'}, 1775 | {'include': '#format_specifier_type'}, 1776 | {'include': '#format_specifier'} 1777 | ], 1778 | 'end': r'(?=})' 1779 | }, 1780 | 'format_specifier_alternate_form': 1781 | { 1782 | 'name' : 'meta.alternate.fmt.{SCOPE}', 1783 | 'begin': r'(#)', 1784 | 'beginCaptures': 1785 | { 1786 | 1: {'name': 'support.constant.alternate.fmt.{SCOPE}'} 1787 | }, 1788 | 'patterns': 1789 | [ 1790 | {'include': '#format_specifier_zero_padding'}, 1791 | {'include': '#format_specifier_width'}, 1792 | {'include': '#format_specifier_thousand_separator'}, 1793 | {'include': '#format_specifier_precision'}, 1794 | {'include': '#format_specifier_type'}, 1795 | {'include': '#format_specifier'} 1796 | ], 1797 | 'end': r'(?=})' 1798 | }, 1799 | 'format_specifier_zero_padding': 1800 | { 1801 | 'name' : 'meta.zero_padding.fmt.{SCOPE}', 1802 | 'begin': r'(0)', 1803 | 'beginCaptures': 1804 | { 1805 | 1: {'name': 'constant.character.escape.zero_padding.fmt.{SCOPE}'} 1806 | }, 1807 | 'patterns': 1808 | [ 1809 | {'include': '#format_specifier_width'}, 1810 | {'include': '#format_specifier_thousand_separator'}, 1811 | {'include': '#format_specifier_precision'}, 1812 | {'include': '#format_specifier_type'}, 1813 | {'include': '#format_specifier'} 1814 | ], 1815 | 'end': r'(?=})' 1816 | }, 1817 | 'format_specifier_width': 1818 | { 1819 | 'name' : 'meta.width.fmt.{SCOPE}', 1820 | 'begin': r'(\d+)', 1821 | 'beginCaptures': 1822 | { 1823 | 1: {'name': 'constant.character.width.fmt.{SCOPE}'} 1824 | }, 1825 | 'patterns': 1826 | [ 1827 | {'include': '#format_specifier_thousand_separator'}, 1828 | {'include': '#format_specifier_precision'}, 1829 | {'include': '#format_specifier_type'}, 1830 | {'include': '#format_specifier'} 1831 | ], 1832 | 'end': r'(?=})' 1833 | }, 1834 | 'format_specifier_thousand_separator': 1835 | { 1836 | 'name' : 'meta.thousand_separator.fmt.{SCOPE}', 1837 | 'begin': r'(,)', 1838 | 'beginCaptures': 1839 | { 1840 | 1: {'name': 'keyword.operator.thousand_separator.fmt.{SCOPE}'} 1841 | }, 1842 | 'patterns': 1843 | [ 1844 | {'include': '#format_specifier_precision'}, 1845 | {'include': '#format_specifier_type'}, 1846 | {'include': '#format_specifier'} 1847 | ], 1848 | 'end': r'(?=})' 1849 | }, 1850 | 'format_specifier_precision': 1851 | { 1852 | 'name' : 'meta.precision.fmt.{SCOPE}', 1853 | 'begin': r'(\.\d+)', 1854 | 'beginCaptures': 1855 | { 1856 | 1: {'name': 'constant.character.precision.fmt.{SCOPE}'} 1857 | }, 1858 | 'patterns': 1859 | [ 1860 | {'include': '#format_specifier_type'}, 1861 | {'include': '#format_specifier'} 1862 | ], 1863 | 'end' : r'(?=})' 1864 | }, 1865 | 'format_specifier_type': 1866 | { 1867 | 'name' : 'meta.type.fmt.{SCOPE}', 1868 | 'begin': r'(b|c|d|e|E|f|F|g|G|n|o|s|x|X|%)', 1869 | 'beginCaptures': 1870 | { 1871 | 1: {'name': 'constant.character.escape.type.fmt.{SCOPE}'} 1872 | }, 1873 | 'patterns': 1874 | [ 1875 | {'include': '#format_specifier'} 1876 | ], 1877 | 'end': r'(?=})' 1878 | }, 1879 | 1880 | 1881 | #-- FSTRING -------------------------------------------------------------------# 1882 | 'format_specifier_extended': 1883 | { 1884 | 'patterns': 1885 | [ 1886 | {'include': '#format_escape'}, 1887 | { 1888 | 'name' : 'meta.interpolated.format.fstring.{SCOPE}', 1889 | 'begin': r'({)', 1890 | 'beginCaptures': 1891 | { 1892 | 1: {'name': 'string.interpolated.brace.fmt.{SCOPE}'} 1893 | }, 1894 | 'patterns': 1895 | [ 1896 | {'include': '#format_specifier_extended_self'}, 1897 | {'include': '#format_specifier_extended_ascii_repr_str'}, 1898 | {'include': '#format_specifier_extended_colon'}, 1899 | {'include': '#format_specifier_extended_fill_align'}, 1900 | {'include': '#format_specifier_extended_sign'}, 1901 | {'include': '#format_specifier_extended_alternate_form'}, 1902 | {'include': '#format_specifier_extended_zero_padding'}, 1903 | {'include': '#format_specifier_extended_width'}, 1904 | {'include': '#format_specifier_extended_thousand_separator'}, 1905 | {'include': '#format_specifier_extended_precision'}, 1906 | {'include': '#format_specifier_extended_type'}, 1907 | {'include': '#format_specifier_extended'}, 1908 | ], 1909 | 'end': r'(})', 1910 | 'endCaptures': 1911 | { 1912 | 1: {'name': 'string.interpolated.brace.fmt.{SCOPE}'} 1913 | } 1914 | } 1915 | ] 1916 | }, 1917 | 'format_specifier_extended_self': 1918 | { 1919 | 'patterns': 1920 | [ 1921 | { 1922 | 'name' : 'meta.self.{SCOPE}', 1923 | 'begin': r'(?<={)', 1924 | 'patterns': 1925 | [ 1926 | {'include': '$self'}, 1927 | ], 1928 | 'end': r'(?=!|:|})' 1929 | } 1930 | ] 1931 | }, 1932 | 'format_specifier_extended_ascii_repr_str': 1933 | { 1934 | 'patterns': 1935 | [ 1936 | { 1937 | 'name' : 'meta.ascii_repr_str.{SCOPE}', 1938 | 'begin': r'(!(a|r|s))', 1939 | 'beginCaptures': 1940 | { 1941 | 1: {'name': 'keyword.operator.exclamation.fmt.{SCOPE}'}, 1942 | 2: {'name': 'support.constant.ascii_repr_str.fmt.{SCOPE}'} 1943 | }, 1944 | 'patterns': 1945 | [ 1946 | {'include': '#format_specifier_extended_colon'}, 1947 | {'include': '#format_specifier_extended_fill_align'}, 1948 | {'include': '#format_specifier_extended_sign'}, 1949 | {'include': '#format_specifier_extended_alternate_form'}, 1950 | {'include': '#format_specifier_extended_zero_padding'}, 1951 | {'include': '#format_specifier_extended_width'}, 1952 | {'include': '#format_specifier_extended_thousand_separator'}, 1953 | {'include': '#format_specifier_extended_precision'}, 1954 | {'include': '#format_specifier_extended_type'}, 1955 | {'include': '#format_specifier_extended'} 1956 | ], 1957 | 'end': r'(?=})' 1958 | } 1959 | ] 1960 | }, 1961 | 'format_specifier_extended_colon': 1962 | { 1963 | 'patterns': 1964 | [ 1965 | { 1966 | 'name' : 'meta.colon.{SCOPE}', 1967 | 'begin': r'(:)', 1968 | 'beginCaptures': 1969 | { 1970 | 1: {'name': 'keyword.operator.colon.fmt.{SCOPE}'}, 1971 | }, 1972 | 'patterns': 1973 | [ 1974 | {'include': '#format_specifier_extended_fill_align'}, 1975 | {'include': '#format_specifier_extended_sign'}, 1976 | {'include': '#format_specifier_extended_alternate_form'}, 1977 | {'include': '#format_specifier_extended_zero_padding'}, 1978 | {'include': '#format_specifier_extended_width'}, 1979 | {'include': '#format_specifier_extended_thousand_separator'}, 1980 | {'include': '#format_specifier_extended_precision'}, 1981 | {'include': '#format_specifier_extended_type'}, 1982 | {'include': '#format_specifier_extended'} 1983 | ], 1984 | 'end': r'(?=})' 1985 | } 1986 | ] 1987 | }, 1988 | 'format_specifier_extended_fill_align': 1989 | { 1990 | 'name' : 'meta.fill_char.fmt.{SCOPE}', 1991 | 'begin': r'([^{}]?(<|>|=|\^))', 1992 | 'beginCaptures': 1993 | { 1994 | 1: {'name': 'string.quoted.fill_char.fmt.{SCOPE}'}, 1995 | 2: {'name': 'keyword.operator.align.fmt.{SCOPE}'} 1996 | }, 1997 | 'patterns': 1998 | [ 1999 | {'include': '#format_specifier_extended_sign'}, 2000 | {'include': '#format_specifier_extended_alternate_form'}, 2001 | {'include': '#format_specifier_extended_zero_padding'}, 2002 | {'include': '#format_specifier_extended_width'}, 2003 | {'include': '#format_specifier_extended_thousand_separator'}, 2004 | {'include': '#format_specifier_extended_precision'}, 2005 | {'include': '#format_specifier_extended_type'}, 2006 | {'include': '#format_specifier_extended'} 2007 | ], 2008 | 'end': r'(?=})' 2009 | }, 2010 | 'format_specifier_extended_sign': 2011 | { 2012 | 'name' : 'meta.sign.fmt.{SCOPE}', 2013 | 'begin': r'(\+|-|\s)', 2014 | 'beginCaptures': 2015 | { 2016 | 1: {'name': 'keyword.operator.sign.fmt.{SCOPE}'} 2017 | }, 2018 | 'patterns': 2019 | [ 2020 | {'include': '#format_specifier_extended_alternate_form'}, 2021 | {'include': '#format_specifier_extended_zero_padding'}, 2022 | {'include': '#format_specifier_extended_width'}, 2023 | {'include': '#format_specifier_extended_thousand_separator'}, 2024 | {'include': '#format_specifier_extended_precision'}, 2025 | {'include': '#format_specifier_extended_type'}, 2026 | {'include': '#format_specifier_extended'} 2027 | ], 2028 | 'end': r'(?=})' 2029 | }, 2030 | 'format_specifier_extended_alternate_form': 2031 | { 2032 | 'name' : 'meta.alternate.fmt.{SCOPE}', 2033 | 'begin': r'(#)', 2034 | 'beginCaptures': 2035 | { 2036 | 1: {'name': 'support.constant.alternate.fmt.{SCOPE}'} 2037 | }, 2038 | 'patterns': 2039 | [ 2040 | {'include': '#format_specifier_extended_zero_padding'}, 2041 | {'include': '#format_specifier_extended_width'}, 2042 | {'include': '#format_specifier_extended_thousand_separator'}, 2043 | {'include': '#format_specifier_extended_precision'}, 2044 | {'include': '#format_specifier_extended_type'}, 2045 | {'include': '#format_specifier_extended'} 2046 | ], 2047 | 'end': r'(?=})' 2048 | }, 2049 | 'format_specifier_extended_zero_padding': 2050 | { 2051 | 'name' : 'meta.zero_padding.fmt.{SCOPE}', 2052 | 'begin': r'(0)', 2053 | 'beginCaptures': 2054 | { 2055 | 1: {'name': 'constant.character.escape.zero_padding.fmt.{SCOPE}'} 2056 | }, 2057 | 'patterns': 2058 | [ 2059 | {'include': '#format_specifier_extended_width'}, 2060 | {'include': '#format_specifier_extended_thousand_separator'}, 2061 | {'include': '#format_specifier_extended_precision'}, 2062 | {'include': '#format_specifier_extended_type'}, 2063 | {'include': '#format_specifier_extended'} 2064 | ], 2065 | 'end': r'(?=})' 2066 | }, 2067 | 'format_specifier_extended_width': 2068 | { 2069 | 'name' : 'meta.width.fmt.{SCOPE}', 2070 | 'begin': r'(\d+)', 2071 | 'beginCaptures': 2072 | { 2073 | 1: {'name': 'constant.character.width.fmt.{SCOPE}'} 2074 | }, 2075 | 'patterns': 2076 | [ 2077 | {'include': '#format_specifier_extended_thousand_separator'}, 2078 | {'include': '#format_specifier_extended_precision'}, 2079 | {'include': '#format_specifier_extended_type'}, 2080 | {'include': '#format_specifier_extended'} 2081 | ], 2082 | 'end': r'(?=})' 2083 | }, 2084 | 'format_specifier_extended_thousand_separator': 2085 | { 2086 | 'name' : 'meta.thousand_separator.fmt.{SCOPE}', 2087 | 'begin': r'(,)', 2088 | 'beginCaptures': 2089 | { 2090 | 1: {'name': 'keyword.operator.thousand_separator.fmt.{SCOPE}'} 2091 | }, 2092 | 'patterns': 2093 | [ 2094 | {'include': '#format_specifier_extended_precision'}, 2095 | {'include': '#format_specifier_extended_type'}, 2096 | {'include': '#format_specifier_extended'} 2097 | ], 2098 | 'end': r'(?=})' 2099 | }, 2100 | 'format_specifier_extended_precision': 2101 | { 2102 | 'name' : 'meta.precision.fmt.{SCOPE}', 2103 | 'begin': r'(\.\d+)', 2104 | 'beginCaptures': 2105 | { 2106 | 1: {'name': 'constant.character.precision.fmt.{SCOPE}'} 2107 | }, 2108 | 'patterns': 2109 | [ 2110 | {'include': '#format_specifier_extended_type'}, 2111 | {'include': '#format_specifier_extended'} 2112 | ], 2113 | 'end' : r'(?=})' 2114 | }, 2115 | 'format_specifier_extended_type': 2116 | { 2117 | 'name' : 'meta.type.fmt.{SCOPE}', 2118 | 'begin': r'(b|c|d|e|E|f|F|g|G|n|o|s|x|X|%)', 2119 | 'beginCaptures': 2120 | { 2121 | 1: {'name': 'constant.character.escape.type.fmt.{SCOPE}'} 2122 | }, 2123 | 'patterns': 2124 | [ 2125 | {'include': '#format_specifier_extended'} 2126 | ], 2127 | 'end': r'(?=})' 2128 | }, 2129 | 2130 | 2131 | # TODO: the escape is not in use so far... 2132 | 'format_escape': 2133 | { 2134 | 'name' : 'constant.character.escape.fmt.{SCOPE}', 2135 | 'match': r'({{|}})' 2136 | }, 2137 | 2138 | 2139 | #-- TEMPLATE ------------------------------------------------------------------# 2140 | 'template_string': 2141 | { 2142 | 'name' : 'string.interpolated.template.{SCOPE}', 2143 | 'match': r'\$(\$|[a-zA-Z_]\w*|{[a-zA-Z_]\w*})' 2144 | } 2145 | }, 2146 | } 2147 | -------------------------------------------------------------------------------- /src/cython.py: -------------------------------------------------------------------------------- 1 | ## INFO ## 2 | ## INFO ## 3 | 4 | #-- CHEATSHEET ----------------------------------------------------------------# 5 | # HOWTO: http://sublimetext.info/docs/en/reference/syntaxdefs.html 6 | # REGEX: http://manual.macromates.com/en/regular_expressions 7 | 8 | # Import python modules 9 | from copy import deepcopy 10 | 11 | # Import user modules 12 | from src.common import syntax as original 13 | 14 | # Syntax Definition 15 | syntax = deepcopy(original) 16 | 17 | # Auto-recognition 18 | syntax['fileTypes'] = ['pyx', 'pxi', 'pxd'] 19 | syntax['keyEquivalent'] = '^~C' 20 | 21 | # Shebang 22 | syntax['firstLineMatch'] = r'^#!/.*\bpython[\d.-]*\b' 23 | 24 | # Folding marks for the TextEditor 25 | syntax['foldingStartMarker'] = (r'^\s*((cp?)?def|class)\s+([.\w>]+)\s*(\((.*)\))?\s*:' 26 | r'|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")') 27 | syntax['foldingStopMarker'] = r'^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$' 28 | 29 | # Language ID 30 | syntax['uuid'] = 'D085155B-E40A-40B3-8FEC-6865318CDEEA' 31 | 32 | # Patterns 33 | syntax['patterns'].update({ 34 | #-- COMMENT -------------------------------------------------------------------# 35 | # ALL ARE COMMON 36 | 37 | #-- KEYWORDS ------------------------------------------------------------------# 38 | 0x0080: 39 | { 40 | 'name' : 'storage.modifier.declaration.{SCOPE}', 41 | 'match': 42 | ( 43 | r'\b(global|nonlocal|gil|nogil|extern|api|public|readonly|' 44 | r'const(\svolatile)?|inline)\b' 45 | ) 46 | }, 47 | 48 | 0x0090: 49 | { 50 | 'name' : 'keyword.control.import_and_import_from.{SCOPE}', 51 | 'match': r'\b(cimport|include|extern|import|from)\b' 52 | }, 53 | 54 | 0x00A0: 55 | { 56 | 'name' : 'keyword.control.flow_block_delimiters.{SCOPE}', 57 | 'match': 58 | ( 59 | r'\b(elif|else|except|finally|for|if|try|while|with|break|' 60 | r'continue|pass|raise|return|yield|IF|ELIF|ELSE|DEF)\b' 61 | ) 62 | }, 63 | 64 | 0x00C0: 65 | { 66 | 'name' : 'keyword.other.{SCOPE}', 67 | 'match': r'\b(as|assert|by|del)\b' 68 | }, 69 | 70 | 71 | #-- OPERATORS -----------------------------------------------------------------# 72 | 0x0101: 73 | { 74 | 'name' : 'keyword.operator.type_test.{SCOPE}', 75 | 'match': r'\?' 76 | }, 77 | 78 | 79 | #-- CLASS ---------------------------------------------------------------------# 80 | 0x0110: 81 | { 82 | 'name' : 'meta.class.{SCOPE}', 83 | 'begin': r'^\s*(cdef\s+)?(class)\s+(?=[a-zA-Z_]\w*(\s*\()?)', 84 | 'beginCaptures': 85 | { 86 | 1: {'name': 'storage.type.class.definition.{SCOPE}'}, 87 | 2: {'name': 'storage.type.class.{SCOPE}'} 88 | }, 89 | 'patterns': 90 | [ 91 | {'include': '#class_entity_name'}, 92 | {'include': '#class_inheritance'} 93 | ], 94 | 'end' : r'(\)?\s*:|\s+([\w#\s:]+))', 95 | 'endCaptures': 96 | { 97 | 3: {'name': 'invalid.illegal.missing_section_begin.{SCOPE}'} 98 | } 99 | }, 100 | 101 | 102 | #-- FUNCTION ------------------------------------------------------------------# 103 | 0x0120: 104 | { 105 | 'name' : 'meta.function.{SCOPE}', 106 | 'begin': r'^\s*(async\s)?\s*((cp?)?def)\s+(?=[a-zA-Z_]\w*\s*\()', 107 | 'beginCaptures': 108 | { 109 | 1: {'name': 'storage.modifier.coroutine.{SCOPE}'}, 110 | 2: {'name': 'storage.type.function.{SCOPE}'} 111 | }, 112 | 'patterns': 113 | [ 114 | # TODO: highlight type declarations in functions! 115 | # Function name 116 | {'include': '#function_entity_name'}, 117 | # Arguments 118 | {'include': '#function_arguments'}, 119 | # Global Interpreter Lock 120 | { 121 | 'begin': r'\)\s*(nogil)\s*', 122 | 'beginCaptures': 123 | { 124 | 1: {'name': 'storage.modifier.declaration.{SCOPE}'} 125 | }, 126 | 'end': r'\s*((->)|:|\n+)' 127 | }, 128 | # Annotation assignment (function) 129 | {'include': '#function_annotation'} 130 | ], 131 | # todo: add illegal 132 | 'end': r'(\s*:|\n+)', 133 | 'endCaptures': 134 | { 135 | 2: {'name': 'invalid.illegal.missing_section_begin.{SCOPE}'} 136 | } 137 | }, 138 | 139 | 140 | #-- LAMBDA --------------------------------------------------------------------# 141 | # ALL ARE COMMON 142 | 143 | #-- DECORATOR -----------------------------------------------------------------# 144 | # ALL ARE COMMONE 145 | 146 | #-- CONSTANTS -----------------------------------------------------------------# 147 | 0x0160: 148 | { 149 | 'name' : 'constant.language.word_like.{SCOPE}', 150 | 'match': 151 | ( 152 | r'\b(NULL|None|True|False|Ellipsis|NotImplemented|' 153 | r'UNAME_SYSNAME|UNAME_NODENAME|UNAME_RELEASE|UNAME_VERSION|' 154 | r'UNAME_MACHINE|EXIT_FAILURE|EXIT_SUCCESS|RAND_MAX)\b' 155 | ) 156 | }, 157 | 158 | 159 | #-- STORAGES ------------------------------------------------------------------# 160 | 0x0180: 161 | { 162 | 'name' : 'storage.type.function.{SCOPE}', 163 | 'match': r'\b((c(p|type)?)?def|lambda)\b' 164 | }, 165 | 166 | 167 | #-- BUILTINS ------------------------------------------------------------------# 168 | 0x01A1: 169 | { 170 | 'include': '#c_types' 171 | }, 172 | 173 | 174 | #-- MAGIC STUFFS --------------------------------------------------------------# 175 | # ALL ARE COMMON 176 | 177 | #-- ETC -----------------------------------------------------------------------# 178 | # ALL ARE COMMON 179 | 180 | #-- STRUCTURES ----------------------------------------------------------------# 181 | # ALL ARE COMMON 182 | 183 | #-- ACCESS --------------------------------------------------------------------# 184 | # ALL ARE COMMON 185 | 186 | #-- STRING --------------------------------------------------------------------# 187 | # ALL ARE COMMON 188 | }) 189 | 190 | 191 | #-- REPOSITORY ----------------------------------------------------------------# 192 | syntax['repository'].update({ 193 | #-- COMMENTS ------------------------------------------------------------------# 194 | # ALL ARE COMMON 195 | 196 | #-- CLASS ---------------------------------------------------------------------# 197 | # ALL ARE COMMON 198 | 199 | #-- FUNCTION ------------------------------------------------------------------# 200 | # ALL ARE COMMON 201 | 202 | #-- BUILTINS ------------------------------------------------------------------# 203 | # TODO: rearrange -> what is builtin function and what is builtin type? 204 | 'builtin_functions': 205 | { 206 | 'name' : 'support.function.builtin.{SCOPE}', 207 | 'match': 208 | ( 209 | r'(? what is magic function and what is magic variable? 264 | 'magic_function_names': 265 | { 266 | 'name' : 'support.function.magic.{SCOPE}', 267 | 'match': 268 | ( 269 | r'\b__(' 270 | r'abs|add|and|await|bool|bytes|call|ceil|complex|contains|copy|' 271 | r'dealloc|deepcopy|del|delattr|delete|delitem|dir|div|divmod|a?enter|' 272 | r'eq|a?exit|float|floor|floordiv|format|ge|get|getattr|getattribute|' 273 | r'getinitargs|getitem|getnewargs|getstate|gt|hash|hex|iadd|' 274 | r'iand|idiv|ifloordiv|ilshift|imul|index|c?init|instancecheck|' 275 | r'int|invert|ior|ipow|irshift|isub|a?iter|itruediv|ixor|le|len|' 276 | r'lshift|lt|metaclass|missing|mod|mul|ne|neg|new|a?next|oct|or|' 277 | r'pos|pow|prepare|radd|rand|rdiv|rdivmod|reduce|reduce_ex|' 278 | r'repr|reversed|rfloordiv|rlshift|rmod|rmul|ror|round|rpow|' 279 | r'rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|' 280 | r'setstate|signatures|str|sub|subclasscheck|subclasshook|truediv|' 281 | r'trunc|unicode|weakref|xor' 282 | r')__\b' 283 | ) 284 | }, 285 | 286 | 287 | #-- STRING --------------------------------------------------------------------# 288 | # ALL ARE COMMON 289 | 290 | #-- REGEX ---------------------------------------------------------------------# 291 | # ALL ARE COMMON 292 | }) 293 | -------------------------------------------------------------------------------- /src/gloom.py: -------------------------------------------------------------------------------- 1 | ## INFO ## 2 | ## INFO ## 3 | 4 | # Import user modules 5 | from itertools import chain 6 | from colorsys import hsv_to_rgb 7 | 8 | # Keyword constants 9 | bg = 'background' 10 | fg = 'foreground' 11 | name = 'name' 12 | scope = 'scope' 13 | prefs = 'settings' 14 | font = 'fontStyle' 15 | bold = 'bold' 16 | italic = 'italic' 17 | 18 | def hsba(h, s, b, a=1.0): 19 | # syntax:fmt 20 | return '#' + ''.join('{:0>2X}'.format(int(v*255)) for v in (hsv_to_rgb(h/360, s, b) + (a,))) 21 | # end:fmt 22 | 23 | #------------------------------------------------------------------------------# 24 | style = { 25 | 'author': 'Peter Varo (C) 2013 - 2017', 26 | 'comment': ('\n\t\tCopyright (C) 2013 - 2017 Peter Varo' 27 | '\n\t\t' 28 | '\n\t\t' 29 | '\n' 30 | '\n\t\tThis program is free software: you can redistribute it' 31 | '\n\t\tand/or modify it under the terms of the GNU General' 32 | '\n\t\tPublic License as published by the Free Software' 33 | '\n\t\tFoundation, either version 3 of the License, or (at your' 34 | '\n\t\toption) any later version.' 35 | '\n' 36 | '\n\t\tThis program is distributed in the hope that it will be' 37 | '\n\t\tuseful, but WITHOUT ANY WARRANTY; without even the' 38 | '\n\t\timplied warranty of MERCHANTABILITY or FITNESS FOR A' 39 | '\n\t\tPARTICULAR PURPOSE. See the GNU General Public License' 40 | '\n\t\tfor more details.' 41 | '\n' 42 | '\n\t\tYou should have received a copy of the GNU General Public' 43 | '\n\t\tLicense along with this program, most likely a file in' 44 | '\n\t\tthe root directory, called "LICENSE". If not, see' 45 | '\n\t\t.' 46 | '\n\t'), 47 | 'uuid': '5E10F479-14B9-4DC1-B26C-557B2BB3FAE', 48 | name : '{NAME}', 49 | prefs: 50 | [ 51 | { 52 | prefs: 53 | { 54 | bg : hsba(0, 0, .08), 55 | fg : hsba(0, 0, .95), 56 | 'caret' : hsba(0, 0, .65), 57 | 'invisibles' : hsba(0, 0, 1, .10), 58 | 'lineHighlight': hsba(0, 0, 1, .04), 59 | 'selection' : hsba(0, 0, 1, .08) 60 | } 61 | }, 62 | { 63 | name : 'Comment', 64 | scope : 'comment', 65 | prefs : 66 | { 67 | fg : hsba(0, 0, .35), 68 | font: italic 69 | } 70 | }, 71 | { 72 | name : 'Constant', 73 | scope: 'constant', 74 | prefs: 75 | { 76 | fg: hsba(15, .65, .80) 77 | } 78 | }, 79 | { 80 | name : 'Entity', 81 | scope: 'entity', 82 | prefs: 83 | { 84 | fg: hsba(30, .60, .60) 85 | } 86 | }, 87 | { 88 | name : 'Keyword', 89 | scope: 'keyword', 90 | prefs: 91 | { 92 | fg: hsba(40, .50, .80) 93 | } 94 | }, 95 | { 96 | name : 'Storage', 97 | scope: 'storage', 98 | prefs: 99 | { 100 | fg: hsba(50, .40, .95) 101 | } 102 | }, 103 | { 104 | name : 'String', 105 | scope: 'string', 106 | prefs: 107 | { 108 | fg: hsba(75, .30, .60) 109 | } 110 | }, 111 | { 112 | name : 'Support', 113 | scope: 'support', 114 | prefs: 115 | { 116 | fg: hsba(295, .15, .60) 117 | } 118 | }, 119 | { 120 | name : 'Variable', 121 | scope: 'variable', 122 | prefs: 123 | { 124 | fg: hsba(220, .30, .65) 125 | } 126 | }, 127 | { 128 | name : 'Invalid Deprecated', 129 | scope: 'invalid.deprecated', 130 | prefs: 131 | { 132 | bg: hsba(10, .25, .80, .25) 133 | } 134 | }, 135 | { 136 | name : 'Invalid Illegal', 137 | scope: 'invalid.illegal', 138 | prefs: 139 | { 140 | bg: hsba(300, .50, .35, .60) 141 | } 142 | }, 143 | 144 | 145 | #-- DETAILS -------------------------------------------------------------------# 146 | { 147 | name : 'Entity Inherited Class', 148 | scope: 'entity.other.inherited-class', 149 | prefs: 150 | { 151 | fg: hsba(25, .70, .60), 152 | font: italic 153 | } 154 | }, 155 | { 156 | name : 'String Constant', 157 | scope: 'string constant', 158 | prefs: 159 | { 160 | fg: hsba(75, .30, .95) 161 | } 162 | }, 163 | { 164 | name : 'String Interpolated', 165 | scope: 'string.interpolated', 166 | prefs: 167 | { 168 | fg: hsba(120, .10, .85) 169 | } 170 | }, 171 | { 172 | name : 'Support Function', 173 | scope: 'support.function', 174 | prefs: 175 | { 176 | fg: hsba(55, .40, .85) 177 | } 178 | }, 179 | { 180 | name : 'Constant Character Escape', 181 | scope: 'constant.character.escape', 182 | prefs: 183 | { 184 | fg: hsba(30, .75, .80) 185 | } 186 | }, 187 | { 188 | name : 'Storage Modifier', 189 | scope: 'storage.modifier', 190 | prefs: 191 | { 192 | fg: hsba(30, .55, .80) 193 | } 194 | }, 195 | 196 | 197 | #-- LINTER --------------------------------------------------------------------# 198 | { 199 | name : 'SublimeLinter Annotations', 200 | scope: 'sublimelinter.annotations', 201 | prefs: 202 | { 203 | bg: hsba(60, .33, 1.0), 204 | fg: hsba(0, 0, 1) 205 | } 206 | }, 207 | { 208 | name : 'SublimeLinter Error Outline', 209 | scope: 'sublimelinter.outline.illegal', 210 | prefs: 211 | { 212 | bg: hsba(20, .80, .60), 213 | fg: hsba(0, 0, 1) 214 | } 215 | }, 216 | { 217 | name : 'SublimeLinter Error Underline', 218 | scope: 'sublimelinter.underline.illegal', 219 | prefs: 220 | { 221 | bg: hsba(20, .80, .95) 222 | } 223 | }, 224 | { 225 | name : 'SublimeLinter Warning Outline', 226 | scope: 'sublimelinter.outline.warning', 227 | prefs: 228 | { 229 | bg: hsba(40, .50, .50), 230 | fg: hsba(0, 0, 1) 231 | } 232 | }, 233 | { 234 | name : 'SublimeLinter Warning Underline', 235 | scope: 'sublimelinter.underline.warning', 236 | prefs: 237 | { 238 | bg: hsba(40, .50, .85) 239 | } 240 | }, 241 | { 242 | name : 'SublimeLinter Violation Outline', 243 | scope: 'sublimelinter.outline.violation', 244 | prefs: 245 | { 246 | bg: hsba(75, .40, .35), 247 | fg: hsba(0, 0, 1) 248 | } 249 | }, 250 | { 251 | name : 'SublimeLinter Violation Underline', 252 | scope: 'sublimelinter.underline.violation', 253 | prefs: 254 | { 255 | bg: hsba(75, .40, .70) 256 | } 257 | } 258 | ] 259 | } 260 | -------------------------------------------------------------------------------- /src/python.py: -------------------------------------------------------------------------------- 1 | ## INFO ## 2 | ## INFO ## 3 | 4 | #-- CHEATSHEET ----------------------------------------------------------------# 5 | # HOWTO: http://sublimetext.info/docs/en/reference/syntaxdefs.html 6 | # REGEX: http://manual.macromates.com/en/regular_expressions 7 | 8 | # Import python modules 9 | from copy import deepcopy 10 | 11 | # Import user modules 12 | from src.common import syntax as original 13 | 14 | # Syntax Definition 15 | syntax = deepcopy(original) 16 | 17 | # Auto-recognition 18 | syntax['fileTypes'] = ['py'] 19 | syntax['keyEquivalent'] = '^~P' 20 | 21 | # Shebang 22 | syntax['firstLineMatch'] = r'^#!/.*\bpython[\d.-]*\b' 23 | 24 | # Folding marks for the TextEditor 25 | syntax['foldingStartMarker'] = (r'^\s*(def|class)\s+([.\w>]+)\s*(\((.*)\))?\s*:' 26 | r'|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")') 27 | syntax['foldingStopMarker'] = r'^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$' 28 | 29 | # Language ID 30 | syntax['uuid'] = '851B1429-B8B4-4C1E-8030-399BDA994393' 31 | 32 | # Patterns 33 | syntax['patterns'].update({ 34 | #-- COMMENT -------------------------------------------------------------------# 35 | # ALL ARE COMMON 36 | 37 | #-- KEYWORDS ------------------------------------------------------------------# 38 | 0x0080: 39 | { 40 | 'name' : 'storage.modifier.declaration.{SCOPE}', 41 | 'match': r'\b(global|nonlocal)\b' 42 | }, 43 | 44 | 0x0090: 45 | { 46 | 'name' : 'keyword.control.import_and_import_from.{SCOPE}', 47 | 'match': r'\b(import|from)\b' 48 | }, 49 | 50 | 0x00A0: 51 | { 52 | 'name' : 'keyword.control.flow_block_delimiters.{SCOPE}', 53 | 'match': 54 | ( 55 | r'\b(elif|else|except|finally|for|if|try|while|' 56 | r'with|break|continue|pass|raise|return|yield)\b' 57 | ) 58 | }, 59 | 60 | 0x00C0: 61 | { 62 | 'name' : 'keyword.other.{SCOPE}', 63 | 'match': r'\b(as|assert|del)\b' 64 | }, 65 | 66 | 67 | #-- OPERATORS -----------------------------------------------------------------# 68 | # ALL ARE COMMON 69 | 70 | #-- CLASS ---------------------------------------------------------------------# 71 | 0x0110: 72 | { 73 | 'name' : 'meta.class.{SCOPE}', 74 | 'begin': r'^\s*(class)\s+(?=[a-zA-Z_]\w*(\s*\()?)', 75 | 'beginCaptures': 76 | { 77 | 1: {'name': 'storage.type.class.{SCOPE}'} 78 | }, 79 | 'patterns': 80 | [ 81 | {'include': '#class_entity_name'}, 82 | {'include': '#class_inheritance'} 83 | ], 84 | 'end' : r'(\)?\s*:|\s+([\w#\s:]+))', 85 | 'endCaptures': 86 | { 87 | 3: {'name': 'invalid.illegal.missing_section_begin.{SCOPE}'} 88 | } 89 | }, 90 | 91 | 92 | #-- FUNCTION ------------------------------------------------------------------# 93 | 0x0120: 94 | { 95 | 'name' : 'meta.function.{SCOPE}', 96 | 'begin': r'^\s*(async\s)?\s*(def)\s+(?=[a-zA-Z_]\w*\s*\()', 97 | 'beginCaptures': 98 | { 99 | 1: {'name': 'storage.modifier.coroutine.{SCOPE}'}, 100 | 2: {'name': 'storage.type.function.{SCOPE}'} 101 | }, 102 | 'patterns': 103 | [ 104 | # Function name 105 | {'include': '#function_entity_name'}, 106 | # Arguments 107 | {'include': '#function_arguments'}, 108 | # Annotation assignment (function) 109 | {'include': '#function_annotation'} 110 | ], 111 | # TODO: add illegal 112 | 'end': r'(\s*:)', 113 | 'endCaptures': 114 | { 115 | 2: {'name': 'invalid.illegal.missing_section_begin.{SCOPE}'} 116 | } 117 | }, 118 | 119 | 120 | #-- LAMBDA --------------------------------------------------------------------# 121 | # ALL ARE COMMON 122 | 123 | #-- DECORATOR -----------------------------------------------------------------# 124 | # ALL ARE COMMONE 125 | 126 | #-- CONSTANTS -----------------------------------------------------------------# 127 | 0x0160: 128 | { 129 | 'name' : 'constant.language.word_like.{SCOPE}', 130 | 'match': r'\b(None|True|False|Ellipsis|NotImplemented)\b' 131 | }, 132 | 133 | 134 | #-- STORAGES ------------------------------------------------------------------# 135 | 0x0180: 136 | { 137 | 'name' : 'storage.type.function.{SCOPE}', 138 | 'match': r'\b(def|lambda)\b' 139 | }, 140 | 141 | 142 | #-- BUILTINS ------------------------------------------------------------------# 143 | # ALL ARE COMMON 144 | 145 | #-- MAGIC STUFFS --------------------------------------------------------------# 146 | # ALL ARE COMMON 147 | 148 | #-- ETC -----------------------------------------------------------------------# 149 | # ALL ARE COMMON 150 | 151 | #-- STRUCTURES ----------------------------------------------------------------# 152 | # ALL ARE COMMON 153 | 154 | #-- ACCESS --------------------------------------------------------------------# 155 | # ALL ARE COMMON 156 | 157 | #-- STRING --------------------------------------------------------------------# 158 | # ALL ARE COMMON 159 | }) 160 | 161 | 162 | #-- REPOSITORY ----------------------------------------------------------------# 163 | syntax['repository'].update({ 164 | #-- COMMENTS ------------------------------------------------------------------# 165 | # ALL ARE COMMON 166 | 167 | #-- CLASS ---------------------------------------------------------------------# 168 | # ALL ARE COMMON 169 | 170 | #-- FUNCTION ------------------------------------------------------------------# 171 | # ALL ARE COMMON 172 | 173 | #-- BUILTINS ------------------------------------------------------------------# 174 | # TODO: rearrange -> what is builtin function and what is builtin type? 175 | 'builtin_functions': 176 | { 177 | 'name' : 'support.function.builtin.{SCOPE}', 178 | 'match': 179 | ( 180 | r'(? what is magic function and what is magic variable? 223 | 'magic_function_names': 224 | { 225 | 'name' : 'support.function.magic.{SCOPE}', 226 | 'match': 227 | ( 228 | r'\b__(' 229 | r'abs|add|and|await|bool|bytes|call|ceil|complex|contains|copy|' 230 | r'deepcopy|del|delattr|delete|delitem|dir|div|divmod|a?enter|eq|' 231 | r'a?exit|float|floor|floordiv|format|ge|get|getattr|getattribute|' 232 | r'getinitargs|getitem|getnewargs|getstate|gt|hash|hex|iadd|' 233 | r'iand|idiv|ifloordiv|ilshift|imul|index|init|instancecheck|' 234 | r'int|invert|ior|ipow|irshift|isub|a?iter|itruediv|ixor|le|len|' 235 | r'lshift|lt|metaclass|missing|mod|mul|ne|neg|new|a?next|oct|or|' 236 | r'pos|pow|prepare|radd|rand|rdiv|rdivmod|reduce|reduce_ex|' 237 | r'repr|reversed|rfloordiv|rlshift|rmod|rmul|ror|round|rpow|' 238 | r'rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|' 239 | r'setstate|sizeof|str|sub|subclasscheck|subclasshook|truediv|' 240 | r'trunc|unicode|weakref|xor' 241 | r')__\b' 242 | ) 243 | }, 244 | 245 | 246 | #-- STRING --------------------------------------------------------------------# 247 | # ALL ARE COMMON 248 | 249 | #-- REGEX ---------------------------------------------------------------------# 250 | # ALL ARE COMMON 251 | }) 252 | -------------------------------------------------------------------------------- /tests/Python3.py: -------------------------------------------------------------------------------- 1 | from module import Klass 2 | from math import pi as PI 3 | from matrix import MAT1, MAT2 4 | 5 | def class_decorator(cls): 6 | 7 | cls.__call__ = lambda self: print('Cabbage!') 8 | return cls 9 | 10 | @class_decorator 11 | class Class(Klass): 12 | 13 | @property 14 | def property(self): 15 | temp, ellipsis = self._property 16 | return {temp} if temp%0x12f2 else set() 17 | 18 | @property.setter 19 | def property(self, value): 20 | try: 21 | temp = value//0o123 22 | except TypeError: 23 | temp = 1. 24 | def do_something(m): 25 | nonlocal temp 26 | return temp, ... 27 | 28 | def __init__(self, *args, **kwargs): 29 | super().__init__(*args, **kwargs) 30 | print("I'm", "alive!", sep='\n') 31 | 32 | async def func(self : 'Class', 33 | callback : 'callable' 34 | domain : [0b00, PI], 35 | opt : bool=True) -> None: 36 | 37 | """ doc string """ 38 | 39 | self._property = await callback(MAT1 @ MAT2) 40 | 41 | r'''(?>12} => {u:0>16b} {{{v!r}}}' 47 | 48 | 49 | if __name__ == '__main__': 50 | c = Class() 51 | c.func(.12) 52 | c.property = 0b1011101110 53 | -------------------------------------------------------------------------------- /tests/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Syntax Highlighting 4 | 5 | 6 | 7 |
  8 | 
  9 | # this is a comment
 10 | 0x12
 11 | 0o2
 12 | 0b0010101011110000
 13 | 1
 14 | 17256134
 15 | .3634
 16 | 1.
 17 | 0.12345689
 18 | 1.23e10
 19 | 1.23e+10
 20 | 1.23e-10
 21 | 1.23E10
 22 | 1.23E+10
 23 | 1.23E-10
 24 | 10e12
 25 | 10e+12
 26 | 10e-12
 27 | 10E12
 28 | 10E+12
 29 | 10E-12
 30 | 10j
 31 | 10.j
 32 | 3.14j
 33 | 10.j
 34 | 10j
 35 | .001j
 36 | 1e100j
 37 | 3.14e-10j
 38 | print(.012)
 39 | hello12 = .344
 40 | hello_12 = 12.
 41 | 
 42 | True
 43 | False
 44 | None
 45 | Ellipsis
 46 | NotImplemented
 47 | [...]
 48 | ...
 49 | 
 50 | '\x78ff'
 51 | 
 52 | r'[a-zA-Z_\]]'
 53 | 
 54 | import re
 55 | s = 'this is ]]]]]] text'
 56 | print(re.findall(r'[]]', s))
 57 | 
 58 | "hello {}".format("python")
 59 | 
 60 | #format("hello {}", 'python')
 61 | print(str.format("hello {}", 'python'))
 62 | 
 63 | r'raw'
 64 | u'unicode.'
 65 | rB'raw byte' + Br'raw byte'
 66 | '\b\r\n\t\v\'\"'
 67 | '''hello\x78'''
 68 | 'hello\x78'
 69 | '''\\'''
 70 | "hello\x78"
 71 | 
 72 | 
 73 | r'[a-z]'
 74 | 
 75 | r'^hello$'
 76 | r'a{4,}b'
 77 | r'a+?(?#this is a comment)'
 78 | 
 79 | r'(?<!\b|$)\d'
 80 | '''(?<!\b|$)\d'''
 81 | 
 82 | a = r'''(?x)\d +  (?# the integral part)
 83 |             \.    (?# the decimal point)
 84 |             \d *  (?# some fractional digits)'''
 85 | 
 86 | {
 87 |     'hello':
 88 |     {
 89 |         'you':
 90 |         {
 91 |             'little':
 92 |             {
 93 |                 'somebody':
 94 |                 (
 95 |                     r'x{2}',
 96 |                     r'\u78ff'
 97 |                 )
 98 |             }
 99 |         }
100 |     }
101 | }
102 | 
103 | 
104 | def hello():
105 |     pass
106 | 
107 | def hello0() -> (i for i in range(10)):
108 |     pass
109 | 
110 | def hello1(world):
111 |     pass
112 | 
113 | def hello2(world) -> True:
114 |     pass
115 | 
116 | def hello3(world, you):
117 |     pass
118 | 
119 | def hello4(world, you) -> (12, 13, 14):
120 |     pass
121 | 
122 | def hello5(world: None):
123 |     pass
124 | 
125 | def hello6(world: None) -> True:
126 |     pass
127 | 
128 | def hello7(world: None, you):
129 |     pass
130 | 
131 | def hello8(world: None, you) -> (12, 13, 14):
132 |     pass
133 | 
134 | def hello9(world: [None, 12], hex, help, jelp, huh: [12, 23, 45], huhu, hah):
135 |     pass
136 | 
137 | def hello10(world: [None, 12]) -> True:
138 |     pass
139 | 
140 | def hello11(world: None, you: range(1, 10, 2), a):
141 |     pass
142 | 
143 | def hello12(world: None, you: [(1, 2), (3, 4), (5, 6)]) -> (12, 13, 14):
144 |     pass
145 | 
146 | def hello13(world):
147 |     pass
148 | 
149 | def hello14(world, come, on):
150 |     pass
151 | 
152 | def hello15(world=12):
153 |     pass
154 | 
155 | def decorator(func):
156 |     return func
157 | 
158 | @decorator
159 | def hello16(world=(12, 23)):
160 |     pass
161 | 
162 | def deco(a, b):
163 |     def wrap(func):
164 |         pass
165 |     return wrap
166 | 
167 | @deco(12**2, b=34)
168 | def hello18(world, come, on=1, you=2):
169 |     pass
170 | 
171 | def hello19(*args, **kwargs):
172 |     pass
173 | 
174 | def hello20(world, come, *args, on=1, you=3, **kwargs):
175 |     pass
176 | 
177 | def hello21(world: True):
178 |     pass
179 | 
180 | def hello22(world: 0, come: 'on' = True, this: None = None, true: (True,) = True):
181 |     pass
182 | 
183 | def hello23(world) -> None:
184 |     pass
185 | 
186 | def hello24(world: 'nice to meet you' = 12, come: 'on you bastard' = 23) -> '':
187 |     pass
188 | 
189 | (lambda e, f, g: e + f + g)
190 | lambda: 12**2
191 | lambda alfa: True if alfa else False
192 | lambda *args, **kwargs: None
193 | lambda a=12, b=23: a+b
194 | lambda a = [(1, 2), (3, 4)], b=[(5, 6)]: zip(a, b)
195 | 
196 | global x
197 | x = 2
198 | def f():
199 |     y = 10
200 |     def ff():
201 |         nonlocal y
202 |         y**2
203 | 
204 | 
205 | import math
206 | math.sqrt(4)
207 | 
208 | from math import sqrt
209 | sqrt(4)
210 | 
211 | 
212 | if x >= 1:
213 |     print()
214 | elif not x:
215 |     print()
216 | else:
217 |     print()
218 | 
219 | class Hello:
220 |     def __init__(self, other):
221 |         pass
222 |     def testing(self):
223 |         self.a = NotImplemented
224 |     def hahaha(cls, b):
225 |         cls.var = b
226 | 
227 | class World(object):  # this is some comment
228 |     def __init__(self, other):
229 |         pass
230 |     def testing(self):
231 |         self.a = NotImplemented
232 |     def hahaha(cls, b):
233 |         cls.var = b
234 | 
235 | class Python(list, Hello, World):
236 |     def __init__(self, other):
237 |         pass
238 |     def testing(self):
239 |         self.a = NotImplemented
240 |     def hahaha(cls, b):
241 |         cls.var = b
242 | 
243 | class Spam(metaclass=type):
244 |     def __init__(self, other):
245 |         pass
246 |     def testing(self):
247 |         self.a = NotImplemented
248 |     def hahaha(cls, b):
249 |         cls.var = b
250 | 
251 | class Hey():
252 |     def __init__(self, other):
253 |         pass
254 |     def testing(self):
255 |         self.a = NotImplemented
256 |     def hahaha(cls, b):
257 |         cls.var = b
258 | 
259 | string = 'abcde'
260 | 
261 | def mul_str(s: 'string', n: 'multiplier' = 'hello') -> 'doubled each string':
262 |     return ''.join(c*n for c in s)
263 | 
264 | print(mul_str.__annotations__)
265 | 
266 | def func(some, arguments, *args, other='keywords', **kwargs):
267 |     pass
268 | 
269 | def life(*, hello, world):
270 |     print(hello, world)
271 | 
272 | life(hello='a', world='b')
273 | 
274 | def h() -> {i: j for i, j in [(1, 2), (3, 4), (5, 6)]}:
275 |     pass
276 | 
277 | property
278 | print(h.__annotations__['return'])
279 | 
280 | 
281 | 282 | 283 | 284 | 285 | -------------------------------------------------------------------------------- /tests/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf8 -*- 3 | 4 | # this is a comment 5 | 0x12 6 | 0o2 7 | 0b0010101011110000 8 | 1 9 | 17256134 10 | .3634 11 | 1. 12 | 0.12345689 13 | 1.e10 14 | 1.23e10 15 | 1.23e+10 16 | 1.23e-10 17 | 1.23E10 18 | 1.23E+10 19 | 1.23E-10 20 | 10e12 21 | 10e+12 22 | 10e-12 23 | 10E12 24 | 10E+12 25 | 10E-12 26 | 10j 27 | 10.j 28 | 3.14j 29 | 10.j 30 | 10j 31 | .001j 32 | 1e100j 33 | 3.14e-10j 34 | print(.012) 35 | hello12 = .344 36 | hello_12 = 12. 37 | 38 | True 39 | False 40 | None 41 | Ellipsis 42 | NotImplemented 43 | [...] 44 | ... 45 | 46 | 'some text %(name)s and all the other' % {'name': 'other_text'} 47 | 48 | dict(hello=12) 49 | 50 | '\x78ff' 51 | 52 | r'[a-zA-Z_\]]' 53 | r'[]]' 54 | r'[[]' 55 | r'[\\]]' 56 | r'[\\]' 57 | r'[^\\]' 58 | 59 | pattern = r""" 60 | # Capture shebang lines if any 61 | ([#]!.*?)* 62 | # Capture opening block 63 | (?P 64 | ((?P{})+|({})) 65 | \s*INFO\s*(?P.)) 66 | .*? # previous content of comment 67 | # Capture closing block 68 | (?P 69 | (?P=pad)\s*INFO\s* 70 | # if line comment: 71 | (?(line) 72 | # capture line closing 73 | (?P=line)+ 74 | |# else: 75 | # capture block closing 76 | ({}))) 77 | """ 78 | 79 | r'(\()' 80 | r'\this\is\a\path' 81 | 82 | 83 | import re 84 | s = 'this is ]]]]]] text' 85 | print(re.findall(r'[]]', s)) 86 | 87 | "hello {}".format("python") 88 | 89 | #format("hello {}", 'python') 90 | print(str.format("hello {}", 'python')) 91 | 92 | r'raw' 93 | u'unicode.' 94 | rB'raw byte' + Br'raw byte' 95 | '\b\r\n\t\v\'\"' 96 | '''hello\x78''' 97 | 'hello\x78' 98 | '''\\''' 99 | "hello\x78" 100 | """khj 101 | """ 102 | 103 | 104 | r'[a-z]' 105 | 106 | r'^hello$' 107 | r'a{4,}b' 108 | r'a+?(?#this is a comment)' 109 | 110 | r'(? (i for i in range(10)): 139 | pass 140 | 141 | def hello1(world): 142 | pass 143 | 144 | def hello2(world) -> True: 145 | pass 146 | 147 | def hello3(world, you): 148 | pass 149 | 150 | def hello4(world, you) -> (12, 13, 14): 151 | pass 152 | 153 | def hello5(world: None): 154 | pass 155 | 156 | def hello6(world: None) -> True: 157 | pass 158 | 159 | def hello7(world: None, you): 160 | pass 161 | 162 | def hello8(world: None, you) -> (12, 13, 14): 163 | pass 164 | 165 | def hello9(world: [None, 12], hex, help, jelp, huh: [12, 23, 45], huhu, hah): 166 | pass 167 | 168 | def hello10(world: [None, 12]) -> True: 169 | pass 170 | 171 | def hello11(world: None, you: range(1, 10, 2), a): 172 | pass 173 | 174 | def hello12(world: None, you: [(1, 2), (3, 4), (5, 6)]) -> (12, 13, 14): 175 | pass 176 | 177 | def hello13(world): 178 | pass 179 | 180 | def hello14(world, come, on): 181 | pass 182 | 183 | def hello15(world=12): 184 | pass 185 | 186 | def decorator(func): 187 | return func 188 | 189 | @decorator 190 | def hello16(world=(12, 23)): 191 | pass 192 | 193 | def deco(a, b): 194 | def wrap(func): 195 | pass 196 | return wrap 197 | 198 | @deco(12**2, b=34) 199 | def hello18(world, come, on=1, you=2): 200 | pass 201 | 202 | def hello19(*args, **kwargs): 203 | pass 204 | 205 | def hello20(world, come, *args, on=1, you=3, **kwargs): 206 | pass 207 | 208 | def hello21(world: True): 209 | pass 210 | 211 | def hello22(world: 0, come: 'on' = True, this: None = None, true: (True,) = True): 212 | pass 213 | 214 | def hello23(world) -> None: 215 | pass 216 | 217 | def hello24(world: 'nice to meet you' = 12, come: 'on you bastard' = 23) -> '': 218 | pass 219 | 220 | def hello25(arg1, # enable 221 | arg2, # multiline 222 | arg3): # comments 223 | pass 224 | 225 | def hello26(arg1:'#', arg2='#', arg3:'#'='#'): 226 | pass 227 | 228 | def hello26(arg1:'#', # enable 229 | arg2='#', # multiline 230 | arg3:'#'='#'): # comments 231 | pass 232 | 233 | def hello26(arg1:'#', # enable 234 | arg2='#', # multiline 235 | arg3:'#'='#') -> '#': # comments 236 | pass 237 | 238 | (lambda e, f, g: e + f + g) 239 | lambda: 12**2 240 | lambda alfa: True if alfa else False 241 | lambda *args, **kwargs: None 242 | lambda a=12, b=23: a+b 243 | lambda a = [(1, 2), (3, 4)], b=[(5, 6)]: zip(a, b) 244 | lambda a,b,c: None 245 | 246 | global x 247 | x = 2 248 | def f(): 249 | y = 10 250 | def ff(): 251 | nonlocal y 252 | y**2 253 | 254 | 255 | import math 256 | math.sqrt(4) 257 | 258 | from math import sqrt 259 | sqrt(4) 260 | 261 | 262 | if x >= 1: 263 | print() 264 | elif not x: 265 | print() 266 | else: 267 | print() 268 | 269 | class Hello: 270 | def __init__(self, other): 271 | pass 272 | def testing(self): 273 | self.a = NotImplemented 274 | def hahaha(cls, b): 275 | cls.var = b 276 | 277 | class World(object): # this is some comment 278 | def __init__(self, other): 279 | pass 280 | def testing(self): 281 | self.a = NotImplemented 282 | def hahaha(cls, b): 283 | cls.var = b 284 | 285 | class Python(list, Hello, World): 286 | def __init__(self, other): 287 | pass 288 | def testing(self): 289 | self.a = NotImplemented 290 | def hahaha(cls, b): 291 | cls.var = b 292 | 293 | class Spam(metaclass=type): 294 | def __init__(self, other): 295 | pass 296 | def testing(self): 297 | self.a = NotImplemented 298 | def hahaha(cls, b): 299 | cls.var = b 300 | 301 | class Hey(): 302 | def __init__(self, other): 303 | pass 304 | def testing(self): 305 | self.a = NotImplemented 306 | def hahaha(cls, b): 307 | cls.var = b 308 | 309 | string = 'abcde' 310 | 311 | def mul_str(s: 'string', n: 'multiplier' = 'hello') -> 'doubled each string': 312 | return ''.join(c*n for c in s) 313 | 314 | print(mul_str.__annotations__) 315 | 316 | def func(some, arguments, *args, other='keywords', **kwargs): 317 | pass 318 | 319 | def life(*, hello, world): 320 | print(hello, world) 321 | 322 | life(hello='a', world='b') 323 | 324 | def h() -> {i: j for i, j in [(1, 2), (3, 4), (5, 6)]}: 325 | pass 326 | 327 | property 328 | print(h.__annotations__['return']) 329 | -------------------------------------------------------------------------------- /themes/Gloom.tmTheme: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | author 6 | Peter Varo (C) 2013 - 2017 7 | comment 8 | 9 | Copyright (C) 2013 - 2017 Peter Varo 10 | <http://github.com/petervaro/d2> 11 | <http://petervaro.com> 12 | 13 | This program is free software: you can redistribute it 14 | and/or modify it under the terms of the GNU General 15 | Public License as published by the Free Software 16 | Foundation, either version 3 of the License, or (at your 17 | option) any later version. 18 | 19 | This program is distributed in the hope that it will be 20 | useful, but WITHOUT ANY WARRANTY; without even the 21 | implied warranty of MERCHANTABILITY or FITNESS FOR A 22 | PARTICULAR PURPOSE. See the GNU General Public License 23 | for more details. 24 | 25 | You should have received a copy of the GNU General Public 26 | License along with this program, most likely a file in 27 | the root directory, called "LICENSE". If not, see 28 | <http://www.gnu.org/licenses>. 29 | 30 | name 31 | Gloom 32 | settings 33 | 34 | 35 | settings 36 | 37 | background 38 | #141414FF 39 | caret 40 | #A5A5A5FF 41 | foreground 42 | #F2F2F2FF 43 | invisibles 44 | #FFFFFF19 45 | lineHighlight 46 | #FFFFFF0A 47 | selection 48 | #FFFFFF14 49 | 50 | 51 | 52 | name 53 | Comment 54 | scope 55 | comment 56 | settings 57 | 58 | fontStyle 59 | italic 60 | foreground 61 | #595959FF 62 | 63 | 64 | 65 | name 66 | Constant 67 | scope 68 | constant 69 | settings 70 | 71 | foreground 72 | #CC6847FF 73 | 74 | 75 | 76 | name 77 | Entity 78 | scope 79 | entity 80 | settings 81 | 82 | foreground 83 | #996B3DFF 84 | 85 | 86 | 87 | name 88 | Keyword 89 | scope 90 | keyword 91 | settings 92 | 93 | foreground 94 | #CCAA66FF 95 | 96 | 97 | 98 | name 99 | Storage 100 | scope 101 | storage 102 | settings 103 | 104 | foreground 105 | #F2E291FF 106 | 107 | 108 | 109 | name 110 | String 111 | scope 112 | string 113 | settings 114 | 115 | foreground 116 | #8D996BFF 117 | 118 | 119 | 120 | name 121 | Support 122 | scope 123 | support 124 | settings 125 | 126 | foreground 127 | #978299FF 128 | 129 | 130 | 131 | name 132 | Variable 133 | scope 134 | variable 135 | settings 136 | 137 | foreground 138 | #7484A5FF 139 | 140 | 141 | 142 | name 143 | Invalid Deprecated 144 | scope 145 | invalid.deprecated 146 | settings 147 | 148 | background 149 | #CCA1993F 150 | 151 | 152 | 153 | name 154 | Invalid Illegal 155 | scope 156 | invalid.illegal 157 | settings 158 | 159 | background 160 | #592C5999 161 | 162 | 163 | 164 | name 165 | Entity Inherited Class 166 | scope 167 | entity.other.inherited-class 168 | settings 169 | 170 | fontStyle 171 | italic 172 | foreground 173 | #995A2DFF 174 | 175 | 176 | 177 | name 178 | String Constant 179 | scope 180 | string constant 181 | settings 182 | 183 | foreground 184 | #E0F2A9FF 185 | 186 | 187 | 188 | name 189 | String Interpolated 190 | scope 191 | string.interpolated 192 | settings 193 | 194 | foreground 195 | #C3D8C3FF 196 | 197 | 198 | 199 | name 200 | Support Function 201 | scope 202 | support.function 203 | settings 204 | 205 | foreground 206 | #D8D182FF 207 | 208 | 209 | 210 | name 211 | Constant Character Escape 212 | scope 213 | constant.character.escape 214 | settings 215 | 216 | foreground 217 | #CC7F33FF 218 | 219 | 220 | 221 | name 222 | Storage Modifier 223 | scope 224 | storage.modifier 225 | settings 226 | 227 | foreground 228 | #CC935BFF 229 | 230 | 231 | 232 | name 233 | SublimeLinter Annotations 234 | scope 235 | sublimelinter.annotations 236 | settings 237 | 238 | background 239 | #FFFFAAFF 240 | foreground 241 | #FFFFFFFF 242 | 243 | 244 | 245 | name 246 | SublimeLinter Error Outline 247 | scope 248 | sublimelinter.outline.illegal 249 | settings 250 | 251 | background 252 | #99471EFF 253 | foreground 254 | #FFFFFFFF 255 | 256 | 257 | 258 | name 259 | SublimeLinter Error Underline 260 | scope 261 | sublimelinter.underline.illegal 262 | settings 263 | 264 | background 265 | #F27130FF 266 | 267 | 268 | 269 | name 270 | SublimeLinter Warning Outline 271 | scope 272 | sublimelinter.outline.warning 273 | settings 274 | 275 | background 276 | #7F6A3FFF 277 | foreground 278 | #FFFFFFFF 279 | 280 | 281 | 282 | name 283 | SublimeLinter Warning Underline 284 | scope 285 | sublimelinter.underline.warning 286 | settings 287 | 288 | background 289 | #D8B46CFF 290 | 291 | 292 | 293 | name 294 | SublimeLinter Violation Outline 295 | scope 296 | sublimelinter.outline.violation 297 | settings 298 | 299 | background 300 | #505935FF 301 | foreground 302 | #FFFFFFFF 303 | 304 | 305 | 306 | name 307 | SublimeLinter Violation Underline 308 | scope 309 | sublimelinter.underline.violation 310 | settings 311 | 312 | background 313 | #A0B26BFF 314 | 315 | 316 | 317 | uuid 318 | 5E10F479-14B9-4DC1-B26C-557B2BB3FAE 319 | 320 | 321 | --------------------------------------------------------------------------------