├── .gitignore
├── .no-sublime-package
├── LICENSE
├── Neon.sublime-color-scheme
├── README.md
├── _config.yml
├── messages.json
├── messages
├── 1.1.0.txt
├── 1.1.4.txt
├── 1.1.6.txt
├── 1.3.0.txt
├── 2.0.0.txt
├── 3.1.0.txt
├── 3.2.0.txt
├── 3.2.1.txt
├── 3.2.2.txt
└── install.txt
├── packages.json
├── test files
├── LaTeX test.tex
├── Makefile
├── deep_json.json
├── lex-flex example.l
├── maths.tex
├── othello.lisp
└── yacc-bison example.y
└── widget settings
├── Console Input Widget.sublime-settings
├── Regex Replace Widget.sublime-settings
├── Regex Widget.sublime-settings
└── Widget.sublime-settings
/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore working JSON version
2 | Neon.tmTheme.JSON
3 | .DS_Store
4 | build
5 |
--------------------------------------------------------------------------------
/.no-sublime-package:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2022 Matthew D. Morrison
4 | =======
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://packagecontrol.io/packages/Neon%20Color%20Scheme)
2 | [](https://github.com/MattDMo/Neon-color-scheme/releases/latest)
3 | 
4 | [](https://paypal.me/MattMorrison966)
5 | 
6 |
7 |
8 | # Neon Color Scheme
9 |
10 | **Neon** is a colorful bright-on-black color scheme for [Sublime Text](https://www.sublimetext.com/). In designing it, I've aimed to make as many languages as possible look as good as possible, taking advantage of as many of the available [scopes](https://www.sublimetext.com/docs/scope_naming.html) as I can. **Neon** was originally designed for [Python](http://www.python.org), which has a very detailed language definition, but lots of languages look good with it, like JavaScript, CSS, HTML, Ruby, PHP, shell scripts, XML, Clojure, Fortran, R, LaTeX, Markdown, reStructuredText, and more. It's also great when using [@wuub](https://github.com/wuub)'s fantastic [SublimeREPL](https://packagecontrol.io/packages/SublimeREPL) plugin, which I can't say enough good things about. Unfortunately it is no longer being maintained.
11 |
12 | Just for clarity's sake: **Neon** is an original work and wasn't based on any other color scheme. If you search [Package Control](https://packagecontrol.io) for [`neon`](https://packagecontrol.io/search/neon) you'll find some other, similarly-named color schemes which are *not* based on this project. Use them if you want -- I particularly like the [Dark Neon Color Scheme](https://packagecontrol.io/packages/Dark%20Neon%20Color%20Scheme), and might borrow some of the colors -- and if you want to fork this project and make your own derivative, go for it! I use the [MIT License](http://opensource.org/licenses/MIT) for a reason.
13 |
14 |
15 | 
16 |
17 | 
18 |
19 |
20 | ## Languages/Plugins Supported
21 |
22 | Neon's main goal is to make as many languages as possible look as good as possible. That being said, there are some language/markup/framework-specific scopes and sections that you might be interested in:
23 |
24 | * [Android Debug Bridge](https://packagecontrol.io/packages/ADBView)/[logcat](https://github.com/leesei/logcat.tmLanguage)
25 | * [AutoHotKey](https://packagecontrol.io/packages/AutoHotKey)
26 | * Bison/YACC
27 | * [BracketHighlighter](https://packagecontrol.io/packages/BracketHighlighter)
28 | * C/C++/[C Improved](https://packagecontrol.io/packages/C%20Improved)
29 | * C#
30 | * Clojure/EDN
31 | * Coffeescript
32 | * CSS/SASS/SCSS - specifically, the [`Syntax Highlighting for SASS`](https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20Sass) package
33 | * diff
34 | * [Dockerfiles](https://packagecontrol.io/packages/Dockerfile%20Syntax%20Highlighting)
35 | * `Find In Files`
36 | * [Fortran](https://packagecontrol.io/packages/Fortran)
37 | * [Git Gutter](https://packagecontrol.io/packages/GitGutter)
38 | * [Handlebars](https://packagecontrol.io/packages/Handlebars)
39 | * Haskell
40 | * HTML/XML
41 | * Java
42 | * JavaScript/[JavaScriptNext](https://packagecontrol.io/packages/JavaScriptNext%20-%20ES6%20Syntax)/Node.js
43 | * [jQuery](https://packagecontrol.io/packages/jQuery)
44 | * JSON
45 | * JSX/[Babel/React](https://packagecontrol.io/packages/Babel)
46 | * LaTeX
47 | * Lisp
48 | * Lua
49 | * Makefile
50 | * Markdown/reStructuredText
51 | * Matlab
52 | * [Mediawiker](https://packagecontrol.io/packages/Mediawiker) wiki markup
53 | * [PackageDev](https://packagecontrol.io/packages/PackageDev) `.sublime-settings`, `.sublime-keymap`, `.sublime-mousemap`, `.sublime-macro`, `.YAML-tmLanguage`, etc.
54 | * Perl
55 | * PHP/[Laravel Blade](https://packagecontrol.io/packages/Laravel%20Blade%20Highlighter)
56 | * Python
57 | - [IPython](http://ipython.org)/[Jupyter](http://jupyter.org) within [SublimeREPL](https://packagecontrol.io/packages/SublimeREPL)
58 | - Django/[Djaneiro](https://packagecontrol.io/packages/Djaneiro)
59 | - [Jinja2 templates](https://github.com/mitsuhiko/jinja2-tmbundle)
60 | - All the customizations in the [`Python Improved`](https://packagecontrol.io/packages/Python%20Improved) syntax definition
61 | - The new default [`Python.sublime-syntax`](https://github.com/sublimehq/Packages/blob/master/Python/Python.sublime-syntax)
62 | * R/[R-Box](https://packagecontrol.io/packages/R-Box)
63 | * [RAML](https://packagecontrol.io/packages/RAML%20Syntax%20Highlighter)
64 | * Regular Expressions
65 | * Ruby
66 | * Rust
67 | * Scala
68 | * Shell Scripts/[ShellScriptImproved](https://packagecontrol.io/packages/ShellScriptImproved)
69 | * SQL
70 | * [SublimeLinter](https://packagecontrol.io/packages/SublimeLinter)
71 | * [Swift](https://packagecontrol.io/packages/Swift)
72 | * Table of Contents/Task Tags
73 | * [TOML](https://packagecontrol.io/packages/TOML)
74 | * [Typescript](https://packagecontrol.io/packages/TypeScript%20Syntax)
75 | * [Vue](https://packagecontrol.io/packages/Vue%20Syntax%20Highlight)
76 | * YAML
77 |
78 | For major changes, I'll test most if not all of the above languages, with maybe some others thrown in for fun. When I say "as many languages as possible" I mean it!
79 |
80 | 
81 |
82 | If you have a particular language or plugin you'd like Neon to support, just [open an issue](https://github.com/MattDMo/Neon-color-scheme/issues/new) and I'll see what I can do.
83 |
84 | There are a bunch of scopes in here that are only found in my [`Python Improved`](https://packagecontrol.io/packages/Python%20Improved) language definition package — [IPython](https://www.ipython.org) `In`/`Out` statements, [Django](https://djangoproject.org)-specific highlighting (adapted from [`Djaneiro`](https://packagecontrol.io/packages/Djaneiro)), a bunch of improvements from [@facelessuser](https://github.com/facelessuser)'s [`Better Python`](https://github.com/facelessuser/sublime-languages/tree/master/Better%20Python) and [@petervaro](https://github.com/petervaro)'s [Python 3](https://packagecontrol.io/packages/Python%203) package, along with various enhancements, extensions, and bug fixes of my own and contributed by others. If you work with Python, I'd highly recommend getting it.
85 |
86 | 
87 |
88 | 
89 |
90 |
91 | ## Development Tools
92 |
93 | There are several plugins and other resources I use that are absolutely invaluable to my development efforts. First and foremost, I'm always using the latest [development version](https://www.sublimetext.com/dev) of Sublime Text 4, [registered](https://www.sublimetext.com/buy) of course. Some features of **Neon** are specific to ST4, so make sure you're up to date! It will still work in ST3 3.1 and above, just the experience won't be quite as good.
94 |
95 | There are two plugins that I couldn't do this without: [`ScopeAlways`](https://packagecontrol.io/packages/ScopeAlways) displays the scope of the current cursor position in the status bar, which is immensely helpful. The other is [@facelessuser's](https://packagecontrol.io/browse/authors/facelessuser) [`ColorHelper`](https://packagecontrol.io/packages/ColorHelper). Do you write CSS or any of its relatives? Do you do anything with color at all, in hex, RGB(A), HSL, LAB, or any one of a million other formats? If you're using one of those *other* color plugins, with difficult configuration and unreliable performance, dump it and install `ColorHelper`. It's simple to configure, yet incredibly powerful for all sorts of use cases. It provides configurable inline color previews, including with/without alpha. The color picker is custom-made and very easy to use, with palette and slider modes, the latter of which allows for very minute adjustments of each channel that you're working with. Seriously, this thing is awesome. Throw this guy [some love](https://facelessuser.github.io/ColorHelper/about/contributing/#contributing--support) while you're at it - he deserves it! He also maintains [`BracketHighlighter`](https://packagecontrol.io/packages/BracketHighlighter), [`ApplySyntax`](https://packagecontrol.io/packages/ApplySyntax), [`ExportHTML`](https://packagecontrol.io/packages/ExportHTML), and a bunch of other stuff.
96 |
97 | I want to thank the authors of all the language-specific plugins I listed above, as I have them installed, and couldn't make **Neon** what it is without them. Included in that bunch is the group working on the [default Sublime packages](https://github.com/sublimehq/Packages). If you've written a language syntax, or even just know of one that's not listed and you'd like Neon to support it better, just [drop me a line](https://github.com/MattDMo/Neon-color-scheme/issues/new).
98 |
99 | The last resource I make use of somewhat often is this fantastic website: [colortools.net](https://www.colortools.net/). It complements `ColorHelper` very well, with options like opposite colors (very useful for finding good foreground/background pairs), close colors and color similarity, a text on background preview, and a whole lot more. Many of the tools also have a "web-safe" option if your work requires that.
100 |
101 |
102 | ## What Font is That?
103 |
104 | I discovered [`Cousine`](https://www.google.com/fonts/specimen/Cousine) while browsing Google Fonts one day and absolutely love it.
105 |
106 | > Cousine was designed by [Steve Matteson](https://en.wikipedia.org/wiki/Steve_Matteson) as an innovative, refreshing sans serif design that is metrically compatible with Courier New™. Cousine offers improved on-screen readability characteristics and the pan-European WGL character set and solves the needs of developers looking for width-compatible fonts to address document portability across platforms.
107 |
108 | It was one of the first things I installed when setting up a new workstation or VM, and it used to be my go-to monospace font for web design and programming.
109 |
110 | For a while now, I've been using [`Liberation Mono`](http://www.fontsquirrel.com/fonts/Liberation-Mono), part of the open-source [Liberation](https://github.com/liberationfonts/liberation-fonts) font family, also initially designed by Matteson. It's almost an exact duplicate of Cousine (with a few minor differences), and has the advantage of being available for Fedora (out of the box) and RHEL/CentOS as `liberation-fonts`, and as `ttf-liberation` for Debian and Ubuntu (my current distro of choice).
111 |
112 | 
113 |
114 | 
115 |
116 |
117 | ## Installation for Sublime Text
118 |
119 | The easiest method is through [Package Control](https://packagecontrol.io/), which now comes with Sublime Text. Open the Command Palette with CtrlShiftP (Windows/Linux) or ⌘ShiftP (macOS) and type ***`pci`*** to bring up `Package Control: Install`. Hit Enter, type in `neon`, and `Neon Color Scheme` should show up. Select it, then activate the theme by choosing the `Preferences -> Select Color Scheme… -> Neon` menu option. Alternatively, paste the following line in `Packages/User/Preferences.sublime-settings` (`Preferences -> Settings`, right-side pane):
120 |
121 | ```
122 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme"
123 | ```
124 |
125 | If you were using the old pre-3.0 version of **Neon**, the file name was `Neon.tmTheme`. I switched to the `.sublime-color-scheme` format both because JSON is far easier to work with than XML, and there are some [cool new features](https://www.sublimetext.com/docs/color_schemes.html) in Sublime Text 4 that don't work with `.tmTheme` files.
126 |
127 |
128 | ## TextMate Installation:
129 |
130 | Due to the switch to the `.sublime-color-scheme` format, TextMate is no longer supported.
131 |
132 | 
133 |
134 | 
135 |
136 |
137 | ## Can you make a version for Visual Studio Code?
138 |
139 | The short answer is no.
140 |
141 | This is because, in all of their Microsofty wisdom, the VSCode developers decided to use a JSON-based translation of TextMate's `.tmTheme` format, *but they decided to not support the `"background"` property*, because... I don't know, reasons. Something about it interfering with the editor's capability to highlight code on its own. See [this 2016 issue](https://github.com/microsoft/vscode/issues/3429) for an exhausting discussion of why. My 2¢ are down near the bottom. There seems to be overwhelming support for this feature, so make your voice heard!
142 |
143 | So what does this have to do with **Neon**? Well, of the over 400 named scopes I have (not counting [global settings](https://www.sublimetext.com/docs/color_schemes.html#global_settings) like `"highlight_color"`), about 100 of them have a `"background"` color. Some scopes would look okay without a background color, although they wouldn't be able to be differentiated from other scopes with just that foreground color, but some would look terrible, and others might only be barely visible on the default black background. The time it would take me to pick through all those scopes and redesign them so they still look good in the context of the language(s), all for an editor that I don't even like that much, is just too much. I'm not going to sacrifice quality just because they decided to not implement background colors. If you want to fork and do it yourself, go for it!
144 |
145 |
146 | ## Issues
147 |
148 | If you have questions, concerns, or suggested improvements, I'd love to hear from you! Feel free to [open an issue](https://github.com/MattDMo/Neon-sublime-theme/issues/new) or send a [pull request](https://github.com/MattDMo/Neon-sublime-theme/compare/) and I'll get back to you as soon as I can. You can also ping me on the Twitters [@MattDMo](https://twitter.com/MattDMo), or catch me on the [Sublime Discord server](https://discord.com/channels/280102180189634562/280102180189634562).
149 |
150 | 
151 |
152 |
153 | ## License
154 |
155 | © 2013-2022 Matt Morrison .
156 |
157 | This is free software. It is licensed under the [MIT License](http://opensource.org/licenses/MIT). Feel free to use this in your own work. However, if you modify and/or redistribute it, please attribute me in some way, and it would be great if you distribute your work under this or a similar license, but it's not required. A shout-out or a beer would be appreciated.
158 |
159 |
160 | ## Support
161 |
162 |
163 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-midnight
--------------------------------------------------------------------------------
/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "install": "messages/install.txt",
3 | "1.1.1": "messages/1.1.0.txt",
4 | "1.1.4": "messages/1.1.4.txt",
5 | "1.1.7": "messages/1.1.6.txt",
6 | "1.2.1": "messages/1.2.1.txt",
7 | "1.3.0": "messages/1.3.0.txt",
8 | "2.0.0": "messages/2.0.0.txt",
9 | "3.1.0": "messages/3.1.0.txt",
10 | "3.2.0": "messages/3.2.0.txt",
11 | "3.2.1": "messages/3.2.1.txt",
12 | "3.2.2": "messages/3.2.2.txt"
13 | }
14 |
--------------------------------------------------------------------------------
/messages/1.1.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Neon Color Scheme v1.1.1
3 | ++++++++++++++++++++++++
4 |
5 | This is a significant update from 1.0.1. I've recently started using Sass/SCSS
6 | as I work on the upcoming Neon Color Scheme website, and installed the Syntax
7 | Highlighting for Sass package (among others) for ST2. While the CSS scopes in
8 | Neon are fairly complete, I was missing some Sass ones, so those have now been
9 | added. Internally, I did a major reorganization, so related items like `keyword`
10 | and `keyword.other` are now grouped together. I also tweaked some (but not too
11 | many) of the colors - `Class` is brighter, with no background, and HTML overall
12 | looks better, I think.
13 |
14 | I try to make as many languages as possible look as good and balanced as
15 | possible, so if you want me to pay extra attention to your favorite language, or
16 | if you have any suggestions, questions, concerns, bugs, unexpected behavior, or
17 | just want to say thanks, please open an issue or a pull request on Github, or
18 | send me a tweet. If you like what you see, please consider supporting my work
19 | with a gittip or Paypal donation - see the README for details.
20 |
21 | Thanks,
22 | @MattDMo
23 |
24 | https://github.com/MattDMo/Neon-sublime-theme
25 |
--------------------------------------------------------------------------------
/messages/1.1.4.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v1.1.4
2 | ========================
3 |
4 | Major changes for this version:
5 | - rearranged some stuff for better organization
6 | - added colors for Python 3 annotations
7 | - altered GitGutter colors from Monokai to Neon
8 | - added AAAPackageDev Sublime Settings keyword
9 | - added default SublimeLinter colors from its README - please let me know if they don't work
10 |
11 | Do you have a favorite plugin that you'd like to see themed by Neon? Open an issue
12 | (https://github.com/MattDMo/Neon-color-scheme/issues/new) and let me know!
13 |
14 | MattDMo
15 |
--------------------------------------------------------------------------------
/messages/1.1.6.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v1.1.7
2 | ========================
3 |
4 | Major changes for this version:
5 | * Extended support for Clojure
6 | * Added some new scopes for JavaScriptNext
7 |
8 | Do you have a favorite plugin or language that you'd like to see themed by Neon?
9 | Open an issue (https://github.com/MattDMo/Neon-color-scheme/issues/new)
10 | and let me know!
11 |
12 | MattDMo
13 |
--------------------------------------------------------------------------------
/messages/1.3.0.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v1.3.0
2 | ========================
3 |
4 | Major changes for this version:
5 | * Added support for logcat and RAML
6 | * Properly highlight `Makefile` functions
7 | * Tweaked highlighting of links in Markdown
8 | * `comment.line.note[.notation]` now generic instead of Python-specific
9 |
10 | Do you have a favorite plugin or language that you'd like to see themed by Neon?
11 | Open an issue (https://github.com/MattDMo/Neon-color-scheme/issues/new)
12 | and let me know!
13 |
14 | MattDMo
15 |
--------------------------------------------------------------------------------
/messages/2.0.0.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v2.0.0
2 | ========================
3 |
4 | Welcome to 2.0! There have been a lot of changes and additions, hence the major
5 | version bump. Here's what I recorded in the commit:
6 |
7 | * Added "white" selector for things that I don't want colored but are for some reason
8 | * Tweaked Storage modifier
9 | * added scope selectors to
10 | * Dict key
11 | * Function definition
12 | * Function call
13 | * Function arguments
14 | * Function definition parameters
15 | * String quotes
16 | * Added constant.other
17 | * Changed background of String embedded-source
18 | * Diff. color for string embedded variable
19 | * Added Scala section
20 | * Added toc-list/Task tags section, thanks to @abusalimov from PR #26
21 | * Added Java section
22 | * JavaScript/Babel/JSX/Node:
23 | * Renamed and added scopes:
24 | * Node module
25 | * Babel - Embedded expression
26 | * Babel - Embedded expression punctuation
27 | * Changed variable.other.property
28 | * Addressed request for better JSX coverage from @rubyruy in #17
29 | * Added Fortran section
30 | * Clojure:
31 | * Removed constant.other
32 | * Added global symbol
33 | * Added Constant.string
34 | * Removed .clojure from entity.name.namespace
35 | * Added scope to String Constant Symbol
36 | * Ruby:
37 | * Added:
38 | * Class accessor notation
39 | * Ruby module
40 | * Ruby constant
41 | * Changed colors for:
42 | * Ruby symbol
43 | * Instance variable
44 | * Block variable (also added to scope selectors)
45 | * Added Python.sublime-syntax section
46 | * Generator/comprehension keys
47 | * Docstring and quotes
48 | * Renamed PythonImproved to Python/PythonImproved
49 | * Added:
50 | * Comprehension keywords
51 | * PI docstring
52 | * Removed constant - allcaps as it's now covered by constant.other
53 | * Renamed section to C/C++/C Improved
54 | * Added CI stuff:
55 | * preprocessor #include
56 | * preprocessor #define
57 | * diff
58 | * Added a bunch of stuff to highlight:
59 | * Range punctuation
60 | * Range line numbers
61 | * From punctuation
62 | * To punctuation
63 | * Header From
64 | * Header To
65 | * Added entity.name.tag to NTML/XML Tag
66 | * PHP:
67 | * Changed colors of double- and single-quoted strings
68 | * Added PHP function
69 | * Stylesheets
70 | * Added background to .class
71 | * Changed property-name
72 | * Added background to property-value
73 | * PackageDev:
74 | * Added Sublime Keymap Modifier Key
75 | * Added Sublime Keymap Key
76 | * Added entirely new YAML section
77 | * Capitalized hex colors in RAML
78 | * Changed BracketHighlighter default color
79 | * Added storage.control to Matlab
80 | * Added Rust section
81 | * Added ShellScriptImproved section (some of which works for default Shell Script (Bash))
82 | * Added R/R-Box section
83 | * Added Swift section
84 | * Made big plans to alphabetize all the sections. Later.
85 |
86 | That's about it for now. As always, keep those suggestions coming!
87 |
88 | Do you have a favorite plugin or language that you'd like to see themed by Neon?
89 | Open an issue (https://github.com/MattDMo/Neon-color-scheme/issues/new)
90 | and let me know!
91 |
92 | MattDMo
93 |
--------------------------------------------------------------------------------
/messages/3.1.0.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v3.1.0
2 | ========================
3 |
4 | Welcome to an entirely new version of the Neon Color Scheme for users of Sublime
5 | Text v3.1 (Build 3170) and above! Lots of things have changed, most importantly
6 | the format - we've migrated from the old XML-based .tmTheme format to the new
7 | JSON-based .sublime-color-scheme format, which not only is much easier to work
8 | with, but is also under active development, with new features being added for
9 | the next public release of Sublime Text.
10 |
11 | Aside from the format change, I've rearranged the entire thing to make working
12 | with specific languages easier, labeled the sections with comments that are
13 | readable in the minimap, and, of course, added and tweaked a ton of new scopes.
14 | Here are the languages, plugins, and Sublime features for which we have specific
15 | coloring rules:
16 |
17 | * Android Debug Bridge (ADB)
18 | * Babel
19 | * BracketHighlighter
20 | * C/C++
21 | * Clojure
22 | * CSS and friends (SCSS, SASS)
23 | * Diff
24 | * Dockerfile
25 | * Find in Files
26 | * Fortran
27 | * Git Gutter
28 | * Haskell
29 | * HTML/XML
30 | * Java
31 | * Javascript/JSX
32 | * JSON
33 | * LaTeX
34 | * Logcat
35 | * Markup/Markdown
36 | * Matlab
37 | * PackageDev
38 | * PHP
39 | * Python/Python Improved
40 | * R/R-Box
41 | * RAML
42 | * Regex
43 | * Ruby
44 | * Rust
45 | * Scala
46 | * Shell scripts
47 | * SQL
48 | * SublimeLinter
49 | * Swift
50 | * Table of Contents/Task Tag
51 | * Typescript
52 | * YACC/Bison
53 | * YAML
54 |
55 | See the README.md file for links to the plugins mentioned
56 |
57 | Many other languages will also look nice with Neon. If you have a particular one
58 | you'd like me to spruce up, let me know. The next version of Sublime Text is now
59 | in active development, with alpha builds available for registered users of ST3.
60 | One nice side effect of this is that many of the language syntaxes are being
61 | improved, which gives me greater opportunities for making them look nicer!
62 |
63 | The .sublime-color-scheme format change requires a change in your
64 | preferences file, from
65 |
66 | "color_scheme": "Packages/Neon Color Scheme/Neon.tmTheme"
67 |
68 | to
69 |
70 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme"
71 |
72 | Enjoy the new version, and please send me feedback, good and bad!
73 |
74 |
75 | --Matt
76 |
77 | @MattDMo
78 | https://github.com/MattDMo/Neon-color-scheme/issues
79 |
--------------------------------------------------------------------------------
/messages/3.2.0.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v3.2.0
2 | ========================
3 |
4 | NEW FEATURE:
5 | I added the following files to a new folder called "widget settings":
6 |
7 | - Console Input Widget.sublime-settings
8 | - Regex Replace Widget.sublime-settings
9 | - Regex Widget.sublime-settings
10 | - Widget.sublime-settings
11 |
12 | These are part of the "Default" package, and set preferences for different
13 | widgets in the program. Each file here has just one setting:
14 |
15 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme"
16 |
17 | so that the overall UI is more consistent. One major advantage is you now get
18 | syntax highlighting for regex search and replace, making it easier to find things
19 | like missing brackets.
20 |
21 |
22 | Changes since 3.1.0:
23 |
24 | - Internal file structure organization
25 | - Added support for Mediawiker (https://packagecontrol.io/packages/Mediawiker)
26 | - Additions and tweaks to various PackageDev syntaxes
27 | - Added support for TOML
28 | - Added CSS variables for styling popups
29 | - Several changes to the globals section to theming the UI itself
30 | - Improved highlighting for function annotations in Python
31 | - New YAML scopes
32 | - Regex tweaks
33 |
34 | Remember to change your settings from
35 |
36 | "color_scheme": "Packages/Neon Color Scheme/Neon.tmTheme"
37 |
38 | to
39 |
40 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme"
41 |
42 | Enjoy the new version, and please send me feedback, good and bad!
43 |
44 |
45 | --Matt
46 |
47 | @MattDMo
48 | https://github.com/MattDMo/Neon-color-scheme/issues
49 |
--------------------------------------------------------------------------------
/messages/3.2.1.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v3.2.1
2 | ========================
3 |
4 | It's been a little while and I've made some changes and tweaks, so I figured it's
5 | time for a new release!
6 |
7 | Changes since 3.2.0:
8 |
9 | - Specific support for new languages:
10 | - AutoHotKey
11 | - C#
12 | - Lisp
13 |
14 | - Added/modified existing scopes
15 | - generic scopes
16 | - CSS
17 | - Find in Files
18 | - HTML/XML
19 | - Markup
20 | - Python
21 |
22 | Enjoy the new version, and please send me feedback, good and bad!
23 |
24 |
25 | --Matt
26 |
27 | @MattDMo
28 | https://github.com/MattDMo/Neon-color-scheme/issues
29 |
--------------------------------------------------------------------------------
/messages/3.2.2.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme v3.2.2
2 | ========================
3 |
4 | Brightened up the string interpolation due to feedback. Also prettified Java a
5 | bit.
6 |
7 | Changes since 3.2.0:
8 |
9 | - Specific support for new languages:
10 | - AutoHotKey
11 | - C#
12 | - Lisp
13 |
14 | - Added/modified existing scopes
15 | - generic scopes
16 | - CSS
17 | - Find in Files
18 | - HTML/XML
19 | - Java
20 | - LaTeX
21 | - Markup
22 | - Python
23 |
24 | Enjoy the new version, and please send me feedback, good and bad!
25 |
26 |
27 | --Matt
28 |
29 | @MattDMo
30 | https://github.com/MattDMo/Neon-color-scheme/issues
31 |
--------------------------------------------------------------------------------
/messages/install.txt:
--------------------------------------------------------------------------------
1 | Neon Color Scheme
2 | +++++++++++++++++
3 |
4 | Thank you for installing my Neon Color Scheme! I hope you enjoy using it as much
5 | as I enjoyed creating it. It looks best when used with a dark UI theme - I use
6 | SodaReloaded Dark, but there are many other excellent ones available on Package
7 | Control.
8 |
9 | To activate, add this line to your user settings:
10 |
11 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme",
12 |
13 | Or, select `Preferences → Color Scheme…` and choose "Neon" from the list.
14 |
15 | If you have any questions, concerns, bugs, improvement suggestions, or anything
16 | else, feel free to open an issue on Github and I'll do my best to help you out.
17 | You can also find me on the Twitters, monitoring the Sublime tags on Stack
18 | Overflow, and hanging out on the Sublime Discord server.
19 |
20 | @MattDMo
21 |
22 | https://github.com/MattDMo/Neon-color-scheme
23 |
--------------------------------------------------------------------------------
/packages.json:
--------------------------------------------------------------------------------
1 | {
2 | "schema_version": "3.0.0",
3 |
4 | "packages": [
5 |
6 | {
7 | "name": "Neon Color Scheme",
8 | "details": "https://github.com/MattDMo/Neon-color-scheme",
9 | "releases": [
10 | {
11 | "sublime_text": "<3170",
12 | "tags": "tmTheme-"
13 | },
14 | {
15 | "sublime_text": ">=3170",
16 | "tags": "scs-"
17 | }
18 | ],
19 | "previous_names": ["Neon Theme"],
20 | "labels": ["color scheme"]
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/test files/LaTeX test.tex:
--------------------------------------------------------------------------------
1 | \documentclass[12pt]{article}
2 |
3 | \usepackage{amsmath} % need for subequations
4 | \usepackage{graphicx} % need for figures
5 | \usepackage{verbatim} % useful for program listings
6 | \usepackage{color} % use if color is used in text
7 | \usepackage{subfigure} % use for side-by-side figures
8 | \usepackage{hyperref} % use for hypertext links, including those to external documents and URLs
9 |
10 | % don't need the following. simply use defaults
11 | \setlength{\baselineskip}{16.0pt} % 16 pt usual spacing between lines
12 |
13 | \setlength{\parskip}{3pt plus 2pt}
14 | \setlength{\parindent}{20pt}
15 | \setlength{\oddsidemargin}{0.5cm}
16 | \setlength{\evensidemargin}{0.5cm}
17 | \setlength{\marginparsep}{0.75cm}
18 | \setlength{\marginparwidth}{2.5cm}
19 | \setlength{\marginparpush}{1.0cm}
20 | \setlength{\textwidth}{150mm}
21 |
22 | \begin{comment}
23 | \pagestyle{empty} % use if page numbers not wanted
24 | \end{comment}
25 |
26 | % above is the preamble
27 |
28 | \begin{document}
29 |
30 | \begin{center}
31 | {\large Introduction to \LaTeX} \\ % \\ = new line
32 | \copyright 2006 by Harvey Gould \\
33 | December 5, 2006
34 | \end{center}
35 |
36 | \section{Introduction}
37 | \TeX\ looks more difficult than it is. It is
38 | almost as easy as $\pi$. See how easy it is to make special
39 | symbols such as $\alpha$,
40 | $\beta$, $\gamma$,
41 | $\delta$, $\sin x$, $\hbar$, $\lambda$, $\ldots$ We also can make
42 | subscripts
43 | $A_{x}$, $A_{xy}$ and superscripts, $e^x$, $e^{x^2}$, and
44 | $e^{a^b}$. We will use \LaTeX, which is based on \TeX\ and has
45 | many higher-level commands (macros) for formatting, making
46 | tables, etc. More information can be found in Ref.~\cite{latex}.
47 |
48 | We just made a new paragraph. Extra lines and spaces make no
49 | difference. Note that all formulas are enclosed by
50 | \$ and occur in \textit{math mode}.
51 |
52 | The default font is Computer Modern. It includes \textit{italics},
53 | \textbf{boldface},
54 | \textsl{slanted}, and \texttt{monospaced} fonts.
55 |
56 | \section{Equations}
57 | Let us see how easy it is to write equations.
58 | \begin{equation}
59 | \Delta =\sum_{i=1}^N w_i (x_i - \bar{x})^2 .
60 | \end{equation}
61 | It is a good idea to number equations, but we can have a
62 | equation without a number by writing
63 | \begin{equation}
64 | P(x) = \frac{x - a}{b - a} , \nonumber
65 | \end{equation}
66 | and
67 | \begin{equation}
68 | g = \frac{1}{2} \sqrt{2\pi} . \nonumber
69 | \end{equation}
70 |
71 | We can give an equation a label so that we can refer to it later.
72 | \begin{equation}
73 | \label{eq:ising}
74 | E = -J \sum_{i=1}^N s_i s_{i+1} ,
75 | \end{equation}
76 | Equation~\eqref{eq:ising} expresses the energy of a configuration
77 | of spins in the Ising model.\footnote{It is necessary to process (typeset) a
78 | file twice to get the counters correct.}
79 |
80 | We can define our own macros to save typing. For example, suppose
81 | that we introduce the macros:
82 | \begin{verbatim}
83 | \newcommand{\lb}{{\langle}}
84 | \newcommand{\rb}{{\rangle}}
85 | \end{verbatim}
86 | \newcommand{\lb}{{\langle}}
87 | \newcommand{\rb}{{\rangle}}
88 | Then we can write the average value of $x$ as
89 | \begin{verbatim}
90 | \begin{equation}
91 | \lb x \rb = 3
92 | \end{equation}
93 | \end{verbatim}
94 | The result is
95 | \begin{equation}
96 | \lb x \rb = 3 .
97 | \end{equation}
98 |
99 | Examples of more complicated equations:
100 | \begin{equation}
101 | I = \! \int_{-\infty}^\infty f(x)\,dx \label{eq:fine}.
102 | \end{equation}
103 | We can do some fine tuning by adding small amounts of horizontal
104 | spacing:
105 | \begin{verbatim}
106 | \, small space \! negative space
107 | \end{verbatim}
108 | as is done in Eq.~\eqref{eq:fine}.
109 |
110 | We also can align several equations:
111 | \begin{align}
112 | a & = b \\
113 | c &= d ,
114 | \end{align}
115 | or number them as subequations:
116 | \begin{subequations}
117 | \begin{align}
118 | a & = b \\
119 | c &= d .
120 | \end{align}
121 | \end{subequations}
122 |
123 | We can also have different cases:
124 | \begin{equation}
125 | \label{eq:mdiv}
126 | m(T) =
127 | \begin{cases}
128 | 0 & \text{$T > T_c$} \\
129 | \bigl(1 - [\sinh 2 \beta J]^{-4} \bigr)^{\! 1/8} & \text{$T < T_c$}
130 | \end{cases}
131 | \end{equation}
132 | write matrices
133 | \begin{align}
134 | \textbf{T} &=
135 | \begin{pmatrix}
136 | T_{++} \hfill & T_{+-} \\
137 | T_{-+} & T_{--} \hfill
138 | \end{pmatrix} , \nonumber \\
139 | & =
140 | \begin{pmatrix}
141 | e^{\beta (J + B)} \hfill & e^{-\beta J} \hfill \\
142 | e^{-\beta J} \hfill & e^{\beta (J - B)} \hfill
143 | \end{pmatrix}.
144 | \end{align}
145 | and
146 | \newcommand{\rv}{\textbf{r}}
147 | \begin{equation}
148 | \sum_i \vec A \cdot \vec B = -P\!\int\! \rv \cdot
149 | \hat{\mathbf{n}}\, dA = P\!\int \! {\vec \nabla} \cdot \rv\, dV.
150 | \end{equation}
151 |
152 | \section{Tables}
153 | Tables are a little more difficult. TeX
154 | automatically calculates the width of the columns.
155 |
156 | \begin{table}[h]
157 | \begin{center}
158 | \begin{tabular}{|l|l|r|l|}
159 | \hline
160 | lattice & $d$ & $q$ & $T_{\rm mf}/T_c$ \\
161 | \hline
162 | square & 2 & 4 & 1.763 \\
163 | \hline
164 | triangular & 2 & 6 & 1.648 \\
165 | \hline
166 | diamond & 3 & 4 & 1.479 \\
167 | \hline
168 | simple cubic & 3 & 6 & 1.330 \\
169 | \hline
170 | bcc & 3 & 8 & 1.260 \\
171 | \hline
172 | fcc & 3 & 12 & 1.225 \\
173 | \hline
174 | \end{tabular}
175 | \caption{\label{tab:5/tc}Comparison of the mean-field predictions
176 | for the critical temperature of the Ising model with exact results
177 | and the best known estimates for different spatial dimensions $d$
178 | and lattice symmetries.}
179 | \end{center}
180 | \end{table}
181 |
182 | \section{Lists}
183 |
184 | Some example of formatted lists include the
185 | following:
186 |
187 | \begin{enumerate}
188 |
189 | \item bread
190 |
191 | \item cheese
192 |
193 | \end{enumerate}
194 |
195 | \begin{itemize}
196 |
197 | \item Tom
198 |
199 | \item Dick
200 |
201 | \end{itemize}
202 |
203 | \section{Figures}
204 |
205 | We can make figures bigger or smaller by scaling them. Figure~\ref{fig:lj}
206 | has been scaled by 60\%.
207 |
208 | \begin{figure}[h]
209 | \begin{center}
210 | \includegraphics{figures/sine}
211 | \caption{\label{fig:typical}Show me a sine.}
212 | \end{center}
213 | \end{figure}
214 |
215 | \begin{figure}[h]
216 | \begin{center}
217 | \scalebox{0.6}{\includegraphics{figures/lj}}
218 | \caption{\label{fig:lj}Plot of the
219 | Lennard-Jones potential
220 | $u(r)$. The potential is characterized by a length
221 | $\sigma$ and an energy
222 | $\epsilon$.}
223 | \end{center}
224 | \end{figure}
225 |
226 | \section{Literal text}
227 | It is desirable to print program code exactly as it is typed in a
228 | monospaced font. Use \verb \begin{verbatim} and
229 | \verb \end{verbatim} as in the following example:
230 | \begin{verbatim}
231 | double y0 = 10; // example of declaration and assignment statement
232 | double v0 = 0; // initial velocity
233 | double t = 0; // time
234 | double dt = 0.01; // time step
235 | double y = y0;
236 | \end{verbatim}
237 | The command \verb \verbatiminput{programs/Square.java}\ allows
238 | you to list the file \texttt{Square.java} in the directory
239 | programs.
240 |
241 | \section{Special Symbols}
242 |
243 | \subsection{Common Greek letters}
244 |
245 | These commands may be used only in math mode. Only the most common
246 | letters are included here.
247 |
248 | $\alpha,
249 | \beta, \gamma, \Gamma,
250 | \delta,\Delta,
251 | \epsilon, \zeta, \eta, \theta, \Theta, \kappa,
252 | \lambda, \Lambda, \mu, \nu,
253 | \xi, \Xi,
254 | \pi, \Pi,
255 | \rho,
256 | \sigma,
257 | \tau,
258 | \phi, \Phi,
259 | \chi,
260 | \psi, \Psi,
261 | \omega, \Omega$
262 |
263 | \subsection{Special symbols}
264 |
265 | The derivative is defined as
266 | \begin{equation}
267 | \frac{dy}{dx} = \lim_{\Delta x \to 0} \frac{\Delta y}
268 | {\Delta x}
269 | \end{equation}
270 | \begin{equation}
271 | f(x) \to y \quad \mbox{as} \quad x \to
272 | x_{0}
273 | \end{equation}
274 | \begin{equation}
275 | f(x) \mathop {\longrightarrow}
276 | \limits_{x \to x_0} y
277 | \end{equation}
278 |
279 | \noindent Order of magnitude:
280 | \begin{equation}
281 | \log_{10}f \simeq n
282 | \end{equation}
283 | \begin{equation}
284 | f(x)\sim 10^{n}
285 | \end{equation}
286 | Approximate equality:
287 | \begin{equation}
288 | f(x)\simeq g(x)
289 | \end{equation}
290 | \LaTeX\ is simple if we keep everything in proportion:
291 | \begin{equation}
292 | f(x) \propto x^3 .
293 | \end{equation}
294 |
295 | Finally we can skip some space by using commands such as
296 | \begin{verbatim}
297 | \bigskip \medskip \smallskip \vspace{1pc}
298 | \end{verbatim}
299 | The space can be negative.
300 |
301 | \section{\color{red}Use of Color}
302 |
303 | {\color{blue}{We can change colors for emphasis}},
304 | {\color{green}{but}} {\color{cyan}{who is going pay for the ink?}}
305 |
306 | \section{\label{morefig}Subfigures}
307 |
308 | As soon as many students start becoming comfortable using \LaTeX, they want
309 | to use some of its advanced features. So we now show how to place two
310 | figures side by side.
311 |
312 | \begin{figure}[h!]
313 | \begin{center}
314 | \subfigure[Real and imaginary.]{
315 | \includegraphics[scale=0.5]{figures/reim}}
316 | \subfigure[Amplitude and phase.]{
317 | \includegraphics[scale=0.5]{figures/phase}}
318 | \caption{\label{fig:qm/complexfunctions} Two representations of complex
319 | wave functions.}
320 | \end{center}
321 | \end{figure}
322 |
323 | We first have to include the necessary package,
324 | \verb+\usepackage{subfigure}+, which has to go in the preamble (before
325 | \verb+\begin{document}+). It sometimes can be difficult to place a figure in
326 | the desired place.
327 |
328 | Your LaTeX document can be easily modified to make a poster or a screen
329 | presentation similar to (and better than) PowerPoint. Conversion to HTML is
330 | straightforward. Comments on this tutorial are appreciated.
331 |
332 | \begin{thebibliography}{5}
333 |
334 | \bibitem{latex}Helmut Kopka and Patrick W. Daly, \textsl{A Guide to
335 | \LaTeX: Document Preparation for Beginners and Advanced Users},
336 | fourth edition, Addison-Wesley (2004).
337 |
338 | \bibitem{website}Some useful links are
339 | given at \url{}.
340 |
341 | \end{thebibliography}
342 |
343 | {\small \noindent Updated 5 December 2006.}
344 | \end{document}
345 |
--------------------------------------------------------------------------------
/test files/Makefile:
--------------------------------------------------------------------------------
1 | # Generated automatically from Makefile.pre by makesetup.
2 | # Top-level Makefile for Python
3 | #
4 | # As distributed, this file is called Makefile.pre.in; it is processed
5 | # into the real Makefile by running the script ./configure, which
6 | # replaces things like @spam@ with values appropriate for your system.
7 | # This means that if you edit Makefile, your changes get lost the next
8 | # time you run the configure script. Ideally, you can do:
9 | #
10 | # ./configure
11 | # make
12 | # make test
13 | # make install
14 | #
15 | # If you have a previous version of Python installed that you don't
16 | # want to overwrite, you can use "make altinstall" instead of "make
17 | # install". Refer to the "Installing" section in the README file for
18 | # additional details.
19 | #
20 | # See also the section "Build instructions" in the README file.
21 |
22 | # === Variables set by makesetup ===
23 |
24 | MODBUILT_NAMES= posix errno pwd _sre _codecs _weakref _functools _operator _collections _abc itertools atexit _signal _stat time _thread _locale _io faulthandler _tracemalloc _peg_parser _symtable xxsubtype
25 | MODDISABLED_NAMES=
26 | MODOBJS= Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/_abc.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_threadmodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/_peg_parser.o Modules/symtablemodule.o Modules/xxsubtype.o
27 | MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS)
28 |
29 | # === Variables set by configure
30 | VERSION= 3.9
31 | srcdir= .
32 |
33 | abs_srcdir= /home/mattdmo/src/Python-3.9.5
34 | abs_builddir= /home/mattdmo/src/Python-3.9.5
35 |
36 |
37 | CC= gcc -pthread
38 | CXX= g++ -pthread
39 | MAINCC= $(CC)
40 | LINKCC= $(PURIFY) $(MAINCC)
41 | AR= ar
42 | READELF= readelf
43 | SOABI= cpython-39-x86_64-linux-gnu
44 | LDVERSION= $(VERSION)$(ABIFLAGS)
45 | LIBPYTHON=
46 | GITVERSION=
47 | GITTAG=
48 | GITBRANCH=
49 | PGO_PROF_GEN_FLAG=-fprofile-generate
50 | PGO_PROF_USE_FLAG=-fprofile-use -fprofile-correction
51 | LLVM_PROF_MERGER=true
52 | LLVM_PROF_FILE=
53 | LLVM_PROF_ERR=no
54 | DTRACE=
55 | DFLAGS=
56 | DTRACE_HEADERS=
57 | DTRACE_OBJS=
58 |
59 | GNULD= yes
60 |
61 | # Shell used by make (some versions default to the login shell, which is bad)
62 | SHELL= /bin/sh
63 |
64 | # Use this to make a link between python$(VERSION) and python in $(BINDIR)
65 | LN= ln
66 |
67 | # Portable install script (configure doesn't always guess right)
68 | INSTALL= /usr/bin/install -c
69 | INSTALL_PROGRAM=${INSTALL}
70 | INSTALL_SCRIPT= ${INSTALL}
71 | INSTALL_DATA= ${INSTALL} -m 644
72 | # Shared libraries must be installed with executable mode on some systems;
73 | # rather than figuring out exactly which, we always give them executable mode.
74 | INSTALL_SHARED= ${INSTALL} -m 755
75 |
76 | MKDIR_P= /usr/bin/mkdir -p
77 |
78 | MAKESETUP= $(srcdir)/Modules/makesetup
79 |
80 | # Compiler options
81 | OPT= -DNDEBUG -g -fwrapv -O3 -Wall
82 | BASECFLAGS= -Wno-unused-result -Wsign-compare
83 | BASECPPFLAGS=
84 | CONFIGURE_CFLAGS=
85 | # CFLAGS_NODIST is used for building the interpreter and stdlib C extensions.
86 | # Use it when a compiler flag should _not_ be part of the distutils CFLAGS
87 | # once Python is installed (Issue #21121).
88 | CONFIGURE_CFLAGS_NODIST= -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden
89 | # LDFLAGS_NODIST is used in the same manner as CFLAGS_NODIST.
90 | # Use it when a linker flag should _not_ be part of the distutils LDFLAGS
91 | # once Python is installed (bpo-35257)
92 | CONFIGURE_LDFLAGS_NODIST=
93 | CONFIGURE_CPPFLAGS=
94 | CONFIGURE_LDFLAGS=
95 | # Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
96 | # command line to append to these values without stomping the pre-set
97 | # values.
98 | PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
99 | PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal
100 | # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
101 | # be able to build extension modules using the directories specified in the
102 | # environment variables
103 | PY_CPPFLAGS= $(BASECPPFLAGS) -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
104 | PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
105 | PY_LDFLAGS_NODIST=$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)
106 | NO_AS_NEEDED= -Wl,--no-as-needed
107 | SGI_ABI= @SGI_ABI@
108 | CCSHARED= -fPIC
109 | # LINKFORSHARED are the flags passed to the $(CC) command that links
110 | # the python executable -- this is only needed for a few systems
111 | LINKFORSHARED= -Xlinker -export-dynamic
112 | ARFLAGS= rcs
113 | # Extra C flags added for building the interpreter object files.
114 | CFLAGSFORSHARED=
115 | # C flags used for building the interpreter object files
116 | PY_STDMODULE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED)
117 | PY_BUILTIN_MODULE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN
118 | PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
119 | # Linker flags used for building the interpreter object files
120 | PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
121 | # Strict or non-strict aliasing flags used to compile dtoa.c, see above
122 | CFLAGS_ALIASING=
123 |
124 |
125 | # Machine-dependent subdirectories
126 | MACHDEP= linux
127 |
128 | # Multiarch directory (may be empty)
129 | MULTIARCH= x86_64-linux-gnu
130 | MULTIARCH_CPPFLAGS = -DMULTIARCH=\"x86_64-linux-gnu\"
131 |
132 | # Install prefix for architecture-independent files
133 | prefix= /usr/local
134 |
135 | # Install prefix for architecture-dependent files
136 | exec_prefix= ${prefix}
137 |
138 | # Install prefix for data files
139 | datarootdir= ${prefix}/share
140 |
141 | # Expanded directories
142 | BINDIR= ${exec_prefix}/bin
143 | LIBDIR= ${exec_prefix}/lib
144 | MANDIR= ${datarootdir}/man
145 | INCLUDEDIR= ${prefix}/include
146 | CONFINCLUDEDIR= $(exec_prefix)/include
147 | PLATLIBDIR= lib
148 | SCRIPTDIR= $(prefix)/$(PLATLIBDIR)
149 | ABIFLAGS=
150 |
151 | # Detailed destination directories
152 | BINLIBDEST= $(LIBDIR)/python$(VERSION)
153 | LIBDEST= $(SCRIPTDIR)/python$(VERSION)
154 | INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION)
155 | CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
156 |
157 | # Symbols used for using shared libraries
158 | SHLIB_SUFFIX= .so
159 | EXT_SUFFIX= .cpython-39-x86_64-linux-gnu.so
160 | LDSHARED= $(CC) -shared $(PY_LDFLAGS)
161 | BLDSHARED= $(CC) -shared $(PY_CORE_LDFLAGS)
162 | LDCXXSHARED= $(CXX) -shared
163 | DESTSHARED= $(BINLIBDEST)/lib-dynload
164 |
165 | # List of exported symbols for AIX
166 | EXPORTSYMS=
167 | EXPORTSFROM=
168 |
169 | # Executable suffix (.exe on Windows and Mac OS X)
170 | EXE=
171 | BUILDEXE=
172 |
173 | # Short name and location for Mac OS X Python framework
174 | UNIVERSALSDK=
175 | PYTHONFRAMEWORK=
176 | PYTHONFRAMEWORKDIR= no-framework
177 | PYTHONFRAMEWORKPREFIX=
178 | PYTHONFRAMEWORKINSTALLDIR=
179 | # Deployment target selected during configure, to be checked
180 | # by distutils. The export statement is needed to ensure that the
181 | # deployment target is active during build.
182 | MACOSX_DEPLOYMENT_TARGET=
183 | #export MACOSX_DEPLOYMENT_TARGET
184 |
185 | # Option to install to strip binaries
186 | STRIPFLAG=-s
187 |
188 | # Flags to lipo to produce a 32-bit-only universal executable
189 | LIPO_32BIT_FLAGS=
190 |
191 | # Flags to lipo to produce an intel-64-only universal executable
192 | LIPO_INTEL64_FLAGS=
193 |
194 | # Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
195 | OTHER_LIBTOOL_OPT=
196 |
197 | # Environment to run shared python without installed libraries
198 | RUNSHARED=
199 |
200 | # ensurepip options
201 | ENSUREPIP= upgrade
202 |
203 | # OpenSSL options for setup.py so sysconfig can pick up AC_SUBST() vars.
204 | OPENSSL_INCLUDES=-I/usr/local/include
205 | OPENSSL_LIBS=-lssl -lcrypto
206 | OPENSSL_LDFLAGS=-L/usr/local/lib
207 |
208 | # Default zoneinfo.TZPATH. Added here to expose it in sysconfig.get_config_var
209 | TZPATH=/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo
210 |
211 | # Modes for directories, executables and data files created by the
212 | # install process. Default to user-only-writable for all file types.
213 | DIRMODE= 755
214 | EXEMODE= 755
215 | FILEMODE= 644
216 |
217 | # configure script arguments
218 | CONFIG_ARGS=
219 |
220 |
221 | # Subdirectories with code
222 | SRCDIRS= Parser Parser/pegen Objects Python Modules Modules/_io Programs
223 |
224 | # Other subdirectories
225 | SUBDIRSTOO= Include Lib Misc
226 |
227 | # Files and directories to be distributed
228 | CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
229 | DISTFILES= README.rst ChangeLog $(CONFIGFILES)
230 | DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
231 | DIST= $(DISTFILES) $(DISTDIRS)
232 |
233 |
234 | LIBRARY= libpython$(VERSION)$(ABIFLAGS).a
235 | LDLIBRARY= libpython$(VERSION)$(ABIFLAGS).a
236 | BLDLIBRARY= $(LDLIBRARY)
237 | PY3LIBRARY=
238 | DLLLIBRARY=
239 | LDLIBRARYDIR=
240 | INSTSONAME= $(LDLIBRARY)
241 |
242 |
243 | LIBS= -lcrypt -lpthread -ldl -lutil -lm
244 | LIBM= -lm
245 | LIBC=
246 | SYSLIBS= $(LIBM) $(LIBC)
247 | SHLIBS= $(LIBS)
248 |
249 | DLINCLDIR= .
250 | DYNLOADFILE= dynload_shlib.o
251 | MACHDEP_OBJS=
252 | LIBOBJDIR= Python/
253 | LIBOBJS=
254 |
255 | PYTHON= python$(EXE)
256 | BUILDPYTHON= python$(BUILDEXE)
257 |
258 | PYTHON_FOR_REGEN?=python3.9
259 | UPDATE_FILE=python3.9 $(srcdir)/Tools/scripts/update_file.py
260 | PYTHON_FOR_BUILD=./$(BUILDPYTHON) -E
261 | _PYTHON_HOST_PLATFORM=
262 | BUILD_GNU_TYPE= x86_64-pc-linux-gnu
263 | HOST_GNU_TYPE= x86_64-pc-linux-gnu
264 |
265 | # Tcl and Tk config info from --with-tcltk-includes and -libs options
266 | TCLTK_INCLUDES=
267 | TCLTK_LIBS=
268 |
269 | # The task to run while instrumented when building the profile-opt target.
270 | # To speed up profile generation, we don't run the full unit test suite
271 | # by default. The default is "-m test --pgo". To run more tests, use
272 | # PROFILE_TASK="-m test --pgo-extended"
273 | PROFILE_TASK= -m test --pgo
274 |
275 | # report files for gcov / lcov coverage report
276 | COVERAGE_INFO= $(abs_builddir)/coverage.info
277 | COVERAGE_REPORT=$(abs_builddir)/lcov-report
278 | COVERAGE_REPORT_OPTIONS=--no-branch-coverage --title "CPython lcov report"
279 |
280 |
281 | # === Definitions added by makesetup ===
282 |
283 | LOCALMODLIBS=
284 | BASEMODLIBS=
285 | PYTHONPATH=$(COREPYTHONPATH)
286 | COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)
287 | TESTPATH=
288 | SITEPATH=
289 | DESTPATH=
290 | MACHDESTLIB=$(BINLIBDEST)
291 | DESTLIB=$(LIBDEST)
292 |
293 |
294 |
295 | ##########################################################################
296 | # Modules
297 | MODULE_OBJS= \
298 | Modules/config.o \
299 | Modules/getpath.o \
300 | Modules/main.o \
301 | Modules/gcmodule.o
302 |
303 | IO_H= Modules/_io/_iomodule.h
304 |
305 | IO_OBJS= \
306 | Modules/_io/_iomodule.o \
307 | Modules/_io/iobase.o \
308 | Modules/_io/fileio.o \
309 | Modules/_io/bufferedio.o \
310 | Modules/_io/textio.o \
311 | Modules/_io/bytesio.o \
312 | Modules/_io/stringio.o
313 |
314 | ##########################################################################
315 |
316 | LIBFFI_INCLUDEDIR=
317 |
318 | ##########################################################################
319 | # Parser
320 |
321 | PEGEN_OBJS= \
322 | Parser/pegen/pegen.o \
323 | Parser/pegen/parse.o \
324 | Parser/pegen/parse_string.o \
325 | Parser/pegen/peg_api.o
326 |
327 |
328 | PEGEN_HEADERS= \
329 | $(srcdir)/Include/internal/pegen_interface.h \
330 | $(srcdir)/Parser/pegen/pegen.h \
331 | $(srcdir)/Parser/pegen/parse_string.h
332 |
333 | POBJS= \
334 | Parser/acceler.o \
335 | Parser/grammar1.o \
336 | Parser/listnode.o \
337 | Parser/node.o \
338 | Parser/parser.o \
339 | Parser/token.o \
340 |
341 | PARSER_OBJS= $(POBJS) $(PEGEN_OBJS) Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o
342 |
343 | PARSER_HEADERS= \
344 | $(PEGEN_HEADERS) \
345 | $(srcdir)/Include/grammar.h \
346 | $(srcdir)/Include/parsetok.h \
347 | $(srcdir)/Parser/parser.h \
348 | $(srcdir)/Parser/tokenizer.h
349 |
350 | ##########################################################################
351 | # Python
352 |
353 | PYTHON_OBJS= \
354 | Python/_warnings.o \
355 | Python/Python-ast.o \
356 | Python/asdl.o \
357 | Python/ast.o \
358 | Python/ast_opt.o \
359 | Python/ast_unparse.o \
360 | Python/bltinmodule.o \
361 | Python/ceval.o \
362 | Python/codecs.o \
363 | Python/compile.o \
364 | Python/context.o \
365 | Python/dynamic_annotations.o \
366 | Python/errors.o \
367 | Python/frozenmain.o \
368 | Python/future.o \
369 | Python/getargs.o \
370 | Python/getcompiler.o \
371 | Python/getcopyright.o \
372 | Python/getplatform.o \
373 | Python/getversion.o \
374 | Python/graminit.o \
375 | Python/hamt.o \
376 | Python/hashtable.o \
377 | Python/import.o \
378 | Python/importdl.o \
379 | Python/initconfig.o \
380 | Python/marshal.o \
381 | Python/modsupport.o \
382 | Python/mysnprintf.o \
383 | Python/mystrtoul.o \
384 | Python/pathconfig.o \
385 | Python/peephole.o \
386 | Python/preconfig.o \
387 | Python/pyarena.o \
388 | Python/pyctype.o \
389 | Python/pyfpe.o \
390 | Python/pyhash.o \
391 | Python/pylifecycle.o \
392 | Python/pymath.o \
393 | Python/pystate.o \
394 | Python/pythonrun.o \
395 | Python/pytime.o \
396 | Python/bootstrap_hash.o \
397 | Python/structmember.o \
398 | Python/symtable.o \
399 | Python/sysmodule.o \
400 | Python/thread.o \
401 | Python/traceback.o \
402 | Python/getopt.o \
403 | Python/pystrcmp.o \
404 | Python/pystrtod.o \
405 | Python/pystrhex.o \
406 | Python/dtoa.o \
407 | Python/formatter_unicode.o \
408 | Python/fileutils.o \
409 | Python/$(DYNLOADFILE) \
410 | $(LIBOBJS) \
411 | $(MACHDEP_OBJS) \
412 | $(DTRACE_OBJS)
413 |
414 |
415 | ##########################################################################
416 | # Objects
417 | OBJECT_OBJS= \
418 | Objects/abstract.o \
419 | Objects/accu.o \
420 | Objects/boolobject.o \
421 | Objects/bytes_methods.o \
422 | Objects/bytearrayobject.o \
423 | Objects/bytesobject.o \
424 | Objects/call.o \
425 | Objects/capsule.o \
426 | Objects/cellobject.o \
427 | Objects/classobject.o \
428 | Objects/codeobject.o \
429 | Objects/complexobject.o \
430 | Objects/descrobject.o \
431 | Objects/enumobject.o \
432 | Objects/exceptions.o \
433 | Objects/genericaliasobject.o \
434 | Objects/genobject.o \
435 | Objects/fileobject.o \
436 | Objects/floatobject.o \
437 | Objects/frameobject.o \
438 | Objects/funcobject.o \
439 | Objects/interpreteridobject.o \
440 | Objects/iterobject.o \
441 | Objects/listobject.o \
442 | Objects/longobject.o \
443 | Objects/dictobject.o \
444 | Objects/odictobject.o \
445 | Objects/memoryobject.o \
446 | Objects/methodobject.o \
447 | Objects/moduleobject.o \
448 | Objects/namespaceobject.o \
449 | Objects/object.o \
450 | Objects/obmalloc.o \
451 | Objects/picklebufobject.o \
452 | Objects/rangeobject.o \
453 | Objects/setobject.o \
454 | Objects/sliceobject.o \
455 | Objects/structseq.o \
456 | Objects/tupleobject.o \
457 | Objects/typeobject.o \
458 | Objects/unicodeobject.o \
459 | Objects/unicodectype.o \
460 | Objects/weakrefobject.o
461 |
462 | ##########################################################################
463 | # objects that get linked into the Python library
464 | LIBRARY_OBJS_OMIT_FROZEN= \
465 | Modules/getbuildinfo.o \
466 | $(PARSER_OBJS) \
467 | $(OBJECT_OBJS) \
468 | $(PYTHON_OBJS) \
469 | $(MODULE_OBJS) \
470 | $(MODOBJS)
471 |
472 | LIBRARY_OBJS= \
473 | $(LIBRARY_OBJS_OMIT_FROZEN) \
474 | Python/frozen.o
475 |
476 | ##########################################################################
477 | # DTrace
478 |
479 | # On some systems, object files that reference DTrace probes need to be modified
480 | # in-place by dtrace(1).
481 | DTRACE_DEPS = \
482 | Python/ceval.o Python/import.o Python/sysmodule.o Modules/gcmodule.o
483 |
484 | #########################################################################
485 | # Rules
486 |
487 | # Default target
488 | all: build_all
489 | build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
490 | Programs/_testembed python-config
491 |
492 | # Check that the source is clean when building out of source.
493 | check-clean-src:
494 | @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \
495 | echo "Error: The source directory ($(srcdir)) is not clean" ; \
496 | echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \
497 | echo "Try to run: make -C \"$(srcdir)\" clean" ; \
498 | exit 1; \
499 | fi
500 |
501 | # Profile generation build must start from a clean tree.
502 | profile-clean-stamp:
503 | $(MAKE) clean
504 | touch $@
505 |
506 | # Compile with profile generation enabled.
507 | profile-gen-stamp: profile-clean-stamp
508 | @if [ $(LLVM_PROF_ERR) = yes ]; then \
509 | echo "Error: Cannot perform PGO build because llvm-profdata was not found in PATH" ;\
510 | echo "Please add it to PATH and run ./configure again" ;\
511 | exit 1;\
512 | fi
513 | @echo "Building with support for profile generation:"
514 | $(MAKE) build_all_generate_profile
515 | touch $@
516 |
517 | # Run task with profile generation build to create profile information.
518 | profile-run-stamp:
519 | @echo "Running code to generate profile data (this can take a while):"
520 | # First, we need to create a clean build with profile generation
521 | # enabled.
522 | $(MAKE) profile-gen-stamp
523 | # Next, run the profile task to generate the profile information.
524 | $(MAKE) run_profile_task
525 | $(MAKE) build_all_merge_profile
526 | # Remove profile generation binary since we are done with it.
527 | $(MAKE) clean-retain-profile
528 | # This is an expensive target to build and it does not have proper
529 | # makefile dependency information. So, we create a "stamp" file
530 | # to record its completion and avoid re-running it.
531 | touch $@
532 |
533 | build_all_generate_profile:
534 | $(MAKE) all CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
535 |
536 | run_profile_task:
537 | @ # FIXME: can't run for a cross build
538 | $(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
539 |
540 | build_all_merge_profile:
541 | $(LLVM_PROF_MERGER)
542 |
543 | # Compile Python binary with profile guided optimization.
544 | # To force re-running of the profile task, remove the profile-run-stamp file.
545 | profile-opt: profile-run-stamp
546 | @echo "Rebuilding with profile guided optimizations:"
547 | -rm -f profile-clean-stamp
548 | $(MAKE) all CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_USE_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST)"
549 |
550 | # Compile and run with gcov
551 | .PHONY=coverage coverage-lcov coverage-report
552 | coverage:
553 | @echo "Building with support for coverage checking:"
554 | $(MAKE) clean
555 | $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg --coverage" LIBS="$(LIBS) --coverage"
556 |
557 | coverage-lcov:
558 | @echo "Creating Coverage HTML report with LCOV:"
559 | @rm -f $(COVERAGE_INFO)
560 | @rm -rf $(COVERAGE_REPORT)
561 | @lcov --capture --directory $(abs_builddir) \
562 | --base-directory $(realpath $(abs_builddir)) \
563 | --path $(realpath $(abs_srcdir)) \
564 | --output-file $(COVERAGE_INFO)
565 | @ # remove 3rd party modules, system headers and internal files with
566 | @ # debug, test or dummy functions.
567 | @lcov --remove $(COVERAGE_INFO) \
568 | '*/Modules/_blake2/impl/*' \
569 | '*/Modules/_ctypes/libffi*/*' \
570 | '*/Modules/_decimal/libmpdec/*' \
571 | '*/Modules/_sha3/kcp/*' \
572 | '*/Modules/expat/*' \
573 | '*/Modules/zlib/*' \
574 | '*/Include/*' \
575 | '*/Modules/xx*.c' \
576 | '*/Parser/listnode.c' \
577 | '*/Python/pyfpe.c' \
578 | '*/Python/pystrcmp.c' \
579 | '/usr/include/*' \
580 | '/usr/local/include/*' \
581 | '/usr/lib/gcc/*' \
582 | --output-file $(COVERAGE_INFO)
583 | @genhtml $(COVERAGE_INFO) --output-directory $(COVERAGE_REPORT) \
584 | $(COVERAGE_REPORT_OPTIONS)
585 | @echo
586 | @echo "lcov report at $(COVERAGE_REPORT)/index.html"
587 | @echo
588 |
589 | # Force regeneration of parser and importlib
590 | coverage-report: regen-grammar regen-token regen-importlib
591 | @ # build with coverage info
592 | $(MAKE) coverage
593 | @ # run tests, ignore failures
594 | $(TESTRUNNER) $(TESTOPTS) || true
595 | @ # build lcov report
596 | $(MAKE) coverage-lcov
597 |
598 | # Run "Argument Clinic" over all source files
599 | .PHONY=clinic
600 | clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
601 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
602 |
603 | # Build the interpreter
604 | $(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
605 | $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
606 |
607 | platform: $(BUILDPYTHON) pybuilddir.txt
608 | $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform
609 |
610 | # Create build directory and generate the sysconfig build-time data there.
611 | # pybuilddir.txt contains the name of the build dir and is used for
612 | # sys.path fixup -- see Modules/getpath.c.
613 | # Since this step runs before shared modules are built, try to avoid bootstrap
614 | # problems by creating a dummy pybuilddir.txt just to allow interpreter
615 | # initialization to succeed. It will be overwritten by generate-posix-vars
616 | # or removed in case of failure.
617 | pybuilddir.txt: $(BUILDPYTHON)
618 | @echo "none" > ./pybuilddir.txt
619 | $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
620 | if test $$? -ne 0 ; then \
621 | echo "generate-posix-vars failed" ; \
622 | rm -f ./pybuilddir.txt ; \
623 | exit 1 ; \
624 | fi
625 |
626 | # This is shared by the math and cmath modules
627 | Modules/_math.o: Modules/_math.c Modules/_math.h
628 | $(CC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $<
629 |
630 | # blake2s is auto-generated from blake2b
631 | $(srcdir)/Modules/_blake2/blake2s_impl.c: $(srcdir)/Modules/_blake2/blake2b_impl.c $(srcdir)/Modules/_blake2/blake2b2s.py
632 | $(PYTHON_FOR_REGEN) $(srcdir)/Modules/_blake2/blake2b2s.py
633 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $@
634 |
635 | # Build the shared modules
636 | # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
637 | # -s, --silent or --quiet is always the first char.
638 | # Under BSD make, MAKEFLAGS might be " -s -v x=y".
639 | # Ignore macros passed by GNU make, passed after --
640 | sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
641 | @case "`echo X $$MAKEFLAGS | sed 's/^X //;s/ -- .*//'`" in \
642 | *\ -s*|s*) quiet="-q";; \
643 | *) quiet="";; \
644 | esac; \
645 | echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
646 | _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
647 | $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \
648 | $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
649 | _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
650 | $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
651 |
652 |
653 | # Build static library
654 | $(LIBRARY): $(LIBRARY_OBJS)
655 | -rm -f $@
656 | $(AR) $(ARFLAGS) $@ $(LIBRARY_OBJS)
657 |
658 | libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
659 | if test $(INSTSONAME) != $(LDLIBRARY); then \
660 | $(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
661 | $(LN) -f $(INSTSONAME) $@; \
662 | else \
663 | $(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
664 | fi
665 |
666 | libpython3.so: libpython$(LDVERSION).so
667 | $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
668 |
669 | libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
670 | $(CC) -dynamiclib -Wl,-single_module $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
671 |
672 |
673 | libpython$(VERSION).sl: $(LIBRARY_OBJS)
674 | $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM)
675 |
676 | # List of exported symbols for AIX
677 | Modules/python.exp: $(LIBRARY)
678 | $(srcdir)/Modules/makexp_aix $@ "$(EXPORTSFROM)" $?
679 |
680 | # Copy up the gdb python hooks into a position where they can be automatically
681 | # loaded by gdb during Lib/test/test_gdb.py
682 | #
683 | # Distributors are likely to want to install this somewhere else e.g. relative
684 | # to the stripped DWARF data for the shared library.
685 | gdbhooks: $(BUILDPYTHON)-gdb.py
686 |
687 | SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
688 | $(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
689 | $(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
690 |
691 | # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
692 | # minimal framework (not including the Lib directory and such) in the current
693 | # directory.
694 | RESSRCDIR=Mac/Resources/framework
695 | $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
696 | $(LIBRARY) \
697 | $(RESSRCDIR)/Info.plist
698 | $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
699 | $(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \
700 | -all_load $(LIBRARY) -Wl,-single_module \
701 | -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
702 | -compatibility_version $(VERSION) \
703 | -current_version $(VERSION) \
704 | -framework CoreFoundation $(LIBS);
705 | $(INSTALL) -d -m $(DIRMODE) \
706 | $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
707 | $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
708 | $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
709 | $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
710 | $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
711 | $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
712 |
713 | # This rule builds the Cygwin Python DLL and import library if configured
714 | # for a shared core library; otherwise, this rule is a noop.
715 | $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
716 | if test -n "$(DLLLIBRARY)"; then \
717 | $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
718 | $(LIBS) $(MODLIBS) $(SYSLIBS); \
719 | else true; \
720 | fi
721 |
722 |
723 | oldsharedmods: $(SHAREDMODS)
724 |
725 |
726 | Makefile Modules/config.c: Makefile.pre \
727 | $(srcdir)/Modules/config.c.in \
728 | $(MAKESETUP) \
729 | $(srcdir)/Modules/Setup \
730 | Modules/Setup.local
731 | $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
732 | -s Modules \
733 | Modules/Setup.local \
734 | $(srcdir)/Modules/Setup
735 | @mv config.c Modules
736 | @echo "The Makefile was updated, you may need to re-run make."
737 |
738 |
739 | Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
740 | $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
741 |
742 | ############################################################################
743 | # Importlib
744 |
745 | Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
746 |
747 | Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
748 | $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS)
749 |
750 | .PHONY: regen-importlib
751 | regen-importlib: Programs/_freeze_importlib
752 | # Regenerate Python/importlib_external.h
753 | # from Lib/importlib/_bootstrap_external.py using _freeze_importlib
754 | ./Programs/_freeze_importlib importlib._bootstrap_external \
755 | $(srcdir)/Lib/importlib/_bootstrap_external.py \
756 | $(srcdir)/Python/importlib_external.h.new
757 | $(UPDATE_FILE) $(srcdir)/Python/importlib_external.h $(srcdir)/Python/importlib_external.h.new
758 | # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
759 | # using _freeze_importlib
760 | ./Programs/_freeze_importlib importlib._bootstrap \
761 | $(srcdir)/Lib/importlib/_bootstrap.py \
762 | $(srcdir)/Python/importlib.h.new
763 | $(UPDATE_FILE) $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib.h.new
764 | # Regenerate Python/importlib_zipimport.h from Lib/zipimport.py
765 | # using _freeze_importlib
766 | ./Programs/_freeze_importlib zipimport \
767 | $(srcdir)/Lib/zipimport.py \
768 | $(srcdir)/Python/importlib_zipimport.h.new
769 | $(UPDATE_FILE) $(srcdir)/Python/importlib_zipimport.h $(srcdir)/Python/importlib_zipimport.h.new
770 |
771 | regen-abidump: all
772 | @$(MKDIR_P) $(srcdir)/Doc/data/
773 | abidw "libpython$(LDVERSION).so" --no-architecture --out-file $(srcdir)/Doc/data/python$(LDVERSION).abi.new
774 | @$(UPDATE_FILE) $(srcdir)/Doc/data/python$(LDVERSION).abi $(srcdir)/Doc/data/python$(LDVERSION).abi.new
775 |
776 | check-abidump: all
777 | abidiff "libpython$(LDVERSION).so" $(srcdir)/Doc/data/python$(LDVERSION).abi --drop-private-types --no-architecture --no-added-syms
778 |
779 | ############################################################################
780 | # Regenerate all generated files
781 |
782 | regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar \
783 | regen-token regen-keyword regen-symbol regen-ast regen-importlib clinic \
784 | regen-pegen-metaparser regen-pegen
785 |
786 | ############################################################################
787 | # Special rules for object files
788 |
789 | Modules/getbuildinfo.o: $(PARSER_OBJS) \
790 | $(OBJECT_OBJS) \
791 | $(PYTHON_OBJS) \
792 | $(MODULE_OBJS) \
793 | $(MODOBJS) \
794 | $(DTRACE_OBJS) \
795 | $(srcdir)/Modules/getbuildinfo.c
796 | $(CC) -c $(PY_CORE_CFLAGS) \
797 | -DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
798 | -DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
799 | -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
800 | -o $@ $(srcdir)/Modules/getbuildinfo.c
801 |
802 | Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
803 | $(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
804 | -DPREFIX='"$(prefix)"' \
805 | -DEXEC_PREFIX='"$(exec_prefix)"' \
806 | -DVERSION='"$(VERSION)"' \
807 | -DVPATH='"$(VPATH)"' \
808 | -o $@ $(srcdir)/Modules/getpath.c
809 |
810 | Programs/python.o: $(srcdir)/Programs/python.c
811 | $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/python.c
812 |
813 | Programs/_testembed.o: $(srcdir)/Programs/_testembed.c
814 | $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Programs/_testembed.c
815 |
816 | Modules/_sre.o: $(srcdir)/Modules/_sre.c $(srcdir)/Modules/sre.h $(srcdir)/Modules/sre_constants.h $(srcdir)/Modules/sre_lib.h
817 |
818 | Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
819 |
820 | Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
821 |
822 | Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
823 |
824 | Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c $(srcdir)/Modules/posixmodule.h
825 |
826 | Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
827 | $(CC) -c $(PY_CORE_CFLAGS) \
828 | -DSOABI='"$(SOABI)"' \
829 | -o $@ $(srcdir)/Python/dynload_shlib.c
830 |
831 | Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile
832 | $(CC) -c $(PY_CORE_CFLAGS) \
833 | -DSHLIB_EXT='"$(EXT_SUFFIX)"' \
834 | -o $@ $(srcdir)/Python/dynload_hpux.c
835 |
836 | Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h
837 | $(CC) -c $(PY_CORE_CFLAGS) \
838 | -DABIFLAGS='"$(ABIFLAGS)"' \
839 | $(MULTIARCH_CPPFLAGS) \
840 | -o $@ $(srcdir)/Python/sysmodule.c
841 |
842 | Python/initconfig.o: $(srcdir)/Python/initconfig.c
843 | $(CC) -c $(PY_CORE_CFLAGS) \
844 | -DPLATLIBDIR='"$(PLATLIBDIR)"' \
845 | -o $@ $(srcdir)/Python/initconfig.c
846 |
847 | $(IO_OBJS): $(IO_H)
848 |
849 | .PHONY: regen-grammar
850 | regen-grammar: regen-token
851 | # Regenerate Include/graminit.h and Python/graminit.c
852 | # from Grammar/Grammar using pgen
853 | @$(MKDIR_P) Include
854 | PYTHONPATH=$(srcdir) $(PYTHON_FOR_REGEN) -m Parser.pgen $(srcdir)/Grammar/Grammar \
855 | $(srcdir)/Grammar/Tokens \
856 | $(srcdir)/Include/graminit.h.new \
857 | $(srcdir)/Python/graminit.c.new
858 | $(UPDATE_FILE) $(srcdir)/Include/graminit.h $(srcdir)/Include/graminit.h.new
859 | $(UPDATE_FILE) $(srcdir)/Python/graminit.c $(srcdir)/Python/graminit.c.new
860 |
861 | .PHONY: regen-pegen-metaparser
862 | regen-pegen-metaparser:
863 | @$(MKDIR_P) $(srcdir)/Tools/peg_generator/pegen
864 | PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q python \
865 | $(srcdir)/Tools/peg_generator/pegen/metagrammar.gram \
866 | -o $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
867 | $(UPDATE_FILE) $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py \
868 | $(srcdir)/Tools/peg_generator/pegen/grammar_parser.py.new
869 |
870 | .PHONY: regen-pegen
871 | regen-pegen:
872 | @$(MKDIR_P) $(srcdir)/Parser/pegen
873 | PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q c \
874 | $(srcdir)/Grammar/python.gram \
875 | $(srcdir)/Grammar/Tokens \
876 | -o $(srcdir)/Parser/pegen/parse.new.c
877 | $(UPDATE_FILE) $(srcdir)/Parser/pegen/parse.c $(srcdir)/Parser/pegen/parse.new.c
878 |
879 | .PHONY=regen-ast
880 | regen-ast:
881 | # Regenerate Include/Python-ast.h and Python/Python-ast.c using Parser/asdl_c.py
882 | $(MKDIR_P) $(srcdir)/Include
883 | $(MKDIR_P) $(srcdir)/Python
884 | $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
885 | $(srcdir)/Parser/Python.asdl \
886 | -H $(srcdir)/Include/Python-ast.h.new \
887 | -C $(srcdir)/Python/Python-ast.c.new
888 |
889 | $(UPDATE_FILE) $(srcdir)/Include/Python-ast.h $(srcdir)/Include/Python-ast.h.new
890 | $(UPDATE_FILE) $(srcdir)/Python/Python-ast.c $(srcdir)/Python/Python-ast.c.new
891 |
892 | .PHONY: regen-opcode
893 | regen-opcode:
894 | # Regenerate Include/opcode.h from Lib/opcode.py
895 | # using Tools/scripts/generate_opcode_h.py
896 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
897 | $(srcdir)/Lib/opcode.py \
898 | $(srcdir)/Include/opcode.h.new
899 | $(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new
900 |
901 | .PHONY: regen-token
902 | regen-token:
903 | # Regenerate Doc/library/token-list.inc from Grammar/Tokens
904 | # using Tools/scripts/generate_token.py
905 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \
906 | $(srcdir)/Grammar/Tokens \
907 | $(srcdir)/Doc/library/token-list.inc
908 | # Regenerate Include/token.h from Grammar/Tokens
909 | # using Tools/scripts/generate_token.py
910 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \
911 | $(srcdir)/Grammar/Tokens \
912 | $(srcdir)/Include/token.h
913 | # Regenerate Parser/token.c from Grammar/Tokens
914 | # using Tools/scripts/generate_token.py
915 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \
916 | $(srcdir)/Grammar/Tokens \
917 | $(srcdir)/Parser/token.c
918 | # Regenerate Lib/token.py from Grammar/Tokens
919 | # using Tools/scripts/generate_token.py
920 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py py \
921 | $(srcdir)/Grammar/Tokens \
922 | $(srcdir)/Lib/token.py
923 |
924 | .PHONY: regen-keyword
925 | regen-keyword:
926 | # Regenerate Lib/keyword.py from Grammar/python.gram and Grammar/Tokens
927 | # using Tools/peg_generator/pegen
928 | PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen.keywordgen \
929 | $(srcdir)/Grammar/python.gram \
930 | $(srcdir)/Grammar/Tokens \
931 | $(srcdir)/Lib/keyword.py.new
932 | $(UPDATE_FILE) $(srcdir)/Lib/keyword.py $(srcdir)/Lib/keyword.py.new
933 |
934 | .PHONY: regen-symbol
935 | regen-symbol: $(srcdir)/Include/graminit.h
936 | # Regenerate Lib/symbol.py from Include/graminit.h
937 | # using Tools/scripts/generate_symbol_py.py
938 | $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_symbol_py.py \
939 | $(srcdir)/Include/graminit.h \
940 | $(srcdir)/Lib/symbol.py
941 |
942 | Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o Parser/parsetok.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
943 |
944 | Python/getplatform.o: $(srcdir)/Python/getplatform.c
945 | $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
946 |
947 | Python/importdl.o: $(srcdir)/Python/importdl.c
948 | $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
949 |
950 | Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
951 | $(srcdir)/Objects/unicodetype_db.h
952 |
953 | BYTESTR_DEPS = \
954 | $(srcdir)/Objects/stringlib/count.h \
955 | $(srcdir)/Objects/stringlib/ctype.h \
956 | $(srcdir)/Objects/stringlib/fastsearch.h \
957 | $(srcdir)/Objects/stringlib/find.h \
958 | $(srcdir)/Objects/stringlib/join.h \
959 | $(srcdir)/Objects/stringlib/partition.h \
960 | $(srcdir)/Objects/stringlib/split.h \
961 | $(srcdir)/Objects/stringlib/stringdefs.h \
962 | $(srcdir)/Objects/stringlib/transmogrify.h
963 |
964 | UNICODE_DEPS = \
965 | $(srcdir)/Objects/stringlib/asciilib.h \
966 | $(srcdir)/Objects/stringlib/codecs.h \
967 | $(srcdir)/Objects/stringlib/count.h \
968 | $(srcdir)/Objects/stringlib/fastsearch.h \
969 | $(srcdir)/Objects/stringlib/find.h \
970 | $(srcdir)/Objects/stringlib/find_max_char.h \
971 | $(srcdir)/Objects/stringlib/localeutil.h \
972 | $(srcdir)/Objects/stringlib/partition.h \
973 | $(srcdir)/Objects/stringlib/replace.h \
974 | $(srcdir)/Objects/stringlib/split.h \
975 | $(srcdir)/Objects/stringlib/ucs1lib.h \
976 | $(srcdir)/Objects/stringlib/ucs2lib.h \
977 | $(srcdir)/Objects/stringlib/ucs4lib.h \
978 | $(srcdir)/Objects/stringlib/undef.h \
979 | $(srcdir)/Objects/stringlib/unicode_format.h \
980 | $(srcdir)/Objects/stringlib/unicodedefs.h
981 |
982 | Objects/bytes_methods.o: $(srcdir)/Objects/bytes_methods.c $(BYTESTR_DEPS)
983 | Objects/bytesobject.o: $(srcdir)/Objects/bytesobject.c $(BYTESTR_DEPS)
984 | Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c $(BYTESTR_DEPS)
985 |
986 | Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
987 |
988 | Objects/odictobject.o: $(srcdir)/Objects/dict-common.h
989 | Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h $(srcdir)/Objects/dict-common.h
990 | Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
991 |
992 | .PHONY: regen-opcode-targets
993 | regen-opcode-targets:
994 | # Regenerate Python/opcode_targets.h from Lib/opcode.py
995 | # using Python/makeopcodetargets.py
996 | $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
997 | $(srcdir)/Python/opcode_targets.h.new
998 | $(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
999 |
1000 | Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \
1001 | $(srcdir)/Python/condvar.h
1002 |
1003 | Python/frozen.o: $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib_external.h \
1004 | $(srcdir)/Python/importlib_zipimport.h
1005 |
1006 | # Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
1007 | # follow our naming conventions. dtrace(1) uses the output filename to generate
1008 | # an include guard, so we can't use a pipeline to transform its output.
1009 | Include/pydtrace_probes.h: $(srcdir)/Include/pydtrace.d
1010 | $(MKDIR_P) Include
1011 | $(DTRACE) $(DFLAGS) -o $@ -h -s $<
1012 | : sed in-place edit with POSIX-only tools
1013 | sed 's/PYTHON_/PyDTrace_/' $@ > $@.tmp
1014 | mv $@.tmp $@
1015 |
1016 | Python/ceval.o: $(srcdir)/Include/pydtrace.h
1017 | Python/import.o: $(srcdir)/Include/pydtrace.h
1018 | Modules/gcmodule.o: $(srcdir)/Include/pydtrace.h
1019 |
1020 | Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
1021 | $(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
1022 |
1023 | Objects/typeobject.o: Objects/typeslots.inc
1024 |
1025 | .PHONY: regen-typeslots
1026 | regen-typeslots:
1027 | # Regenerate Objects/typeslots.inc from Include/typeslotsh
1028 | # using Objects/typeslots.py
1029 | $(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
1030 | < $(srcdir)/Include/typeslots.h \
1031 | $(srcdir)/Objects/typeslots.inc.new
1032 | $(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new
1033 |
1034 | ############################################################################
1035 | # Header files
1036 |
1037 | PYTHON_HEADERS= \
1038 | $(srcdir)/Include/Python.h \
1039 | $(srcdir)/Include/abstract.h \
1040 | $(srcdir)/Include/asdl.h \
1041 | $(srcdir)/Include/ast.h \
1042 | $(srcdir)/Include/bitset.h \
1043 | $(srcdir)/Include/bltinmodule.h \
1044 | $(srcdir)/Include/boolobject.h \
1045 | $(srcdir)/Include/bytearrayobject.h \
1046 | $(srcdir)/Include/bytesobject.h \
1047 | $(srcdir)/Include/cellobject.h \
1048 | $(srcdir)/Include/ceval.h \
1049 | $(srcdir)/Include/classobject.h \
1050 | $(srcdir)/Include/code.h \
1051 | $(srcdir)/Include/codecs.h \
1052 | $(srcdir)/Include/compile.h \
1053 | $(srcdir)/Include/complexobject.h \
1054 | $(srcdir)/Include/context.h \
1055 | $(srcdir)/Include/descrobject.h \
1056 | $(srcdir)/Include/dictobject.h \
1057 | $(srcdir)/Include/dynamic_annotations.h \
1058 | $(srcdir)/Include/enumobject.h \
1059 | $(srcdir)/Include/errcode.h \
1060 | $(srcdir)/Include/eval.h \
1061 | $(srcdir)/Include/fileobject.h \
1062 | $(srcdir)/Include/fileutils.h \
1063 | $(srcdir)/Include/floatobject.h \
1064 | $(srcdir)/Include/frameobject.h \
1065 | $(srcdir)/Include/funcobject.h \
1066 | $(srcdir)/Include/genobject.h \
1067 | $(srcdir)/Include/import.h \
1068 | $(srcdir)/Include/interpreteridobject.h \
1069 | $(srcdir)/Include/intrcheck.h \
1070 | $(srcdir)/Include/iterobject.h \
1071 | $(srcdir)/Include/listobject.h \
1072 | $(srcdir)/Include/longintrepr.h \
1073 | $(srcdir)/Include/longobject.h \
1074 | $(srcdir)/Include/marshal.h \
1075 | $(srcdir)/Include/memoryobject.h \
1076 | $(srcdir)/Include/methodobject.h \
1077 | $(srcdir)/Include/modsupport.h \
1078 | $(srcdir)/Include/moduleobject.h \
1079 | $(srcdir)/Include/namespaceobject.h \
1080 | $(srcdir)/Include/node.h \
1081 | $(srcdir)/Include/object.h \
1082 | $(srcdir)/Include/objimpl.h \
1083 | $(srcdir)/Include/odictobject.h \
1084 | $(srcdir)/Include/opcode.h \
1085 | $(srcdir)/Include/osdefs.h \
1086 | $(srcdir)/Include/osmodule.h \
1087 | $(srcdir)/Include/patchlevel.h \
1088 | $(srcdir)/Include/picklebufobject.h \
1089 | $(srcdir)/Include/pyarena.h \
1090 | $(srcdir)/Include/pycapsule.h \
1091 | $(srcdir)/Include/pyctype.h \
1092 | $(srcdir)/Include/pydebug.h \
1093 | $(srcdir)/Include/pydtrace.h \
1094 | $(srcdir)/Include/pyerrors.h \
1095 | $(srcdir)/Include/pyfpe.h \
1096 | $(srcdir)/Include/pyframe.h \
1097 | $(srcdir)/Include/pyhash.h \
1098 | $(srcdir)/Include/pylifecycle.h \
1099 | $(srcdir)/Include/pymacconfig.h \
1100 | $(srcdir)/Include/pymacro.h \
1101 | $(srcdir)/Include/pymath.h \
1102 | $(srcdir)/Include/pymem.h \
1103 | $(srcdir)/Include/pyport.h \
1104 | $(srcdir)/Include/pystate.h \
1105 | $(srcdir)/Include/pystrcmp.h \
1106 | $(srcdir)/Include/pystrhex.h \
1107 | $(srcdir)/Include/pystrtod.h \
1108 | $(srcdir)/Include/pythonrun.h \
1109 | $(srcdir)/Include/pythread.h \
1110 | $(srcdir)/Include/pytime.h \
1111 | $(srcdir)/Include/rangeobject.h \
1112 | $(srcdir)/Include/setobject.h \
1113 | $(srcdir)/Include/sliceobject.h \
1114 | $(srcdir)/Include/structmember.h \
1115 | $(srcdir)/Include/structseq.h \
1116 | $(srcdir)/Include/symtable.h \
1117 | $(srcdir)/Include/sysmodule.h \
1118 | $(srcdir)/Include/token.h \
1119 | $(srcdir)/Include/traceback.h \
1120 | $(srcdir)/Include/tracemalloc.h \
1121 | $(srcdir)/Include/tupleobject.h \
1122 | $(srcdir)/Include/ucnhash.h \
1123 | $(srcdir)/Include/unicodeobject.h \
1124 | $(srcdir)/Include/warnings.h \
1125 | $(srcdir)/Include/weakrefobject.h \
1126 | \
1127 | pyconfig.h \
1128 | $(PARSER_HEADERS) \
1129 | $(srcdir)/Include/Python-ast.h \
1130 | \
1131 | $(srcdir)/Include/cpython/abstract.h \
1132 | $(srcdir)/Include/cpython/bytearrayobject.h \
1133 | $(srcdir)/Include/cpython/bytesobject.h \
1134 | $(srcdir)/Include/cpython/ceval.h \
1135 | $(srcdir)/Include/cpython/code.h \
1136 | $(srcdir)/Include/cpython/dictobject.h \
1137 | $(srcdir)/Include/cpython/fileobject.h \
1138 | $(srcdir)/Include/cpython/fileutils.h \
1139 | $(srcdir)/Include/cpython/frameobject.h \
1140 | $(srcdir)/Include/cpython/import.h \
1141 | $(srcdir)/Include/cpython/initconfig.h \
1142 | $(srcdir)/Include/cpython/interpreteridobject.h \
1143 | $(srcdir)/Include/cpython/listobject.h \
1144 | $(srcdir)/Include/cpython/methodobject.h \
1145 | $(srcdir)/Include/cpython/object.h \
1146 | $(srcdir)/Include/cpython/objimpl.h \
1147 | $(srcdir)/Include/cpython/pyerrors.h \
1148 | $(srcdir)/Include/cpython/pylifecycle.h \
1149 | $(srcdir)/Include/cpython/pymem.h \
1150 | $(srcdir)/Include/cpython/pystate.h \
1151 | $(srcdir)/Include/cpython/sysmodule.h \
1152 | $(srcdir)/Include/cpython/traceback.h \
1153 | $(srcdir)/Include/cpython/tupleobject.h \
1154 | $(srcdir)/Include/cpython/unicodeobject.h \
1155 | \
1156 | $(srcdir)/Include/internal/pycore_abstract.h \
1157 | $(srcdir)/Include/internal/pycore_accu.h \
1158 | $(srcdir)/Include/internal/pycore_atomic.h \
1159 | $(srcdir)/Include/internal/pycore_byteswap.h \
1160 | $(srcdir)/Include/internal/pycore_bytes_methods.h \
1161 | $(srcdir)/Include/internal/pycore_call.h \
1162 | $(srcdir)/Include/internal/pycore_ceval.h \
1163 | $(srcdir)/Include/internal/pycore_code.h \
1164 | $(srcdir)/Include/internal/pycore_condvar.h \
1165 | $(srcdir)/Include/internal/pycore_context.h \
1166 | $(srcdir)/Include/internal/pycore_dtoa.h \
1167 | $(srcdir)/Include/internal/pycore_fileutils.h \
1168 | $(srcdir)/Include/internal/pycore_getopt.h \
1169 | $(srcdir)/Include/internal/pycore_gil.h \
1170 | $(srcdir)/Include/internal/pycore_hamt.h \
1171 | $(srcdir)/Include/internal/pycore_hashtable.h \
1172 | $(srcdir)/Include/internal/pycore_import.h \
1173 | $(srcdir)/Include/internal/pycore_initconfig.h \
1174 | $(srcdir)/Include/internal/pycore_interp.h \
1175 | $(srcdir)/Include/internal/pycore_object.h \
1176 | $(srcdir)/Include/internal/pycore_pathconfig.h \
1177 | $(srcdir)/Include/internal/pycore_pyerrors.h \
1178 | $(srcdir)/Include/internal/pycore_pyhash.h \
1179 | $(srcdir)/Include/internal/pycore_pylifecycle.h \
1180 | $(srcdir)/Include/internal/pycore_pymem.h \
1181 | $(srcdir)/Include/internal/pycore_pystate.h \
1182 | $(srcdir)/Include/internal/pycore_runtime.h \
1183 | $(srcdir)/Include/internal/pycore_sysmodule.h \
1184 | $(srcdir)/Include/internal/pycore_traceback.h \
1185 | $(srcdir)/Include/internal/pycore_tupleobject.h \
1186 | $(srcdir)/Include/internal/pycore_warnings.h \
1187 | $(DTRACE_HEADERS)
1188 |
1189 | $(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
1190 |
1191 |
1192 | ######################################################################
1193 |
1194 | TESTOPTS= $(EXTRATESTOPTS)
1195 | TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
1196 | TESTRUNNER= $(TESTPYTHON) $(srcdir)/Tools/scripts/run_tests.py
1197 | TESTTIMEOUT= 1200
1198 |
1199 | .PHONY: test testall testuniversal buildbottest pythoninfo
1200 |
1201 | # Remove "test_python_*" directories of previous failed test jobs.
1202 | # Pass TESTOPTS options because it can contain --tempdir option.
1203 | cleantest: build_all
1204 | $(TESTRUNNER) $(TESTOPTS) --cleanup
1205 |
1206 | # Run a basic set of regression tests.
1207 | # This excludes some tests that are particularly resource-intensive.
1208 | test: all platform
1209 | $(TESTRUNNER) $(TESTOPTS)
1210 |
1211 | # Run the full test suite twice - once without .pyc files, and once with.
1212 | # In the past, we've had problems where bugs in the marshalling or
1213 | # elsewhere caused bytecode read from .pyc files to behave differently
1214 | # than bytecode generated directly from a .py source file. Sometimes
1215 | # the bytecode read from a .pyc file had the bug, sometimes the directly
1216 | # generated bytecode. This is sometimes a very shy bug needing a lot of
1217 | # sample data.
1218 | testall: all platform
1219 | -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
1220 | $(TESTPYTHON) -E $(srcdir)/Lib/compileall.py
1221 | -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
1222 | -$(TESTRUNNER) -u all $(TESTOPTS)
1223 | $(TESTRUNNER) -u all $(TESTOPTS)
1224 |
1225 | # Run the test suite for both architectures in a Universal build on OSX.
1226 | # Must be run on an Intel box.
1227 | testuniversal: all platform
1228 | @if [ `arch` != 'i386' ]; then \
1229 | echo "This can only be used on OSX/i386" ;\
1230 | exit 1 ;\
1231 | fi
1232 | $(TESTRUNNER) -u all $(TESTOPTS)
1233 | $(RUNSHARED) /usr/libexec/oah/translate \
1234 | ./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
1235 |
1236 | # Like testall, but with only one pass and without multiple processes.
1237 | # Run an optional script to include information about the build environment.
1238 | buildbottest: build_all platform
1239 | -@if which pybuildbot.identify >/dev/null 2>&1; then \
1240 | pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
1241 | fi
1242 | $(TESTRUNNER) -j 1 -u all -W --slowest --fail-env-changed --timeout=$(TESTTIMEOUT) $(TESTOPTS)
1243 |
1244 | pythoninfo: build_all
1245 | $(RUNSHARED) ./$(BUILDPYTHON) -m test.pythoninfo
1246 |
1247 | QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
1248 | test_multibytecodec test_urllib2_localnet test_itertools \
1249 | test_multiprocessing_fork test_multiprocessing_spawn \
1250 | test_multiprocessing_forkserver \
1251 | test_mailbox test_socket test_poll \
1252 | test_select test_zipfile test_concurrent_futures
1253 | quicktest: all platform
1254 | $(TESTRUNNER) $(QUICKTESTOPTS)
1255 |
1256 | # SSL tests
1257 | .PHONY: multisslcompile multissltest
1258 | multisslcompile: build_all
1259 | $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py --steps=modules
1260 |
1261 | multissltest: build_all
1262 | $(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py
1263 |
1264 | install: commoninstall bininstall maninstall
1265 | if test "x$(ENSUREPIP)" != "xno" ; then \
1266 | case $(ENSUREPIP) in \
1267 | upgrade) ensurepip="--upgrade" ;; \
1268 | install|*) ensurepip="" ;; \
1269 | esac; \
1270 | $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
1271 | $$ensurepip --root=$(DESTDIR)/ ; \
1272 | fi
1273 |
1274 | altinstall: commoninstall
1275 | if test "x$(ENSUREPIP)" != "xno" ; then \
1276 | case $(ENSUREPIP) in \
1277 | upgrade) ensurepip="--altinstall --upgrade" ;; \
1278 | install|*) ensurepip="--altinstall" ;; \
1279 | esac; \
1280 | $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
1281 | $$ensurepip --root=$(DESTDIR)/ ; \
1282 | fi
1283 |
1284 | commoninstall: check-clean-src \
1285 | altbininstall libinstall inclinstall libainstall \
1286 | sharedinstall oldsharedinstall altmaninstall \
1287 |
1288 |
1289 | # Install shared libraries enabled by Setup
1290 | DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
1291 |
1292 | oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
1293 | @for i in X $(SHAREDMODS); do \
1294 | if test $$i != X; then \
1295 | echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
1296 | $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
1297 | fi; \
1298 | done
1299 |
1300 | $(DESTSHARED):
1301 | @for i in $(DESTDIRS); \
1302 | do \
1303 | if test ! -d $(DESTDIR)$$i; then \
1304 | echo "Creating directory $$i"; \
1305 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1306 | else true; \
1307 | fi; \
1308 | done
1309 |
1310 | # Install the interpreter with $(VERSION) affixed
1311 | # This goes into $(exec_prefix)
1312 | altbininstall: $(BUILDPYTHON)
1313 | @for i in $(BINDIR) $(LIBDIR); \
1314 | do \
1315 | if test ! -d $(DESTDIR)$$i; then \
1316 | echo "Creating directory $$i"; \
1317 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1318 | else true; \
1319 | fi; \
1320 | done
1321 | if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
1322 | $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
1323 | else \
1324 | $(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
1325 | fi
1326 | -if test "$(VERSION)" != "$(LDVERSION)"; then \
1327 | if test -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE) -o -h $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1328 | then rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1329 | fi; \
1330 | (cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
1331 | fi
1332 | if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
1333 | if test -n "$(DLLLIBRARY)" ; then \
1334 | $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
1335 | else \
1336 | $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
1337 | if test $(LDLIBRARY) != $(INSTSONAME); then \
1338 | (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
1339 | fi \
1340 | fi; \
1341 | if test -n "$(PY3LIBRARY)"; then \
1342 | $(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
1343 | fi; \
1344 | else true; \
1345 | fi
1346 | if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
1347 | rm -f $(DESTDIR)$(BINDIR)python$(VERSION)-32$(EXE); \
1348 | lipo $(LIPO_32BIT_FLAGS) \
1349 | -output $(DESTDIR)$(BINDIR)/python$(VERSION)-32$(EXE) \
1350 | $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1351 | fi
1352 | if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
1353 | rm -f $(DESTDIR)$(BINDIR)python$(VERSION)-intel64$(EXE); \
1354 | lipo $(LIPO_INTEL64_FLAGS) \
1355 | -output $(DESTDIR)$(BINDIR)/python$(VERSION)-intel64$(EXE) \
1356 | $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
1357 | fi
1358 |
1359 | bininstall: altbininstall
1360 | if test ! -d $(DESTDIR)$(LIBPC); then \
1361 | echo "Creating directory $(LIBPC)"; \
1362 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC); \
1363 | fi
1364 | -if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \
1365 | then rm -f $(DESTDIR)$(BINDIR)/python3$(EXE); \
1366 | else true; \
1367 | fi
1368 | (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python3$(EXE))
1369 | -if test "$(VERSION)" != "$(LDVERSION)"; then \
1370 | rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
1371 | (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
1372 | rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \
1373 | (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \
1374 | rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION)-embed.pc; \
1375 | (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python-$(LDVERSION)-embed.pc); \
1376 | fi
1377 | -rm -f $(DESTDIR)$(BINDIR)/python3-config
1378 | (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
1379 | -rm -f $(DESTDIR)$(LIBPC)/python3.pc
1380 | (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
1381 | -rm -f $(DESTDIR)$(LIBPC)/python3-embed.pc
1382 | (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION)-embed.pc python3-embed.pc)
1383 | -rm -f $(DESTDIR)$(BINDIR)/idle3
1384 | (cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
1385 | -rm -f $(DESTDIR)$(BINDIR)/pydoc3
1386 | (cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
1387 | -rm -f $(DESTDIR)$(BINDIR)/2to3
1388 | (cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
1389 | if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
1390 | rm -f $(DESTDIR)$(BINDIR)/python3-32$(EXE); \
1391 | (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-32$(EXE) python3-32$(EXE)) \
1392 | fi
1393 | if test "x$(LIPO_INTEL64_FLAGS)" != "x" ; then \
1394 | rm -f $(DESTDIR)$(BINDIR)/python3-intel64$(EXE); \
1395 | (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-intel64$(EXE) python3-intel64$(EXE)) \
1396 | fi
1397 |
1398 | # Install the versioned manual page
1399 | altmaninstall:
1400 | @for i in $(MANDIR) $(MANDIR)/man1; \
1401 | do \
1402 | if test ! -d $(DESTDIR)$$i; then \
1403 | echo "Creating directory $$i"; \
1404 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1405 | else true; \
1406 | fi; \
1407 | done
1408 | $(INSTALL_DATA) $(srcdir)/Misc/python.man \
1409 | $(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
1410 |
1411 | # Install the unversioned manual page
1412 | maninstall: altmaninstall
1413 | -rm -f $(DESTDIR)$(MANDIR)/man1/python3.1
1414 | (cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python3.1)
1415 |
1416 | # Install the library
1417 | XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
1418 | LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
1419 | tkinter/test/test_ttk site-packages test \
1420 | test/audiodata \
1421 | test/capath test/data \
1422 | test/cjkencodings test/decimaltestdata \
1423 | test/xmltestdata test/xmltestdata/c14n-20 \
1424 | test/dtracedata \
1425 | test/eintrdata \
1426 | test/imghdrdata \
1427 | test/libregrtest \
1428 | test/subprocessdata test/sndhdrdata test/support \
1429 | test/tracedmodules test/encoded_modules \
1430 | test/test_import \
1431 | test/test_import/data \
1432 | test/test_import/data/circular_imports \
1433 | test/test_import/data/circular_imports/subpkg \
1434 | test/test_import/data/package \
1435 | test/test_import/data/package2 \
1436 | test/test_import/data/unwritable \
1437 | importlib \
1438 | importlib/metadata \
1439 | test/test_importlib \
1440 | test/test_importlib/builtin \
1441 | test/test_importlib/data \
1442 | test/test_importlib/data01 \
1443 | test/test_importlib/data01/subdirectory \
1444 | test/test_importlib/data02 \
1445 | test/test_importlib/data02/one \
1446 | test/test_importlib/data02/two \
1447 | test/test_importlib/data03 \
1448 | test/test_importlib/data03/namespace \
1449 | test/test_importlib/data03/namespace/portion1 \
1450 | test/test_importlib/data03/namespace/portion2 \
1451 | test/test_importlib/extension \
1452 | test/test_importlib/frozen \
1453 | test/test_importlib/import_ \
1454 | test/test_importlib/namespace_pkgs \
1455 | test/test_importlib/namespace_pkgs/both_portions \
1456 | test/test_importlib/namespace_pkgs/both_portions/foo \
1457 | test/test_importlib/namespace_pkgs/module_and_namespace_package \
1458 | test/test_importlib/namespace_pkgs/module_and_namespace_package/a_test \
1459 | test/test_importlib/namespace_pkgs/not_a_namespace_pkg \
1460 | test/test_importlib/namespace_pkgs/not_a_namespace_pkg/foo \
1461 | test/test_importlib/namespace_pkgs/portion1 \
1462 | test/test_importlib/namespace_pkgs/portion1/foo \
1463 | test/test_importlib/namespace_pkgs/portion2 \
1464 | test/test_importlib/namespace_pkgs/portion2/foo \
1465 | test/test_importlib/namespace_pkgs/project1 \
1466 | test/test_importlib/namespace_pkgs/project1/parent \
1467 | test/test_importlib/namespace_pkgs/project1/parent/child \
1468 | test/test_importlib/namespace_pkgs/project2 \
1469 | test/test_importlib/namespace_pkgs/project2/parent \
1470 | test/test_importlib/namespace_pkgs/project2/parent/child \
1471 | test/test_importlib/namespace_pkgs/project3 \
1472 | test/test_importlib/namespace_pkgs/project3/parent \
1473 | test/test_importlib/namespace_pkgs/project3/parent/child \
1474 | test/test_importlib/partial \
1475 | test/test_importlib/source \
1476 | test/test_importlib/zipdata01 \
1477 | test/test_importlib/zipdata02 \
1478 | test/test_zoneinfo test/test_zoneinfo/data \
1479 | test/ziptestdata \
1480 | asyncio \
1481 | test/test_asyncio \
1482 | collections concurrent concurrent/futures encodings \
1483 | email email/mime test/test_email test/test_email/data \
1484 | ensurepip ensurepip/_bundled \
1485 | html json test/test_json http dbm xmlrpc \
1486 | sqlite3 sqlite3/test \
1487 | logging csv wsgiref urllib \
1488 | lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
1489 | lib2to3/tests/data lib2to3/tests/data/fixers \
1490 | lib2to3/tests/data/fixers/myfixes \
1491 | ctypes ctypes/test ctypes/macholib \
1492 | idlelib idlelib/Icons idlelib/idle_test \
1493 | distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
1494 | test/test_peg_generator \
1495 | test/test_tools test/test_warnings test/test_warnings/data \
1496 | turtledemo \
1497 | multiprocessing multiprocessing/dummy \
1498 | unittest unittest/test unittest/test/testmock \
1499 | venv venv/scripts venv/scripts/common venv/scripts/posix \
1500 | curses pydoc_data \
1501 | zoneinfo
1502 | libinstall: build_all $(srcdir)/Modules/xxmodule.c
1503 | @for i in $(SCRIPTDIR) $(LIBDEST); \
1504 | do \
1505 | if test ! -d $(DESTDIR)$$i; then \
1506 | echo "Creating directory $$i"; \
1507 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1508 | else true; \
1509 | fi; \
1510 | done
1511 | @for d in $(LIBSUBDIRS); \
1512 | do \
1513 | a=$(srcdir)/Lib/$$d; \
1514 | if test ! -d $$a; then continue; else true; fi; \
1515 | b=$(LIBDEST)/$$d; \
1516 | if test ! -d $(DESTDIR)$$b; then \
1517 | echo "Creating directory $$b"; \
1518 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
1519 | else true; \
1520 | fi; \
1521 | done
1522 | @for i in $(srcdir)/Lib/*.py; \
1523 | do \
1524 | if test -x $$i; then \
1525 | $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
1526 | echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
1527 | else \
1528 | $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
1529 | echo $(INSTALL_DATA) $$i $(LIBDEST); \
1530 | fi; \
1531 | done
1532 | @for d in $(LIBSUBDIRS); \
1533 | do \
1534 | a=$(srcdir)/Lib/$$d; \
1535 | if test ! -d $$a; then continue; else true; fi; \
1536 | if test `ls $$a | wc -l` -lt 1; then continue; fi; \
1537 | b=$(LIBDEST)/$$d; \
1538 | for i in $$a/*; \
1539 | do \
1540 | case $$i in \
1541 | *CVS) ;; \
1542 | *.py[co]) ;; \
1543 | *.orig) ;; \
1544 | *wininst-*.exe) ;; \
1545 | *~) ;; \
1546 | *) \
1547 | if test -d $$i; then continue; fi; \
1548 | if test -x $$i; then \
1549 | echo $(INSTALL_SCRIPT) $$i $$b; \
1550 | $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
1551 | else \
1552 | echo $(INSTALL_DATA) $$i $$b; \
1553 | $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
1554 | fi;; \
1555 | esac; \
1556 | done; \
1557 | done
1558 | $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
1559 | $(DESTDIR)$(LIBDEST); \
1560 | $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
1561 | if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
1562 | $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
1563 | $(DESTDIR)$(LIBDEST)/distutils/tests ; \
1564 | fi
1565 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1566 | $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
1567 | -j0 -d $(LIBDEST) -f \
1568 | -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1569 | $(DESTDIR)$(LIBDEST)
1570 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1571 | $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
1572 | -j0 -d $(LIBDEST) -f \
1573 | -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1574 | $(DESTDIR)$(LIBDEST)
1575 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1576 | $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
1577 | -j0 -d $(LIBDEST) -f \
1578 | -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1579 | $(DESTDIR)$(LIBDEST)
1580 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1581 | $(PYTHON_FOR_BUILD) -Wi $(DESTDIR)$(LIBDEST)/compileall.py \
1582 | -j0 -d $(LIBDEST)/site-packages -f \
1583 | -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1584 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1585 | $(PYTHON_FOR_BUILD) -Wi -O $(DESTDIR)$(LIBDEST)/compileall.py \
1586 | -j0 -d $(LIBDEST)/site-packages -f \
1587 | -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1588 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1589 | $(PYTHON_FOR_BUILD) -Wi -OO $(DESTDIR)$(LIBDEST)/compileall.py \
1590 | -j0 -d $(LIBDEST)/site-packages -f \
1591 | -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1592 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1593 | $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
1594 | -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1595 | $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
1596 |
1597 | # bpo-21536: Misc/python-config.sh is generated in the build directory
1598 | # from $(srcdir)Misc/python-config.sh.in.
1599 | python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
1600 | @ # Substitution happens here, as the completely-expanded BINDIR
1601 | @ # is not available in configure
1602 | sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
1603 | @ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
1604 | LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
1605 | @ # On Darwin, always use the python version of the script, the shell
1606 | @ # version doesn't use the compiler customizations that are provided
1607 | @ # in python (_osx_support.py).
1608 | @if test `uname -s` = Darwin; then \
1609 | cp python-config.py python-config; \
1610 | fi
1611 |
1612 |
1613 | # Install the include files
1614 | INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
1615 | inclinstall:
1616 | @for i in $(INCLDIRSTOMAKE); \
1617 | do \
1618 | if test ! -d $(DESTDIR)$$i; then \
1619 | echo "Creating directory $$i"; \
1620 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1621 | else true; \
1622 | fi; \
1623 | done
1624 | @if test ! -d $(DESTDIR)$(INCLUDEPY)/cpython; then \
1625 | echo "Creating directory $(DESTDIR)$(INCLUDEPY)/cpython"; \
1626 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/cpython; \
1627 | else true; \
1628 | fi
1629 | @if test ! -d $(DESTDIR)$(INCLUDEPY)/internal; then \
1630 | echo "Creating directory $(DESTDIR)$(INCLUDEPY)/internal"; \
1631 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(INCLUDEPY)/internal; \
1632 | else true; \
1633 | fi
1634 | @for i in $(srcdir)/Include/*.h; \
1635 | do \
1636 | echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
1637 | $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
1638 | done
1639 | @for i in $(srcdir)/Include/cpython/*.h; \
1640 | do \
1641 | echo $(INSTALL_DATA) $$i $(INCLUDEPY)/cpython; \
1642 | $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/cpython; \
1643 | done
1644 | @for i in $(srcdir)/Include/internal/*.h; \
1645 | do \
1646 | echo $(INSTALL_DATA) $$i $(INCLUDEPY)/internal; \
1647 | $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY)/internal; \
1648 | done
1649 | $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
1650 |
1651 | # Install the library and miscellaneous stuff needed for extending/embedding
1652 | # This goes into $(exec_prefix)
1653 | LIBPL= $(prefix)/lib/python3.9/config-$(VERSION)$(ABIFLAGS)-x86_64-linux-gnu
1654 |
1655 | # pkgconfig directory
1656 | LIBPC= $(LIBDIR)/pkgconfig
1657 |
1658 | libainstall: all python-config
1659 | @for i in $(LIBDIR) $(LIBPL) $(LIBPC); \
1660 | do \
1661 | if test ! -d $(DESTDIR)$$i; then \
1662 | echo "Creating directory $$i"; \
1663 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1664 | else true; \
1665 | fi; \
1666 | done
1667 | @if test -d $(LIBRARY); then :; else \
1668 | if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1669 | if test "$(SHLIB_SUFFIX)" = .dll; then \
1670 | $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
1671 | else \
1672 | $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1673 | fi; \
1674 | else \
1675 | echo Skip install of $(LIBRARY) - use make frameworkinstall; \
1676 | fi; \
1677 | fi
1678 | $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
1679 | $(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o
1680 | $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
1681 | $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
1682 | $(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup
1683 | $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
1684 | $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
1685 | $(INSTALL_DATA) Misc/python-embed.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)-embed.pc
1686 | $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
1687 | $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
1688 | $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
1689 | $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
1690 | @if [ -s Modules/python.exp -a \
1691 | "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
1692 | echo; echo "Installing support files for building shared extension modules on AIX:"; \
1693 | $(INSTALL_DATA) Modules/python.exp \
1694 | $(DESTDIR)$(LIBPL)/python.exp; \
1695 | echo; echo "$(LIBPL)/python.exp"; \
1696 | $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
1697 | $(DESTDIR)$(LIBPL)/makexp_aix; \
1698 | echo "$(LIBPL)/makexp_aix"; \
1699 | $(INSTALL_SCRIPT) Modules/ld_so_aix \
1700 | $(DESTDIR)$(LIBPL)/ld_so_aix; \
1701 | echo "$(LIBPL)/ld_so_aix"; \
1702 | echo; echo "See Misc/AIX-NOTES for details."; \
1703 | else true; \
1704 | fi
1705 |
1706 | # Install the dynamically loadable modules
1707 | # This goes into $(exec_prefix)
1708 | sharedinstall: sharedmods
1709 | $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
1710 | --prefix=$(prefix) \
1711 | --install-scripts=$(BINDIR) \
1712 | --install-platlib=$(DESTSHARED) \
1713 | --root=$(DESTDIR)/
1714 | -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
1715 | -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
1716 |
1717 | # Here are a couple of targets for MacOSX again, to install a full
1718 | # framework-based Python. frameworkinstall installs everything, the
1719 | # subtargets install specific parts. Much of the actual work is offloaded to
1720 | # the Makefile in Mac
1721 | #
1722 | #
1723 | # This target is here for backward compatibility, previous versions of Python
1724 | # hadn't integrated framework installation in the normal install process.
1725 | frameworkinstall: install
1726 |
1727 | # On install, we re-make the framework
1728 | # structure in the install location, /Library/Frameworks/ or the argument to
1729 | # --enable-framework. If --enable-framework has been specified then we have
1730 | # automatically set prefix to the location deep down in the framework, so we
1731 | # only have to cater for the structural bits of the framework.
1732 |
1733 | frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1734 |
1735 | frameworkinstallstructure: $(LDLIBRARY)
1736 | @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1737 | echo Not configured with --enable-framework; \
1738 | exit 1; \
1739 | else true; \
1740 | fi
1741 | @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1742 | if test ! -d $(DESTDIR)$$i; then \
1743 | echo "Creating directory $(DESTDIR)$$i"; \
1744 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1745 | else true; \
1746 | fi; \
1747 | done
1748 | $(LN) -fsn include/python$(LDVERSION) $(DESTDIR)$(prefix)/Headers
1749 | sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1750 | $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1751 | $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1752 | $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1753 | $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1754 | $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1755 |
1756 | # This installs Mac/Lib into the framework
1757 | # Install a number of symlinks to keep software that expects a normal unix
1758 | # install (which includes python-config) happy.
1759 | frameworkinstallmaclib:
1760 | $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).a"
1761 | $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(LDVERSION).dylib"
1762 | $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).a"
1763 | $(LN) -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBPL)/libpython$(VERSION).dylib"
1764 | $(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(LDVERSION).dylib"
1765 | $(LN) -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
1766 |
1767 | # This installs the IDE, the Launcher and other apps into /Applications
1768 | frameworkinstallapps:
1769 | cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1770 |
1771 | # Build the bootstrap executable that will spawn the interpreter inside
1772 | # an app bundle within the framework. This allows the interpreter to
1773 | # run OS X GUI APIs.
1774 | frameworkpythonw:
1775 | cd Mac && $(MAKE) pythonw
1776 |
1777 | # This installs the python* and other bin symlinks in $prefix/bin or in
1778 | # a bin directory relative to the framework root
1779 | frameworkinstallunixtools:
1780 | cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1781 |
1782 | frameworkaltinstallunixtools:
1783 | cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1784 |
1785 | # This installs the Tools into the applications directory.
1786 | # It is not part of a normal frameworkinstall
1787 | frameworkinstallextras:
1788 | cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1789 |
1790 | # Build the toplevel Makefile
1791 | Makefile.pre: $(srcdir)/Makefile.pre.in config.status
1792 | CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1793 | $(MAKE) -f Makefile.pre Makefile
1794 |
1795 | # Run the configure script.
1796 | config.status: $(srcdir)/configure
1797 | $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1798 |
1799 | .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1800 |
1801 | # Some make's put the object file in the current directory
1802 | .c.o:
1803 | $(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
1804 |
1805 | # bpo-30104: dtoa.c uses union to cast double to unsigned long[2]. clang 4.0
1806 | # with -O2 or higher and strict aliasing miscompiles the ratio() function
1807 | # causing rounding issues. Compile dtoa.c using -fno-strict-aliasing on clang.
1808 | # https://bugs.llvm.org//show_bug.cgi?id=31928
1809 | Python/dtoa.o: Python/dtoa.c
1810 | $(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $<
1811 |
1812 | # Run reindent on the library
1813 | reindent:
1814 | ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1815 |
1816 | # Rerun configure with the same options as it was run last time,
1817 | # provided the config.status script exists
1818 | recheck:
1819 | $(SHELL) config.status --recheck
1820 | $(SHELL) config.status
1821 |
1822 | # Regenerate configure and pyconfig.h.in
1823 | .PHONY: autoconf
1824 | autoconf:
1825 | # Regenerate the configure script from configure.ac using autoconf
1826 | (cd $(srcdir); autoconf -Wall)
1827 | # Regenerate pyconfig.h.in from configure.ac using autoheader
1828 | (cd $(srcdir); autoheader -Wall)
1829 |
1830 | # Create a tags file for vi
1831 | tags::
1832 | ctags -w $(srcdir)/Include/*.h $(srcdir)/Include/cpython/*.h $(srcdir)/Include/internal/*.h
1833 | for i in $(SRCDIRS); do ctags -f tags -w -a $(srcdir)/$$i/*.[ch]; done
1834 | ctags -f tags -w -a $(srcdir)/Modules/_ctypes/*.[ch]
1835 | find $(srcdir)/Lib -type f -name "*.py" -not -name "test_*.py" -not -path "*/test/*" -not -path "*/tests/*" -not -path "*/*_test/*" | ctags -f tags -w -a -L -
1836 | LC_ALL=C sort -o tags tags
1837 |
1838 | # Create a tags file for GNU Emacs
1839 | TAGS::
1840 | cd $(srcdir); \
1841 | etags Include/*.h Include/cpython/*.h Include/internal/*.h; \
1842 | for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1843 | etags -a $(srcdir)/Modules/_ctypes/*.[ch]
1844 | find $(srcdir)/Lib -type f -name "*.py" -not -name "test_*.py" -not -path "*/test/*" -not -path "*/tests/*" -not -path "*/*_test/*" | etags - -a
1845 |
1846 | # Sanitation targets -- clean leaves libraries, executables and tags
1847 | # files, which clobber removes as well
1848 | pycremoval:
1849 | -find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';'
1850 | -find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1851 |
1852 | rmtestturds:
1853 | -rm -f *BAD *GOOD *SKIPPED
1854 | -rm -rf OUT
1855 | -rm -f *.TXT
1856 | -rm -f *.txt
1857 | -rm -f gb-18030-2000.xml
1858 |
1859 | docclean:
1860 | -rm -rf Doc/build
1861 | -rm -rf Doc/tools/sphinx Doc/tools/pygments Doc/tools/docutils
1862 |
1863 | # like the 'clean' target but retain the profile guided optimization (PGO)
1864 | # data. The PGO data is only valid if source code remains unchanged.
1865 | clean-retain-profile: pycremoval
1866 | find . -name '*.[oa]' -exec rm -f {} ';'
1867 | find . -name '*.s[ol]' -exec rm -f {} ';'
1868 | find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
1869 | find . -name '*.lst' -exec rm -f {} ';'
1870 | find build -name 'fficonfig.h' -exec rm -f {} ';' || true
1871 | find build -name '*.py' -exec rm -f {} ';' || true
1872 | find build -name '*.py[co]' -exec rm -f {} ';' || true
1873 | -rm -f pybuilddir.txt
1874 | -rm -f Lib/lib2to3/*Grammar*.pickle
1875 | -rm -f Programs/_testembed Programs/_freeze_importlib
1876 | -find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
1877 | -rm -f Include/pydtrace_probes.h
1878 | -rm -f profile-gen-stamp
1879 |
1880 | profile-removal:
1881 | find . -name '*.gc??' -exec rm -f {} ';'
1882 | find . -name '*.profclang?' -exec rm -f {} ';'
1883 | find . -name '*.dyn' -exec rm -f {} ';'
1884 | rm -f $(COVERAGE_INFO)
1885 | rm -rf $(COVERAGE_REPORT)
1886 | rm -f profile-run-stamp
1887 |
1888 | clean: clean-retain-profile
1889 | @if test build_all = profile-opt; then \
1890 | rm -f profile-gen-stamp profile-clean-stamp; \
1891 | $(MAKE) profile-removal; \
1892 | fi
1893 |
1894 | clobber: clean
1895 | -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1896 | tags TAGS \
1897 | config.cache config.log pyconfig.h Modules/config.c
1898 | -rm -rf build platform
1899 | -rm -rf $(PYTHONFRAMEWORKDIR)
1900 | -rm -f python-config.py python-config
1901 |
1902 | # Make things extra clean, before making a distribution:
1903 | # remove all generated files, even Makefile[.pre]
1904 | # Keep configure and Python-ast.[ch], it's possible they can't be generated
1905 | distclean: clobber
1906 | for file in $(srcdir)/Lib/test/data/* ; do \
1907 | if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \
1908 | done
1909 | -rm -f core Makefile Makefile.pre config.status Modules/Setup.local \
1910 | Modules/ld_so_aix Modules/python.exp Misc/python.pc \
1911 | Misc/python-embed.pc Misc/python-config.sh
1912 | -rm -f python*-gdb.py
1913 | # Issue #28258: set LC_ALL to avoid issues with Estonian locale.
1914 | # Expansion is performed here by shell (spawned by make) itself before
1915 | # arguments are passed to find. So LC_ALL=C must be set as a separate
1916 | # command.
1917 | LC_ALL=C; find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
1918 | -o -name '[@,#]*' -o -name '*.old' \
1919 | -o -name '*.orig' -o -name '*.rej' \
1920 | -o -name '*.bak' ')' \
1921 | -exec rm -f {} ';'
1922 |
1923 | # Check that all symbols exported by libpython start with "Py" or "_Py"
1924 | smelly: all
1925 | $(RUNSHARED) ./$(BUILDPYTHON) Tools/scripts/smelly.py
1926 |
1927 | # Find files with funny names
1928 | funny:
1929 | find $(SUBDIRS) $(SUBDIRSTOO) \
1930 | -type d \
1931 | -o -name '*.[chs]' \
1932 | -o -name '*.py' \
1933 | -o -name '*.pyw' \
1934 | -o -name '*.dat' \
1935 | -o -name '*.el' \
1936 | -o -name '*.fd' \
1937 | -o -name '*.in' \
1938 | -o -name '*.gif' \
1939 | -o -name '*.txt' \
1940 | -o -name '*.xml' \
1941 | -o -name '*.xbm' \
1942 | -o -name '*.xpm' \
1943 | -o -name '*.uue' \
1944 | -o -name '*.decTest' \
1945 | -o -name '*.tmCommand' \
1946 | -o -name '*.tmSnippet' \
1947 | -o -name 'Setup' \
1948 | -o -name 'Setup.*' \
1949 | -o -name README \
1950 | -o -name NEWS \
1951 | -o -name HISTORY \
1952 | -o -name Makefile \
1953 | -o -name ChangeLog \
1954 | -o -name .hgignore \
1955 | -o -name MANIFEST \
1956 | -o -print
1957 |
1958 | # Perform some verification checks on any modified files.
1959 | patchcheck: all
1960 | $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1961 |
1962 | # Dependencies
1963 |
1964 | Python/thread.o: $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_pthread.h $(srcdir)/Python/condvar.h
1965 |
1966 | # Declare targets that aren't real files
1967 | .PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest
1968 | .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1969 | .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1970 | .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1971 | .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1972 | .PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
1973 | .PHONY: smelly funny patchcheck touch altmaninstall commoninstall
1974 | .PHONY: clean-retain-profile profile-removal run_profile_task
1975 | .PHONY: build_all_generate_profile build_all_merge_profile
1976 | .PHONY: gdbhooks
1977 |
1978 | # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
1979 | # Local Variables:
1980 | # mode: makefile
1981 | # End:
1982 |
1983 | # Rules appended by makesetup
1984 |
1985 | Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/posixmodule.c -o Modules/posixmodule.o
1986 | Modules/posix$(EXT_SUFFIX): Modules/posixmodule.o; $(BLDSHARED) Modules/posixmodule.o -o Modules/posix$(EXT_SUFFIX)
1987 | Modules/errnomodule.o: $(srcdir)/Modules/errnomodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/errnomodule.c -o Modules/errnomodule.o
1988 | Modules/errno$(EXT_SUFFIX): Modules/errnomodule.o; $(BLDSHARED) Modules/errnomodule.o -o Modules/errno$(EXT_SUFFIX)
1989 | Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/pwdmodule.c -o Modules/pwdmodule.o
1990 | Modules/pwd$(EXT_SUFFIX): Modules/pwdmodule.o; $(BLDSHARED) Modules/pwdmodule.o -o Modules/pwd$(EXT_SUFFIX)
1991 | Modules/_sre.o: $(srcdir)/Modules/_sre.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_sre.c -o Modules/_sre.o
1992 | Modules/_sre$(EXT_SUFFIX): Modules/_sre.o; $(BLDSHARED) Modules/_sre.o -o Modules/_sre$(EXT_SUFFIX)
1993 | Modules/_codecsmodule.o: $(srcdir)/Modules/_codecsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_codecsmodule.c -o Modules/_codecsmodule.o
1994 | Modules/_codecs$(EXT_SUFFIX): Modules/_codecsmodule.o; $(BLDSHARED) Modules/_codecsmodule.o -o Modules/_codecs$(EXT_SUFFIX)
1995 | Modules/_weakref.o: $(srcdir)/Modules/_weakref.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_weakref.c -o Modules/_weakref.o
1996 | Modules/_weakref$(EXT_SUFFIX): Modules/_weakref.o; $(BLDSHARED) Modules/_weakref.o -o Modules/_weakref$(EXT_SUFFIX)
1997 | Modules/_functoolsmodule.o: $(srcdir)/Modules/_functoolsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/_functoolsmodule.c -o Modules/_functoolsmodule.o
1998 | Modules/_functools$(EXT_SUFFIX): Modules/_functoolsmodule.o; $(BLDSHARED) Modules/_functoolsmodule.o -o Modules/_functools$(EXT_SUFFIX)
1999 | Modules/_operator.o: $(srcdir)/Modules/_operator.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_operator.c -o Modules/_operator.o
2000 | Modules/_operator$(EXT_SUFFIX): Modules/_operator.o; $(BLDSHARED) Modules/_operator.o -o Modules/_operator$(EXT_SUFFIX)
2001 | Modules/_collectionsmodule.o: $(srcdir)/Modules/_collectionsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_collectionsmodule.c -o Modules/_collectionsmodule.o
2002 | Modules/_collections$(EXT_SUFFIX): Modules/_collectionsmodule.o; $(BLDSHARED) Modules/_collectionsmodule.o -o Modules/_collections$(EXT_SUFFIX)
2003 | Modules/_abc.o: $(srcdir)/Modules/_abc.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_abc.c -o Modules/_abc.o
2004 | Modules/_abc$(EXT_SUFFIX): Modules/_abc.o; $(BLDSHARED) Modules/_abc.o -o Modules/_abc$(EXT_SUFFIX)
2005 | Modules/itertoolsmodule.o: $(srcdir)/Modules/itertoolsmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/itertoolsmodule.c -o Modules/itertoolsmodule.o
2006 | Modules/itertools$(EXT_SUFFIX): Modules/itertoolsmodule.o; $(BLDSHARED) Modules/itertoolsmodule.o -o Modules/itertools$(EXT_SUFFIX)
2007 | Modules/atexitmodule.o: $(srcdir)/Modules/atexitmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/atexitmodule.c -o Modules/atexitmodule.o
2008 | Modules/atexit$(EXT_SUFFIX): Modules/atexitmodule.o; $(BLDSHARED) Modules/atexitmodule.o -o Modules/atexit$(EXT_SUFFIX)
2009 | Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/signalmodule.c -o Modules/signalmodule.o
2010 | Modules/_signal$(EXT_SUFFIX): Modules/signalmodule.o; $(BLDSHARED) Modules/signalmodule.o -o Modules/_signal$(EXT_SUFFIX)
2011 | Modules/_stat.o: $(srcdir)/Modules/_stat.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_stat.c -o Modules/_stat.o
2012 | Modules/_stat$(EXT_SUFFIX): Modules/_stat.o; $(BLDSHARED) Modules/_stat.o -o Modules/_stat$(EXT_SUFFIX)
2013 | Modules/timemodule.o: $(srcdir)/Modules/timemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/timemodule.c -o Modules/timemodule.o
2014 | Modules/time$(EXT_SUFFIX): Modules/timemodule.o; $(BLDSHARED) Modules/timemodule.o -o Modules/time$(EXT_SUFFIX)
2015 | Modules/_threadmodule.o: $(srcdir)/Modules/_threadmodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -c $(srcdir)/Modules/_threadmodule.c -o Modules/_threadmodule.o
2016 | Modules/_thread$(EXT_SUFFIX): Modules/_threadmodule.o; $(BLDSHARED) Modules/_threadmodule.o -o Modules/_thread$(EXT_SUFFIX)
2017 | Modules/_localemodule.o: $(srcdir)/Modules/_localemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -c $(srcdir)/Modules/_localemodule.c -o Modules/_localemodule.o
2018 | Modules/_locale$(EXT_SUFFIX): Modules/_localemodule.o; $(BLDSHARED) Modules/_localemodule.o -o Modules/_locale$(EXT_SUFFIX)
2019 | Modules/_iomodule.o: $(srcdir)/Modules/_io/_iomodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/_iomodule.c -o Modules/_iomodule.o
2020 | Modules/iobase.o: $(srcdir)/Modules/_io/iobase.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/iobase.c -o Modules/iobase.o
2021 | Modules/fileio.o: $(srcdir)/Modules/_io/fileio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/fileio.c -o Modules/fileio.o
2022 | Modules/bytesio.o: $(srcdir)/Modules/_io/bytesio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bytesio.c -o Modules/bytesio.o
2023 | Modules/bufferedio.o: $(srcdir)/Modules/_io/bufferedio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bufferedio.c -o Modules/bufferedio.o
2024 | Modules/textio.o: $(srcdir)/Modules/_io/textio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/textio.c -o Modules/textio.o
2025 | Modules/stringio.o: $(srcdir)/Modules/_io/stringio.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/stringio.c -o Modules/stringio.o
2026 | Modules/_io$(EXT_SUFFIX): Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o; $(BLDSHARED) Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o -o Modules/_io$(EXT_SUFFIX)
2027 | Modules/faulthandler.o: $(srcdir)/Modules/faulthandler.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/faulthandler.c -o Modules/faulthandler.o
2028 | Modules/faulthandler$(EXT_SUFFIX): Modules/faulthandler.o; $(BLDSHARED) Modules/faulthandler.o -o Modules/faulthandler$(EXT_SUFFIX)
2029 | Modules/_tracemalloc.o: $(srcdir)/Modules/_tracemalloc.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_tracemalloc.c -o Modules/_tracemalloc.o
2030 | Modules/_tracemalloc$(EXT_SUFFIX): Modules/_tracemalloc.o; $(BLDSHARED) Modules/_tracemalloc.o -o Modules/_tracemalloc$(EXT_SUFFIX)
2031 | Modules/_peg_parser.o: $(srcdir)/Modules/_peg_parser.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/_peg_parser.c -o Modules/_peg_parser.o
2032 | Modules/_peg_parser$(EXT_SUFFIX): Modules/_peg_parser.o; $(BLDSHARED) Modules/_peg_parser.o -o Modules/_peg_parser$(EXT_SUFFIX)
2033 | Modules/symtablemodule.o: $(srcdir)/Modules/symtablemodule.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/symtablemodule.c -o Modules/symtablemodule.o
2034 | Modules/_symtable$(EXT_SUFFIX): Modules/symtablemodule.o; $(BLDSHARED) Modules/symtablemodule.o -o Modules/_symtable$(EXT_SUFFIX)
2035 | Modules/xxsubtype.o: $(srcdir)/Modules/xxsubtype.c; $(CC) $(PY_BUILTIN_MODULE_CFLAGS) -c $(srcdir)/Modules/xxsubtype.c -o Modules/xxsubtype.o
2036 | Modules/xxsubtype$(EXT_SUFFIX): Modules/xxsubtype.o; $(BLDSHARED) Modules/xxsubtype.o -o Modules/xxsubtype$(EXT_SUFFIX)
2037 |
--------------------------------------------------------------------------------
/test files/deep_json.json:
--------------------------------------------------------------------------------
1 | {
2 | "origin_addresses": [
3 | "Compton, CA, USA"
4 | ],
5 | "rows": [
6 | {
7 | "elements": [
8 | {
9 | "distance":
10 | {
11 | "text": "227 mi",
12 | "value": 365468,
13 | "moar_elements":
14 | {
15 | "something": false,
16 | "else": 42,
17 | "more_stuff": [
18 | "some",
19 | "more",
20 | "things",
21 | {
22 | "to_do":
23 | {
24 | "its_like": "this",
25 | "and_like": "that",
26 | "and_like_this": "and_uh",
27 | "and": "like_that_and",
28 | "like_this": "and",
29 | "like_that": "and_uh",
30 | "so":
31 | {
32 | "lets": "chill",
33 | "til": [
34 | "the",
35 | "next",
36 | "episode"
37 | ]
38 | },
39 | "switch!": true,
40 | "the_light":
41 | {
42 | "in_the": "window",
43 | "is":
44 | {
45 | "a_crack":
46 | {
47 | "in_the":
48 | {
49 | "sky": ";",
50 | "a": "stairway",
51 | "to": "darkness",
52 | "in":
53 | {
54 | "the": "blink",
55 | "of":
56 | {
57 | "an": "eye"
58 | },
59 | },
60 | },
61 | },
62 | },
63 | },
64 | },
65 | },
66 | ],
67 | },
68 | },
69 | "duration":
70 | {
71 | "text": "3 hours 54 mins",
72 | "value": 14064,
73 | "elements":
74 | {
75 | "something": true,
76 | "else": 42,
77 | "more_stuff": [
78 | "some",
79 | "more",
80 | "things",
81 | {
82 | "to_do":
83 | {
84 | "like": "this",
85 | "and_like": "that",
86 | "and_like_this": "and_uh",
87 | "and": "like_that_and",
88 | "like_this": "and",
89 | "like_that": "and_uh",
90 | "so":
91 | {
92 | "lets": "chill",
93 | "til": "the next episode"
94 | }
95 | }
96 | }
97 | ]
98 | }
99 | },
100 | "status": "OK"
101 | },
102 | {
103 | "distance":
104 | {
105 | "text": "94.6 mi",
106 | "value": 152193
107 | },
108 | "duration":
109 | {
110 | "text": "1 hour 44 mins",
111 | "value": 6227
112 | },
113 | "status": "OK"
114 | },
115 | {
116 | "distance":
117 | {
118 | "text": "2,878 mi",
119 | "value": 4632197
120 | },
121 | "duration":
122 | {
123 | "text": "1 day 18 hours",
124 | "value": 151772
125 | },
126 | "status": "OK"
127 | },
128 | {
129 | "distance":
130 | {
131 | "text": "1,286 mi",
132 | "value": 2069031
133 | },
134 | "duration":
135 | {
136 | "text": "18 hours 43 mins",
137 | "value": 67405
138 | },
139 | "status": "OK"
140 | },
141 | {
142 | "distance":
143 | {
144 | "text": "1,742 mi",
145 | "value": 2802972
146 | },
147 | "duration":
148 | {
149 | "text": "1 day 2 hours",
150 | "value": 93070
151 | },
152 | "status": "OK"
153 | },
154 | {
155 | "distance":
156 | {
157 | "text": "2,871 mi",
158 | "value": 4620514
159 | },
160 | "duration":
161 | {
162 | "text": "1 day 18 hours",
163 | "value": 152913
164 | },
165 | "status": "OK"
166 | }]
167 | }],
168 | "status": "OK"
169 | }
170 |
--------------------------------------------------------------------------------
/test files/lex-flex example.l:
--------------------------------------------------------------------------------
1 | %{
2 | /*-------------------------------------------------------------------------
3 | *
4 | * scan.l
5 | * lexical scanner for PostgreSQL
6 | *
7 | * NOTE NOTE NOTE:
8 | *
9 | * The rules in this file must be kept in sync with psql's lexer!!!
10 | *
11 | * The rules are designed so that the scanner never has to backtrack,
12 | * in the sense that there is always a rule that can match the input
13 | * consumed so far (the rule action may internally throw back some input
14 | * with yyless(), however). As explained in the flex manual, this makes
15 | * for a useful speed increase --- about a third faster than a plain -CF
16 | * lexer, in simple testing. The extra complexity is mostly in the rules
17 | * for handling float numbers and continued string literals. If you change
18 | * the lexical rules, verify that you haven't broken the no-backtrack
19 | * property by running flex with the "-b" option and checking that the
20 | * resulting "lex.backup" file says that no backing up is needed.
21 | *
22 | *
23 | * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
24 | * Portions Copyright (c) 1994, Regents of the University of California
25 | *
26 | * IDENTIFICATION
27 | * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.167 2010/05/30 18:10:41 tgl Exp $
28 | *
29 | *-------------------------------------------------------------------------
30 | */
31 | #include "postgres.h"
32 |
33 | #include
34 | #include
35 |
36 | #include "parser/parser.h" /* only needed for GUC variables */
37 | #include "parser/scanner.h"
38 | #include "parser/scansup.h"
39 | #include "mb/pg_wchar.h"
40 |
41 |
42 | /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
43 | #undef fprintf
44 | #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
45 |
46 | /*
47 | * GUC variables. This is a DIRECT violation of the warning given at the
48 | * head of gram.y, ie flex/bison code must not depend on any GUC variables;
49 | * as such, changing their values can induce very unintuitive behavior.
50 | * But we shall have to live with it as a short-term thing until the switch
51 | * to SQL-standard string syntax is complete.
52 | */
53 | int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
54 | bool escape_string_warning = true;
55 | bool standard_conforming_strings = true;
56 |
57 | /*
58 | * Set the type of YYSTYPE.
59 | */
60 | #define YYSTYPE core_YYSTYPE
61 |
62 | /*
63 | * Set the type of yyextra. All state variables used by the scanner should
64 | * be in yyextra, *not* statically allocated.
65 | */
66 | #define YY_EXTRA_TYPE core_yy_extra_type *
67 |
68 | /*
69 | * Each call to yylex must set yylloc to the location of the found token
70 | * (expressed as a byte offset from the start of the input text).
71 | * When we parse a token that requires multiple lexer rules to process,
72 | * this should be done in the first such rule, else yylloc will point
73 | * into the middle of the token.
74 | */
75 | #define SET_YYLLOC() (*(yylloc) = yytext - yyextra->scanbuf)
76 |
77 | /*
78 | * Advance yylloc by the given number of bytes.
79 | */
80 | #define ADVANCE_YYLLOC(delta) ( *(yylloc) += (delta) )
81 |
82 | #define startlit() ( yyextra->literallen = 0 )
83 | static void addlit(char *ytext, int yleng, core_yyscan_t yyscanner);
84 | static void addlitchar(unsigned char ychar, core_yyscan_t yyscanner);
85 | static char *litbufdup(core_yyscan_t yyscanner);
86 | static char *litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner);
87 | static unsigned char unescape_single_char(unsigned char c, core_yyscan_t yyscanner);
88 | static int process_integer_literal(const char *token, YYSTYPE *lval);
89 | static bool is_utf16_surrogate_first(pg_wchar c);
90 | static bool is_utf16_surrogate_second(pg_wchar c);
91 | static pg_wchar surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second);
92 | static void addunicode(pg_wchar c, yyscan_t yyscanner);
93 |
94 | #define yyerror(msg) scanner_yyerror(msg, yyscanner)
95 |
96 | #define lexer_errposition() scanner_errposition(*(yylloc), yyscanner)
97 |
98 | static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner);
99 | static void check_escape_warning(core_yyscan_t yyscanner);
100 |
101 | /*
102 | * Work around a bug in flex 2.5.35: it emits a couple of functions that
103 | * it forgets to emit declarations for. Since we use -Wmissing-prototypes,
104 | * this would cause warnings. Providing our own declarations should be
105 | * harmless even when the bug gets fixed.
106 | */
107 | extern int core_yyget_column(yyscan_t yyscanner);
108 | extern void core_yyset_column(int column_no, yyscan_t yyscanner);
109 |
110 | %}
111 |
112 | %option reentrant
113 | %option bison-bridge
114 | %option bison-locations
115 | %option 8bit
116 | %option never-interactive
117 | %option nodefault
118 | %option noinput
119 | %option nounput
120 | %option noyywrap
121 | %option noyyalloc
122 | %option noyyrealloc
123 | %option noyyfree
124 | %option warn
125 | %option prefix="core_yy"
126 |
127 | /*
128 | * OK, here is a short description of lex/flex rules behavior.
129 | * The longest pattern which matches an input string is always chosen.
130 | * For equal-length patterns, the first occurring in the rules list is chosen.
131 | * INITIAL is the starting state, to which all non-conditional rules apply.
132 | * Exclusive states change parsing rules while the state is active. When in
133 | * an exclusive state, only those rules defined for that state apply.
134 | *
135 | * We use exclusive states for quoted strings, extended comments,
136 | * and to eliminate parsing troubles for numeric strings.
137 | * Exclusive states:
138 | * bit string literal
139 | * extended C-style comments
140 | * delimited identifiers (double-quoted identifiers)
141 | * hexadecimal numeric string
142 | * standard quoted strings
143 | * extended quoted strings (support backslash escape sequences)
144 | * $foo$ quoted strings
145 | * quoted identifier with Unicode escapes
146 | * quoted string with Unicode escapes
147 | * Unicode surrogate pair in extended quoted string
148 | */
149 |
150 | %x xb
151 | %x xc
152 | %x xd
153 | %x xh
154 | %x xe
155 | %x xq
156 | %x xdolq
157 | %x xui
158 | %x xus
159 | %x xeu
160 |
161 | /*
162 | * In order to make the world safe for Windows and Mac clients as well as
163 | * Unix ones, we accept either \n or \r as a newline. A DOS-style \r\n
164 | * sequence will be seen as two successive newlines, but that doesn't cause
165 | * any problems. Comments that start with -- and extend to the next
166 | * newline are treated as equivalent to a single whitespace character.
167 | *
168 | * NOTE a fine point: if there is no newline following --, we will absorb
169 | * everything to the end of the input as a comment. This is correct. Older
170 | * versions of Postgres failed to recognize -- as a comment if the input
171 | * did not end with a newline.
172 | *
173 | * XXX perhaps \f (formfeed) should be treated as a newline as well?
174 | *
175 | * XXX if you change the set of whitespace characters, fix scanner_isspace()
176 | * to agree, and see also the plpgsql lexer.
177 | */
178 |
179 | space [ \t\n\r\f]
180 | horiz_space [ \t\f]
181 | newline [\n\r]
182 | non_newline [^\n\r]
183 |
184 | comment ("--"{non_newline}*)
185 |
186 | whitespace ({space}+|{comment})
187 |
188 | /*
189 | * SQL requires at least one newline in the whitespace separating
190 | * string literals that are to be concatenated. Silly, but who are we
191 | * to argue? Note that {whitespace_with_newline} should not have * after
192 | * it, whereas {whitespace} should generally have a * after it...
193 | */
194 |
195 | special_whitespace ({space}+|{comment}{newline})
196 | horiz_whitespace ({horiz_space}|{comment})
197 | whitespace_with_newline ({horiz_whitespace}*{newline}{special_whitespace}*)
198 |
199 | /*
200 | * To ensure that {quotecontinue} can be scanned without having to back up
201 | * if the full pattern isn't matched, we include trailing whitespace in
202 | * {quotestop}. This matches all cases where {quotecontinue} fails to match,
203 | * except for {quote} followed by whitespace and just one "-" (not two,
204 | * which would start a {comment}). To cover that we have {quotefail}.
205 | * The actions for {quotestop} and {quotefail} must throw back characters
206 | * beyond the quote proper.
207 | */
208 | quote '
209 | quotestop {quote}{whitespace}*
210 | quotecontinue {quote}{whitespace_with_newline}{quote}
211 | quotefail {quote}{whitespace}*"-"
212 |
213 | /* Bit string
214 | * It is tempting to scan the string for only those characters
215 | * which are allowed. However, this leads to silently swallowed
216 | * characters if illegal characters are included in the string.
217 | * For example, if xbinside is [01] then B'ABCD' is interpreted
218 | * as a zero-length string, and the ABCD' is lost!
219 | * Better to pass the string forward and let the input routines
220 | * validate the contents.
221 | */
222 | xbstart [bB]{quote}
223 | xbinside [^']*
224 |
225 | /* Hexadecimal number */
226 | xhstart [xX]{quote}
227 | xhinside [^']*
228 |
229 | /* National character */
230 | xnstart [nN]{quote}
231 |
232 | /* Quoted string that allows backslash escapes */
233 | xestart [eE]{quote}
234 | xeinside [^\\']+
235 | xeescape [\\][^0-7]
236 | xeoctesc [\\][0-7]{1,3}
237 | xehexesc [\\]x[0-9A-Fa-f]{1,2}
238 | xeunicode [\\](u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
239 | xeunicodefail [\\](u[0-9A-Fa-f]{0,3}|U[0-9A-Fa-f]{0,7})
240 |
241 | /* Extended quote
242 | * xqdouble implements embedded quote, ''''
243 | */
244 | xqstart {quote}
245 | xqdouble {quote}{quote}
246 | xqinside [^']+
247 |
248 | /* $foo$ style quotes ("dollar quoting")
249 | * The quoted string starts with $foo$ where "foo" is an optional string
250 | * in the form of an identifier, except that it may not contain "$",
251 | * and extends to the first occurrence of an identical string.
252 | * There is *no* processing of the quoted text.
253 | *
254 | * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
255 | * fails to match its trailing "$".
256 | */
257 | dolq_start [A-Za-z\200-\377_]
258 | dolq_cont [A-Za-z\200-\377_0-9]
259 | dolqdelim \$({dolq_start}{dolq_cont}*)?\$
260 | dolqfailed \${dolq_start}{dolq_cont}*
261 | dolqinside [^$]+
262 |
263 | /* Double quote
264 | * Allows embedded spaces and other special characters into identifiers.
265 | */
266 | dquote \"
267 | xdstart {dquote}
268 | xdstop {dquote}
269 | xddouble {dquote}{dquote}
270 | xdinside [^"]+
271 |
272 | /* Unicode escapes */
273 | uescape [uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}[^']{quote}
274 | /* error rule to avoid backup */
275 | uescapefail ("-"|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*"-"|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}[^']|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*{quote}|[uU][eE][sS][cC][aA][pP][eE]{whitespace}*|[uU][eE][sS][cC][aA][pP]|[uU][eE][sS][cC][aA]|[uU][eE][sS][cC]|[uU][eE][sS]|[uU][eE]|[uU])
276 |
277 | /* Quoted identifier with Unicode escapes */
278 | xuistart [uU]&{dquote}
279 | xuistop1 {dquote}{whitespace}*{uescapefail}?
280 | xuistop2 {dquote}{whitespace}*{uescape}
281 |
282 | /* Quoted string with Unicode escapes */
283 | xusstart [uU]&{quote}
284 | xusstop1 {quote}{whitespace}*{uescapefail}?
285 | xusstop2 {quote}{whitespace}*{uescape}
286 |
287 | /* error rule to avoid backup */
288 | xufailed [uU]&
289 |
290 |
291 | /* C-style comments
292 | *
293 | * The "extended comment" syntax closely resembles allowable operator syntax.
294 | * The tricky part here is to get lex to recognize a string starting with
295 | * slash-star as a comment, when interpreting it as an operator would produce
296 | * a longer match --- remember lex will prefer a longer match! Also, if we
297 | * have something like plus-slash-star, lex will think this is a 3-character
298 | * operator whereas we want to see it as a + operator and a comment start.
299 | * The solution is two-fold:
300 | * 1. append {op_chars}* to xcstart so that it matches as much text as
301 | * {operator} would. Then the tie-breaker (first matching rule of same
302 | * length) ensures xcstart wins. We put back the extra stuff with yyless()
303 | * in case it contains a star-slash that should terminate the comment.
304 | * 2. In the operator rule, check for slash-star within the operator, and
305 | * if found throw it back with yyless(). This handles the plus-slash-star
306 | * problem.
307 | * Dash-dash comments have similar interactions with the operator rule.
308 | */
309 | xcstart \/\*{op_chars}*
310 | xcstop \*+\/
311 | xcinside [^*/]+
312 |
313 | digit [0-9]
314 | ident_start [A-Za-z\200-\377_]
315 | ident_cont [A-Za-z\200-\377_0-9\$]
316 |
317 | identifier {ident_start}{ident_cont}*
318 |
319 | typecast "::"
320 | dot_dot \.\.
321 | colon_equals ":="
322 |
323 | /*
324 | * "self" is the set of chars that should be returned as single-character
325 | * tokens. "op_chars" is the set of chars that can make up "Op" tokens,
326 | * which can be one or more characters long (but if a single-char token
327 | * appears in the "self" set, it is not to be returned as an Op). Note
328 | * that the sets overlap, but each has some chars that are not in the other.
329 | *
330 | * If you change either set, adjust the character lists appearing in the
331 | * rule for "operator"!
332 | */
333 | self [,()\[\].;\:\+\-\*\/\%\^\<\>\=]
334 | op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%\<\>\=]
335 | operator {op_chars}+
336 |
337 | /* we no longer allow unary minus in numbers.
338 | * instead we pass it separately to parser. there it gets
339 | * coerced via doNegate() -- Leon aug 20 1999
340 | *
341 | * {decimalfail} is used because we would like "1..10" to lex as 1, dot_dot, 10.
342 | *
343 | * {realfail1} and {realfail2} are added to prevent the need for scanner
344 | * backup when the {real} rule fails to match completely.
345 | */
346 |
347 | integer {digit}+
348 | decimal (({digit}*\.{digit}+)|({digit}+\.{digit}*))
349 | decimalfail {digit}+\.\.
350 | real ({integer}|{decimal})[Ee][-+]?{digit}+
351 | realfail1 ({integer}|{decimal})[Ee]
352 | realfail2 ({integer}|{decimal})[Ee][-+]
353 |
354 | param \${integer}
355 |
356 | other .
357 |
358 | /*
359 | * Dollar quoted strings are totally opaque, and no escaping is done on them.
360 | * Other quoted strings must allow some special characters such as single-quote
361 | * and newline.
362 | * Embedded single-quotes are implemented both in the SQL standard
363 | * style of two adjacent single quotes "''" and in the Postgres/Java style
364 | * of escaped-quote "\'".
365 | * Other embedded escaped characters are matched explicitly and the leading
366 | * backslash is dropped from the string.
367 | * Note that xcstart must appear before operator, as explained above!
368 | * Also whitespace (comment) must appear before operator.
369 | */
370 |
371 | %%
372 |
373 | {whitespace} {
374 | /* ignore */
375 | }
376 |
377 | {xcstart} {
378 | /* Set location in case of syntax error in comment */
379 | SET_YYLLOC();
380 | yyextra->xcdepth = 0;
381 | BEGIN(xc);
382 | /* Put back any characters past slash-star; see above */
383 | yyless(2);
384 | }
385 |
386 | {xcstart} {
387 | (yyextra->xcdepth)++;
388 | /* Put back any characters past slash-star; see above */
389 | yyless(2);
390 | }
391 |
392 | {xcstop} {
393 | if (yyextra->xcdepth <= 0)
394 | BEGIN(INITIAL);
395 | else
396 | (yyextra->xcdepth)--;
397 | }
398 |
399 | {xcinside} {
400 | /* ignore */
401 | }
402 |
403 | {op_chars} {
404 | /* ignore */
405 | }
406 |
407 | \*+ {
408 | /* ignore */
409 | }
410 |
411 | <> { yyerror("unterminated /* comment"); }
412 |
413 | {xbstart} {
414 | /* Binary bit type.
415 | * At some point we should simply pass the string
416 | * forward to the parser and label it there.
417 | * In the meantime, place a leading "b" on the string
418 | * to mark it for the input routine as a binary string.
419 | */
420 | SET_YYLLOC();
421 | BEGIN(xb);
422 | startlit();
423 | addlitchar('b', yyscanner);
424 | }
425 | {quotestop} |
426 | {quotefail} {
427 | yyless(1);
428 | BEGIN(INITIAL);
429 | yylval->str = litbufdup(yyscanner);
430 | return BCONST;
431 | }
432 | {xhinside} |
433 | {xbinside} {
434 | addlit(yytext, yyleng, yyscanner);
435 | }
436 | {quotecontinue} |
437 | {quotecontinue} {
438 | /* ignore */
439 | }
440 | <> { yyerror("unterminated bit string literal"); }
441 |
442 | {xhstart} {
443 | /* Hexadecimal bit type.
444 | * At some point we should simply pass the string
445 | * forward to the parser and label it there.
446 | * In the meantime, place a leading "x" on the string
447 | * to mark it for the input routine as a hex string.
448 | */
449 | SET_YYLLOC();
450 | BEGIN(xh);
451 | startlit();
452 | addlitchar('x', yyscanner);
453 | }
454 | {quotestop} |
455 | {quotefail} {
456 | yyless(1);
457 | BEGIN(INITIAL);
458 | yylval->str = litbufdup(yyscanner);
459 | return XCONST;
460 | }
461 | <> { yyerror("unterminated hexadecimal string literal"); }
462 |
463 | {xnstart} {
464 | /* National character.
465 | * We will pass this along as a normal character string,
466 | * but preceded with an internally-generated "NCHAR".
467 | */
468 | const ScanKeyword *keyword;
469 |
470 | SET_YYLLOC();
471 | yyless(1); /* eat only 'n' this time */
472 |
473 | keyword = ScanKeywordLookup("nchar",
474 | yyextra->keywords,
475 | yyextra->num_keywords);
476 | if (keyword != NULL)
477 | {
478 | yylval->keyword = keyword->name;
479 | return keyword->value;
480 | }
481 | else
482 | {
483 | /* If NCHAR isn't a keyword, just return "n" */
484 | yylval->str = pstrdup("n");
485 | return IDENT;
486 | }
487 | }
488 |
489 | {xqstart} {
490 | yyextra->warn_on_first_escape = true;
491 | yyextra->saw_non_ascii = false;
492 | SET_YYLLOC();
493 | if (standard_conforming_strings)
494 | BEGIN(xq);
495 | else
496 | BEGIN(xe);
497 | startlit();
498 | }
499 | {xestart} {
500 | yyextra->warn_on_first_escape = false;
501 | yyextra->saw_non_ascii = false;
502 | SET_YYLLOC();
503 | BEGIN(xe);
504 | startlit();
505 | }
506 | {xusstart} {
507 | SET_YYLLOC();
508 | if (!standard_conforming_strings)
509 | ereport(ERROR,
510 | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
511 | errmsg("unsafe use of string constant with Unicode escapes"),
512 | errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off."),
513 | lexer_errposition()));
514 | BEGIN(xus);
515 | startlit();
516 | }
517 | {quotestop} |
518 | {quotefail} {
519 | yyless(1);
520 | BEGIN(INITIAL);
521 | /*
522 | * check that the data remains valid if it might have been
523 | * made invalid by unescaping any chars.
524 | */
525 | if (yyextra->saw_non_ascii)
526 | pg_verifymbstr(yyextra->literalbuf,
527 | yyextra->literallen,
528 | false);
529 | yylval->str = litbufdup(yyscanner);
530 | return SCONST;
531 | }
532 | {xusstop1} {
533 | /* throw back all but the quote */
534 | yyless(1);
535 | BEGIN(INITIAL);
536 | yylval->str = litbuf_udeescape('\\', yyscanner);
537 | return SCONST;
538 | }
539 | {xusstop2} {
540 | BEGIN(INITIAL);
541 | yylval->str = litbuf_udeescape(yytext[yyleng-2], yyscanner);
542 | return SCONST;
543 | }
544 | {xqdouble} {
545 | addlitchar('\'', yyscanner);
546 | }
547 | {xqinside} {
548 | addlit(yytext, yyleng, yyscanner);
549 | }
550 | {xeinside} {
551 | addlit(yytext, yyleng, yyscanner);
552 | }
553 | {xeunicode} {
554 | pg_wchar c = strtoul(yytext+2, NULL, 16);
555 |
556 | check_escape_warning(yyscanner);
557 |
558 | if (is_utf16_surrogate_first(c))
559 | {
560 | yyextra->utf16_first_part = c;
561 | BEGIN(xeu);
562 | }
563 | else if (is_utf16_surrogate_second(c))
564 | yyerror("invalid Unicode surrogate pair");
565 | else
566 | addunicode(c, yyscanner);
567 | }
568 | {xeunicode} {
569 | pg_wchar c = strtoul(yytext+2, NULL, 16);
570 |
571 | if (!is_utf16_surrogate_second(c))
572 | yyerror("invalid Unicode surrogate pair");
573 |
574 | c = surrogate_pair_to_codepoint(yyextra->utf16_first_part, c);
575 |
576 | addunicode(c, yyscanner);
577 |
578 | BEGIN(xe);
579 | }
580 | . { yyerror("invalid Unicode surrogate pair"); }
581 | \n { yyerror("invalid Unicode surrogate pair"); }
582 | <> { yyerror("invalid Unicode surrogate pair"); }
583 | {xeunicodefail} {
584 | ereport(ERROR,
585 | (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
586 | errmsg("invalid Unicode escape"),
587 | errhint("Unicode escapes must be \\uXXXX or \\UXXXXXXXX."),
588 | lexer_errposition()));
589 | }
590 | {xeescape} {
591 | if (yytext[1] == '\'')
592 | {
593 | if (backslash_quote == BACKSLASH_QUOTE_OFF ||
594 | (backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING &&
595 | PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding())))
596 | ereport(ERROR,
597 | (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
598 | errmsg("unsafe use of \\' in a string literal"),
599 | errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
600 | lexer_errposition()));
601 | }
602 | check_string_escape_warning(yytext[1], yyscanner);
603 | addlitchar(unescape_single_char(yytext[1], yyscanner),
604 | yyscanner);
605 | }
606 | {xeoctesc} {
607 | unsigned char c = strtoul(yytext+1, NULL, 8);
608 |
609 | check_escape_warning(yyscanner);
610 | addlitchar(c, yyscanner);
611 | if (c == '\0' || IS_HIGHBIT_SET(c))
612 | yyextra->saw_non_ascii = true;
613 | }
614 | {xehexesc} {
615 | unsigned char c = strtoul(yytext+2, NULL, 16);
616 |
617 | check_escape_warning(yyscanner);
618 | addlitchar(c, yyscanner);
619 | if (c == '\0' || IS_HIGHBIT_SET(c))
620 | yyextra->saw_non_ascii = true;
621 | }
622 | {quotecontinue} {
623 | /* ignore */
624 | }
625 | . {
626 | /* This is only needed for \ just before EOF */
627 | addlitchar(yytext[0], yyscanner);
628 | }
629 | <> { yyerror("unterminated quoted string"); }
630 |
631 | {dolqdelim} {
632 | SET_YYLLOC();
633 | yyextra->dolqstart = pstrdup(yytext);
634 | BEGIN(xdolq);
635 | startlit();
636 | }
637 | {dolqfailed} {
638 | SET_YYLLOC();
639 | /* throw back all but the initial "$" */
640 | yyless(1);
641 | /* and treat it as {other} */
642 | return yytext[0];
643 | }
644 | {dolqdelim} {
645 | if (strcmp(yytext, yyextra->dolqstart) == 0)
646 | {
647 | pfree(yyextra->dolqstart);
648 | yyextra->dolqstart = NULL;
649 | BEGIN(INITIAL);
650 | yylval->str = litbufdup(yyscanner);
651 | return SCONST;
652 | }
653 | else
654 | {
655 | /*
656 | * When we fail to match $...$ to dolqstart, transfer
657 | * the $... part to the output, but put back the final
658 | * $ for rescanning. Consider $delim$...$junk$delim$
659 | */
660 | addlit(yytext, yyleng-1, yyscanner);
661 | yyless(yyleng-1);
662 | }
663 | }
664 | {dolqinside} {
665 | addlit(yytext, yyleng, yyscanner);
666 | }
667 | {dolqfailed} {
668 | addlit(yytext, yyleng, yyscanner);
669 | }
670 | . {
671 | /* This is only needed for $ inside the quoted text */
672 | addlitchar(yytext[0], yyscanner);
673 | }
674 | <> { yyerror("unterminated dollar-quoted string"); }
675 |
676 | {xdstart} {
677 | SET_YYLLOC();
678 | BEGIN(xd);
679 | startlit();
680 | }
681 | {xuistart} {
682 | SET_YYLLOC();
683 | BEGIN(xui);
684 | startlit();
685 | }
686 | {xdstop} {
687 | char *ident;
688 |
689 | BEGIN(INITIAL);
690 | if (yyextra->literallen == 0)
691 | yyerror("zero-length delimited identifier");
692 | ident = litbufdup(yyscanner);
693 | if (yyextra->literallen >= NAMEDATALEN)
694 | truncate_identifier(ident, yyextra->literallen, true);
695 | yylval->str = ident;
696 | return IDENT;
697 | }
698 | {xuistop1} {
699 | char *ident;
700 |
701 | BEGIN(INITIAL);
702 | if (yyextra->literallen == 0)
703 | yyerror("zero-length delimited identifier");
704 | ident = litbuf_udeescape('\\', yyscanner);
705 | if (yyextra->literallen >= NAMEDATALEN)
706 | truncate_identifier(ident, yyextra->literallen, true);
707 | yylval->str = ident;
708 | /* throw back all but the quote */
709 | yyless(1);
710 | return IDENT;
711 | }
712 | {xuistop2} {
713 | char *ident;
714 |
715 | BEGIN(INITIAL);
716 | if (yyextra->literallen == 0)
717 | yyerror("zero-length delimited identifier");
718 | ident = litbuf_udeescape(yytext[yyleng - 2], yyscanner);
719 | if (yyextra->literallen >= NAMEDATALEN)
720 | truncate_identifier(ident, yyextra->literallen, true);
721 | yylval->str = ident;
722 | return IDENT;
723 | }
724 | {xddouble} {
725 | addlitchar('"', yyscanner);
726 | }
727 | {xdinside} {
728 | addlit(yytext, yyleng, yyscanner);
729 | }
730 | <> { yyerror("unterminated quoted identifier"); }
731 |
732 | {xufailed} {
733 | char *ident;
734 |
735 | SET_YYLLOC();
736 | /* throw back all but the initial u/U */
737 | yyless(1);
738 | /* and treat it as {identifier} */
739 | ident = downcase_truncate_identifier(yytext, yyleng, true);
740 | yylval->str = ident;
741 | return IDENT;
742 | }
743 |
744 | {typecast} {
745 | SET_YYLLOC();
746 | return TYPECAST;
747 | }
748 |
749 | {dot_dot} {
750 | SET_YYLLOC();
751 | return DOT_DOT;
752 | }
753 |
754 | {colon_equals} {
755 | SET_YYLLOC();
756 | return COLON_EQUALS;
757 | }
758 |
759 | {self} {
760 | SET_YYLLOC();
761 | return yytext[0];
762 | }
763 |
764 | {operator} {
765 | /*
766 | * Check for embedded slash-star or dash-dash; those
767 | * are comment starts, so operator must stop there.
768 | * Note that slash-star or dash-dash at the first
769 | * character will match a prior rule, not this one.
770 | */
771 | int nchars = yyleng;
772 | char *slashstar = strstr(yytext, "/*");
773 | char *dashdash = strstr(yytext, "--");
774 |
775 | if (slashstar && dashdash)
776 | {
777 | /* if both appear, take the first one */
778 | if (slashstar > dashdash)
779 | slashstar = dashdash;
780 | }
781 | else if (!slashstar)
782 | slashstar = dashdash;
783 | if (slashstar)
784 | nchars = slashstar - yytext;
785 |
786 | /*
787 | * For SQL compatibility, '+' and '-' cannot be the
788 | * last char of a multi-char operator unless the operator
789 | * contains chars that are not in SQL operators.
790 | * The idea is to lex '=-' as two operators, but not
791 | * to forbid operator names like '?-' that could not be
792 | * sequences of SQL operators.
793 | */
794 | while (nchars > 1 &&
795 | (yytext[nchars-1] == '+' ||
796 | yytext[nchars-1] == '-'))
797 | {
798 | int ic;
799 |
800 | for (ic = nchars-2; ic >= 0; ic--)
801 | {
802 | if (strchr("~!@#^&|`?%", yytext[ic]))
803 | break;
804 | }
805 | if (ic >= 0)
806 | break; /* found a char that makes it OK */
807 | nchars--; /* else remove the +/-, and check again */
808 | }
809 |
810 | SET_YYLLOC();
811 |
812 | if (nchars < yyleng)
813 | {
814 | /* Strip the unwanted chars from the token */
815 | yyless(nchars);
816 | /*
817 | * If what we have left is only one char, and it's
818 | * one of the characters matching "self", then
819 | * return it as a character token the same way
820 | * that the "self" rule would have.
821 | */
822 | if (nchars == 1 &&
823 | strchr(",()[].;:+-*/%^<>=", yytext[0]))
824 | return yytext[0];
825 | }
826 |
827 | /*
828 | * Complain if operator is too long. Unlike the case
829 | * for identifiers, we make this an error not a notice-
830 | * and-truncate, because the odds are we are looking at
831 | * a syntactic mistake anyway.
832 | */
833 | if (nchars >= NAMEDATALEN)
834 | yyerror("operator too long");
835 |
836 | /* Convert "!=" operator to "<>" for compatibility */
837 | if (strcmp(yytext, "!=") == 0)
838 | yylval->str = pstrdup("<>");
839 | else
840 | yylval->str = pstrdup(yytext);
841 | return Op;
842 | }
843 |
844 | {param} {
845 | SET_YYLLOC();
846 | yylval->ival = atol(yytext + 1);
847 | return PARAM;
848 | }
849 |
850 | {integer} {
851 | SET_YYLLOC();
852 | return process_integer_literal(yytext, yylval);
853 | }
854 | {decimal} {
855 | SET_YYLLOC();
856 | yylval->str = pstrdup(yytext);
857 | return FCONST;
858 | }
859 | {decimalfail} {
860 | /* throw back the .., and treat as integer */
861 | yyless(yyleng-2);
862 | SET_YYLLOC();
863 | return process_integer_literal(yytext, yylval);
864 | }
865 | {real} {
866 | SET_YYLLOC();
867 | yylval->str = pstrdup(yytext);
868 | return FCONST;
869 | }
870 | {realfail1} {
871 | /*
872 | * throw back the [Ee], and treat as {decimal}. Note
873 | * that it is possible the input is actually {integer},
874 | * but since this case will almost certainly lead to a
875 | * syntax error anyway, we don't bother to distinguish.
876 | */
877 | yyless(yyleng-1);
878 | SET_YYLLOC();
879 | yylval->str = pstrdup(yytext);
880 | return FCONST;
881 | }
882 | {realfail2} {
883 | /* throw back the [Ee][+-], and proceed as above */
884 | yyless(yyleng-2);
885 | SET_YYLLOC();
886 | yylval->str = pstrdup(yytext);
887 | return FCONST;
888 | }
889 |
890 |
891 | {identifier} {
892 | const ScanKeyword *keyword;
893 | char *ident;
894 |
895 | SET_YYLLOC();
896 |
897 | /* Is it a keyword? */
898 | keyword = ScanKeywordLookup(yytext,
899 | yyextra->keywords,
900 | yyextra->num_keywords);
901 | if (keyword != NULL)
902 | {
903 | yylval->keyword = keyword->name;
904 | return keyword->value;
905 | }
906 |
907 | /*
908 | * No. Convert the identifier to lower case, and truncate
909 | * if necessary.
910 | */
911 | ident = downcase_truncate_identifier(yytext, yyleng, true);
912 | yylval->str = ident;
913 | return IDENT;
914 | }
915 |
916 | {other} {
917 | SET_YYLLOC();
918 | return yytext[0];
919 | }
920 |
921 | <> {
922 | SET_YYLLOC();
923 | yyterminate();
924 | }
925 |
926 | %%
927 |
928 | /*
929 | * Arrange access to yyextra for subroutines of the main yylex() function.
930 | * We expect each subroutine to have a yyscanner parameter. Rather than
931 | * use the yyget_xxx functions, which might or might not get inlined by the
932 | * compiler, we cheat just a bit and cast yyscanner to the right type.
933 | */
934 | #undef yyextra
935 | #define yyextra (((struct yyguts_t *) yyscanner)->yyextra_r)
936 |
937 | /* Likewise for a couple of other things we need. */
938 | #undef yylloc
939 | #define yylloc (((struct yyguts_t *) yyscanner)->yylloc_r)
940 | #undef yyleng
941 | #define yyleng (((struct yyguts_t *) yyscanner)->yyleng_r)
942 |
943 |
944 | /*
945 | * scanner_errposition
946 | * Report a lexer or grammar error cursor position, if possible.
947 | *
948 | * This is expected to be used within an ereport() call. The return value
949 | * is a dummy (always 0, in fact).
950 | *
951 | * Note that this can only be used for messages emitted during raw parsing
952 | * (essentially, scan.l and gram.y), since it requires the yyscanner struct
953 | * to still be available.
954 | */
955 | int
956 | scanner_errposition(int location, core_yyscan_t yyscanner)
957 | {
958 | int pos;
959 |
960 | if (location < 0)
961 | return 0; /* no-op if location is unknown */
962 |
963 | /* Convert byte offset to character number */
964 | pos = pg_mbstrlen_with_len(yyextra->scanbuf, location) + 1;
965 | /* And pass it to the ereport mechanism */
966 | return errposition(pos);
967 | }
968 |
969 | /*
970 | * scanner_yyerror
971 | * Report a lexer or grammar error.
972 | *
973 | * The message's cursor position is whatever YYLLOC was last set to,
974 | * ie, the start of the current token if called within yylex(), or the
975 | * most recently lexed token if called from the grammar.
976 | * This is OK for syntax error messages from the Bison parser, because Bison
977 | * parsers report error as soon as the first unparsable token is reached.
978 | * Beware of using yyerror for other purposes, as the cursor position might
979 | * be misleading!
980 | */
981 | void
982 | scanner_yyerror(const char *message, core_yyscan_t yyscanner)
983 | {
984 | const char *loc = yyextra->scanbuf + *yylloc;
985 |
986 | if (*loc == YY_END_OF_BUFFER_CHAR)
987 | {
988 | ereport(ERROR,
989 | (errcode(ERRCODE_SYNTAX_ERROR),
990 | /* translator: %s is typically the translation of "syntax error" */
991 | errmsg("%s at end of input", _(message)),
992 | lexer_errposition()));
993 | }
994 | else
995 | {
996 | ereport(ERROR,
997 | (errcode(ERRCODE_SYNTAX_ERROR),
998 | /* translator: first %s is typically the translation of "syntax error" */
999 | errmsg("%s at or near \"%s\"", _(message), loc),
1000 | lexer_errposition()));
1001 | }
1002 | }
1003 |
1004 |
1005 | /*
1006 | * Called before any actual parsing is done
1007 | */
1008 | core_yyscan_t
1009 | scanner_init(const char *str,
1010 | core_yy_extra_type *yyext,
1011 | const ScanKeyword *keywords,
1012 | int num_keywords)
1013 | {
1014 | Size slen = strlen(str);
1015 | yyscan_t scanner;
1016 |
1017 | if (yylex_init(&scanner) != 0)
1018 | elog(ERROR, "yylex_init() failed: %m");
1019 |
1020 | core_yyset_extra(yyext, scanner);
1021 |
1022 | yyext->keywords = keywords;
1023 | yyext->num_keywords = num_keywords;
1024 |
1025 | /*
1026 | * Make a scan buffer with special termination needed by flex.
1027 | */
1028 | yyext->scanbuf = (char *) palloc(slen + 2);
1029 | yyext->scanbuflen = slen;
1030 | memcpy(yyext->scanbuf, str, slen);
1031 | yyext->scanbuf[slen] = yyext->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
1032 | yy_scan_buffer(yyext->scanbuf, slen + 2, scanner);
1033 |
1034 | /* initialize literal buffer to a reasonable but expansible size */
1035 | yyext->literalalloc = 1024;
1036 | yyext->literalbuf = (char *) palloc(yyext->literalalloc);
1037 | yyext->literallen = 0;
1038 |
1039 | return scanner;
1040 | }
1041 |
1042 |
1043 | /*
1044 | * Called after parsing is done to clean up after scanner_init()
1045 | */
1046 | void
1047 | scanner_finish(core_yyscan_t yyscanner)
1048 | {
1049 | /*
1050 | * We don't bother to call yylex_destroy(), because all it would do
1051 | * is pfree a small amount of control storage. It's cheaper to leak
1052 | * the storage until the parsing context is destroyed. The amount of
1053 | * space involved is usually negligible compared to the output parse
1054 | * tree anyway.
1055 | *
1056 | * We do bother to pfree the scanbuf and literal buffer, but only if they
1057 | * represent a nontrivial amount of space. The 8K cutoff is arbitrary.
1058 | */
1059 | if (yyextra->scanbuflen >= 8192)
1060 | pfree(yyextra->scanbuf);
1061 | if (yyextra->literalalloc >= 8192)
1062 | pfree(yyextra->literalbuf);
1063 | }
1064 |
1065 |
1066 | static void
1067 | addlit(char *ytext, int yleng, core_yyscan_t yyscanner)
1068 | {
1069 | /* enlarge buffer if needed */
1070 | if ((yyextra->literallen + yleng) >= yyextra->literalalloc)
1071 | {
1072 | do {
1073 | yyextra->literalalloc *= 2;
1074 | } while ((yyextra->literallen + yleng) >= yyextra->literalalloc);
1075 | yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
1076 | yyextra->literalalloc);
1077 | }
1078 | /* append new data */
1079 | memcpy(yyextra->literalbuf + yyextra->literallen, ytext, yleng);
1080 | yyextra->literallen += yleng;
1081 | }
1082 |
1083 |
1084 | static void
1085 | addlitchar(unsigned char ychar, core_yyscan_t yyscanner)
1086 | {
1087 | /* enlarge buffer if needed */
1088 | if ((yyextra->literallen + 1) >= yyextra->literalalloc)
1089 | {
1090 | yyextra->literalalloc *= 2;
1091 | yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
1092 | yyextra->literalalloc);
1093 | }
1094 | /* append new data */
1095 | yyextra->literalbuf[yyextra->literallen] = ychar;
1096 | yyextra->literallen += 1;
1097 | }
1098 |
1099 |
1100 | /*
1101 | * Create a palloc'd copy of literalbuf, adding a trailing null.
1102 | */
1103 | static char *
1104 | litbufdup(core_yyscan_t yyscanner)
1105 | {
1106 | int llen = yyextra->literallen;
1107 | char *new;
1108 |
1109 | new = palloc(llen + 1);
1110 | memcpy(new, yyextra->literalbuf, llen);
1111 | new[llen] = '\0';
1112 | return new;
1113 | }
1114 |
1115 | static int
1116 | process_integer_literal(const char *token, YYSTYPE *lval)
1117 | {
1118 | long val;
1119 | char *endptr;
1120 |
1121 | errno = 0;
1122 | val = strtol(token, &endptr, 10);
1123 | if (*endptr != '\0' || errno == ERANGE
1124 | #ifdef HAVE_LONG_INT_64
1125 | /* if long > 32 bits, check for overflow of int4 */
1126 | || val != (long) ((int32) val)
1127 | #endif
1128 | )
1129 | {
1130 | /* integer too large, treat it as a float */
1131 | lval->str = pstrdup(token);
1132 | return FCONST;
1133 | }
1134 | lval->ival = val;
1135 | return ICONST;
1136 | }
1137 |
1138 | static unsigned int
1139 | hexval(unsigned char c)
1140 | {
1141 | if (c >= '0' && c <= '9')
1142 | return c - '0';
1143 | if (c >= 'a' && c <= 'f')
1144 | return c - 'a' + 0xA;
1145 | if (c >= 'A' && c <= 'F')
1146 | return c - 'A' + 0xA;
1147 | elog(ERROR, "invalid hexadecimal digit");
1148 | return 0; /* not reached */
1149 | }
1150 |
1151 | static void
1152 | check_unicode_value(pg_wchar c, char *loc, core_yyscan_t yyscanner)
1153 | {
1154 | if (GetDatabaseEncoding() == PG_UTF8)
1155 | return;
1156 |
1157 | if (c > 0x7F)
1158 | {
1159 | ADVANCE_YYLLOC(loc - yyextra->literalbuf + 3); /* 3 for U&" */
1160 | yyerror("Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8");
1161 | }
1162 | }
1163 |
1164 | static bool
1165 | is_utf16_surrogate_first(pg_wchar c)
1166 | {
1167 | return (c >= 0xD800 && c <= 0xDBFF);
1168 | }
1169 |
1170 | static bool
1171 | is_utf16_surrogate_second(pg_wchar c)
1172 | {
1173 | return (c >= 0xDC00 && c <= 0xDFFF);
1174 | }
1175 |
1176 | static pg_wchar
1177 | surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second)
1178 | {
1179 | return ((first & 0x3FF) << 10) + 0x10000 + (second & 0x3FF);
1180 | }
1181 |
1182 | static void
1183 | addunicode(pg_wchar c, core_yyscan_t yyscanner)
1184 | {
1185 | char buf[8];
1186 |
1187 | if (c == 0 || c > 0x10FFFF)
1188 | yyerror("invalid Unicode escape value");
1189 | if (c > 0x7F)
1190 | {
1191 | if (GetDatabaseEncoding() != PG_UTF8)
1192 | yyerror("Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8");
1193 | yyextra->saw_non_ascii = true;
1194 | }
1195 | unicode_to_utf8(c, (unsigned char *) buf);
1196 | addlit(buf, pg_mblen(buf), yyscanner);
1197 | }
1198 |
1199 | static char *
1200 | litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
1201 | {
1202 | char *new;
1203 | char *litbuf, *in, *out;
1204 | pg_wchar pair_first = 0;
1205 |
1206 | if (isxdigit(escape)
1207 | || escape == '+'
1208 | || escape == '\''
1209 | || escape == '"'
1210 | || scanner_isspace(escape))
1211 | {
1212 | ADVANCE_YYLLOC(yyextra->literallen + yyleng + 1);
1213 | yyerror("invalid Unicode escape character");
1214 | }
1215 |
1216 | /* Make literalbuf null-terminated to simplify the scanning loop */
1217 | litbuf = yyextra->literalbuf;
1218 | litbuf[yyextra->literallen] = '\0';
1219 |
1220 | /*
1221 | * This relies on the subtle assumption that a UTF-8 expansion
1222 | * cannot be longer than its escaped representation.
1223 | */
1224 | new = palloc(yyextra->literallen + 1);
1225 |
1226 | in = litbuf;
1227 | out = new;
1228 | while (*in)
1229 | {
1230 | if (in[0] == escape)
1231 | {
1232 | if (in[1] == escape)
1233 | {
1234 | if (pair_first)
1235 | {
1236 | ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1237 | yyerror("invalid Unicode surrogate pair");
1238 | }
1239 | *out++ = escape;
1240 | in += 2;
1241 | }
1242 | else if (isxdigit((unsigned char) in[1]) &&
1243 | isxdigit((unsigned char) in[2]) &&
1244 | isxdigit((unsigned char) in[3]) &&
1245 | isxdigit((unsigned char) in[4]))
1246 | {
1247 | pg_wchar unicode;
1248 |
1249 | unicode = (hexval(in[1]) << 12) +
1250 | (hexval(in[2]) << 8) +
1251 | (hexval(in[3]) << 4) +
1252 | hexval(in[4]);
1253 | check_unicode_value(unicode, in, yyscanner);
1254 | if (pair_first)
1255 | {
1256 | if (is_utf16_surrogate_second(unicode))
1257 | {
1258 | unicode = surrogate_pair_to_codepoint(pair_first, unicode);
1259 | pair_first = 0;
1260 | }
1261 | else
1262 | {
1263 | ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1264 | yyerror("invalid Unicode surrogate pair");
1265 | }
1266 | }
1267 | else if (is_utf16_surrogate_second(unicode))
1268 | yyerror("invalid Unicode surrogate pair");
1269 |
1270 | if (is_utf16_surrogate_first(unicode))
1271 | pair_first = unicode;
1272 | else
1273 | {
1274 | unicode_to_utf8(unicode, (unsigned char *) out);
1275 | out += pg_mblen(out);
1276 | }
1277 | in += 5;
1278 | }
1279 | else if (in[1] == '+' &&
1280 | isxdigit((unsigned char) in[2]) &&
1281 | isxdigit((unsigned char) in[3]) &&
1282 | isxdigit((unsigned char) in[4]) &&
1283 | isxdigit((unsigned char) in[5]) &&
1284 | isxdigit((unsigned char) in[6]) &&
1285 | isxdigit((unsigned char) in[7]))
1286 | {
1287 | pg_wchar unicode;
1288 |
1289 | unicode = (hexval(in[2]) << 20) +
1290 | (hexval(in[3]) << 16) +
1291 | (hexval(in[4]) << 12) +
1292 | (hexval(in[5]) << 8) +
1293 | (hexval(in[6]) << 4) +
1294 | hexval(in[7]);
1295 | check_unicode_value(unicode, in, yyscanner);
1296 | if (pair_first)
1297 | {
1298 | if (is_utf16_surrogate_second(unicode))
1299 | {
1300 | unicode = surrogate_pair_to_codepoint(pair_first, unicode);
1301 | pair_first = 0;
1302 | }
1303 | else
1304 | {
1305 | ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1306 | yyerror("invalid Unicode surrogate pair");
1307 | }
1308 | }
1309 | else if (is_utf16_surrogate_second(unicode))
1310 | yyerror("invalid Unicode surrogate pair");
1311 |
1312 | if (is_utf16_surrogate_first(unicode))
1313 | pair_first = unicode;
1314 | else
1315 | {
1316 | unicode_to_utf8(unicode, (unsigned char *) out);
1317 | out += pg_mblen(out);
1318 | }
1319 | in += 8;
1320 | }
1321 | else
1322 | {
1323 | ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1324 | yyerror("invalid Unicode escape value");
1325 | }
1326 | }
1327 | else
1328 | {
1329 | if (pair_first)
1330 | {
1331 | ADVANCE_YYLLOC(in - litbuf + 3); /* 3 for U&" */
1332 | yyerror("invalid Unicode surrogate pair");
1333 | }
1334 | *out++ = *in++;
1335 | }
1336 | }
1337 |
1338 | *out = '\0';
1339 | /*
1340 | * We could skip pg_verifymbstr if we didn't process any non-7-bit-ASCII
1341 | * codes; but it's probably not worth the trouble, since this isn't
1342 | * likely to be a performance-critical path.
1343 | */
1344 | pg_verifymbstr(new, out - new, false);
1345 | return new;
1346 | }
1347 |
1348 | static unsigned char
1349 | unescape_single_char(unsigned char c, core_yyscan_t yyscanner)
1350 | {
1351 | switch (c)
1352 | {
1353 | case 'b':
1354 | return '\b';
1355 | case 'f':
1356 | return '\f';
1357 | case 'n':
1358 | return '\n';
1359 | case 'r':
1360 | return '\r';
1361 | case 't':
1362 | return '\t';
1363 | default:
1364 | /* check for backslash followed by non-7-bit-ASCII */
1365 | if (c == '\0' || IS_HIGHBIT_SET(c))
1366 | yyextra->saw_non_ascii = true;
1367 |
1368 | return c;
1369 | }
1370 | }
1371 |
1372 | static void
1373 | check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner)
1374 | {
1375 | if (ychar == '\'')
1376 | {
1377 | if (yyextra->warn_on_first_escape && escape_string_warning)
1378 | ereport(WARNING,
1379 | (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1380 | errmsg("nonstandard use of \\' in a string literal"),
1381 | errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
1382 | lexer_errposition()));
1383 | yyextra->warn_on_first_escape = false; /* warn only once per string */
1384 | }
1385 | else if (ychar == '\\')
1386 | {
1387 | if (yyextra->warn_on_first_escape && escape_string_warning)
1388 | ereport(WARNING,
1389 | (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1390 | errmsg("nonstandard use of \\\\ in a string literal"),
1391 | errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."),
1392 | lexer_errposition()));
1393 | yyextra->warn_on_first_escape = false; /* warn only once per string */
1394 | }
1395 | else
1396 | check_escape_warning(yyscanner);
1397 | }
1398 |
1399 | static void
1400 | check_escape_warning(core_yyscan_t yyscanner)
1401 | {
1402 | if (yyextra->warn_on_first_escape && escape_string_warning)
1403 | ereport(WARNING,
1404 | (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1405 | errmsg("nonstandard use of escape in a string literal"),
1406 | errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."),
1407 | lexer_errposition()));
1408 | yyextra->warn_on_first_escape = false; /* warn only once per string */
1409 | }
1410 |
1411 | /*
1412 | * Interface functions to make flex use palloc() instead of malloc().
1413 | * It'd be better to make these static, but flex insists otherwise.
1414 | */
1415 |
1416 | void *
1417 | core_yyalloc(yy_size_t bytes, core_yyscan_t yyscanner)
1418 | {
1419 | return palloc(bytes);
1420 | }
1421 |
1422 | void *
1423 | core_yyrealloc(void *ptr, yy_size_t bytes, core_yyscan_t yyscanner)
1424 | {
1425 | if (ptr)
1426 | return repalloc(ptr, bytes);
1427 | else
1428 | return palloc(bytes);
1429 | }
1430 |
1431 | void
1432 | core_yyfree(void *ptr, core_yyscan_t yyscanner)
1433 | {
1434 | if (ptr)
1435 | pfree(ptr);
1436 | }
1437 |
--------------------------------------------------------------------------------
/test files/maths.tex:
--------------------------------------------------------------------------------
1 | \documentclass[20pt,a4paper]{extarticle}
2 | \usepackage[a4paper,margin=6mm]{geometry}
3 | \usepackage{amsmath,amsthm}
4 | \usepackage{hyperref}
5 | \usepackage[capitalise,nameinlink,noabbrev]{cleveref}
6 | \crefname{equation}{}{}
7 |
8 | \newtheorem{theorem}{Theorem}
9 | \newtheorem{corollary}[theorem]{Corollary}
10 | \newtheorem{lemma}[theorem]{Lemma}
11 | \newtheorem{definition}[theorem]{Definition}
12 |
13 |
14 | \title{\LaTeX\ Mathematics Examples}
15 | \author{Prof Tony Roberts}
16 |
17 | \begin{document}
18 |
19 | \maketitle
20 |
21 | \tableofcontents
22 |
23 |
24 |
25 | \section{Delimiters}
26 |
27 | See how the delimiters are of reasonable size in these examples
28 | \[
29 | \left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
30 | \]
31 | \[
32 | \sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|,
33 | \]
34 | even when there is no matching delimiter
35 | \[
36 | \int_a^bu\frac{d^2v}{dx^2}\,dx
37 | =\left.u\frac{dv}{dx}\right|_a^b
38 | -\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx.
39 | \]
40 |
41 |
42 |
43 |
44 |
45 |
46 | \section{Spacing}
47 |
48 | Differentials often need a bit of help with their spacing as in
49 | \[
50 | \iint xy^2\,dx\,dy
51 | =\frac{1}{6}x^2y^3,
52 | \]
53 | whereas vector problems often lead to statements such as
54 | \[
55 | u=\frac{-y}{x^2+y^2}\,,\quad
56 | v=\frac{x}{x^2+y^2}\,,\quad\text{and}\quad
57 | w=0\,.
58 | \]
59 | Occasionally one gets horrible line breaks when using a list in mathematics such as listing the first twelve primes \(2,3,5,7,11,13,17,19,23,29,31,37\)\,.
60 | In such cases, perhaps include \verb|\mathcode`\,="213B| inside the inline maths environment so that the list breaks: \(\mathcode`\,="213B 2,3,5,7,11,13,17,19,23,29,31,37\)\,.
61 | Be discerning about when to do this as the spacing is different.
62 |
63 |
64 |
65 |
66 |
67 |
68 | \section{Arrays}
69 |
70 | Arrays of mathematics are typeset using one of the matrix environments as
71 | in
72 | \[
73 | \begin{bmatrix}
74 | 1 & x & 0 \\
75 | 0 & 1 & -1
76 | \end{bmatrix}\begin{bmatrix}
77 | 1 \\
78 | y \\
79 | 1
80 | \end{bmatrix}
81 | =\begin{bmatrix}
82 | 1+xy \\
83 | y-1
84 | \end{bmatrix}.
85 | \]
86 | Case statements use cases:
87 | \[
88 | |x|=\begin{cases}
89 | x, & \text{if }x\geq 0\,, \\
90 | -x, & \text{if }x< 0\,.
91 | \end{cases}
92 | \]
93 | Many arrays have lots of dots all over the place as in
94 | \[
95 | \begin{matrix}
96 | -2 & 1 & 0 & 0 & \cdots & 0 \\
97 | 1 & -2 & 1 & 0 & \cdots & 0 \\
98 | 0 & 1 & -2 & 1 & \cdots & 0 \\
99 | 0 & 0 & 1 & -2 & \ddots & \vdots \\
100 | \vdots & \vdots & \vdots & \ddots & \ddots & 1 \\
101 | 0 & 0 & 0 & \cdots & 1 & -2
102 | \end{matrix}
103 | \]
104 |
105 |
106 |
107 |
108 |
109 |
110 | \section{Equation arrays}
111 |
112 | In the flow of a fluid film we may report
113 | \begin{align}
114 | u_\alpha & = \epsilon^2 \kappa_{xxx}
115 | \left( y-\frac{1}{2}y^2 \right),
116 | \label{equ} \\
117 | v & = \epsilon^3 \kappa_{xxx} y\,,
118 | \label{eqv} \\
119 | p & = \epsilon \kappa_{xx}\,.
120 | \label{eqp}
121 | \end{align}
122 | Alternatively, the curl of a vector field $(u,v,w)$ may be written
123 | with only one equation number:
124 | \begin{align}
125 | \omega_1 & =
126 | \frac{\partial w}{\partial y}-\frac{\partial v}{\partial z}\,,
127 | \nonumber \\
128 | \omega_2 & =
129 | \frac{\partial u}{\partial z}-\frac{\partial w}{\partial x}\,,
130 | \label{eqcurl} \\
131 | \omega_3 & =
132 | \frac{\partial v}{\partial x}-\frac{\partial u}{\partial y}\,.
133 | \nonumber
134 | \end{align}
135 | Whereas a derivation may look like
136 | \begin{align*}
137 | (p\wedge q)\vee(p\wedge\neg q) & = p\wedge(q\vee\neg q)
138 | \quad\text{by distributive law} \\
139 | & = p\wedge T \quad\text{by excluded middle} \\
140 | & = p \quad\text{by identity}
141 | \end{align*}
142 |
143 |
144 |
145 |
146 |
147 |
148 | \section{Functions}
149 |
150 | Observe that trigonometric and other elementary functions are typeset
151 | properly, even to the extent of providing a thin space if followed by
152 | a single letter argument:
153 | \[
154 | \exp(i\theta)=\cos\theta +i\sin\theta\,,\quad
155 | \sinh(\log x)=\frac{1}{2}\left( x-\frac{1}{x} \right).
156 | \]
157 | With sub- and super-scripts placed properly on more complicated
158 | functions,
159 | \[
160 | \lim_{q\to\infty}\|f(x)\|_q
161 | =\max_{x}|f(x)|,
162 | \]
163 | and large operators, such as integrals and
164 | \begin{align*}
165 | e^x & = \sum_{n=0}^\infty \frac{x^n}{n!}
166 | \quad\text{where }n!=\prod_{i=1}^n i\,, \\
167 | \overline{U_\alpha} & = \bigcap_\alpha U_\alpha\,.
168 | \end{align*}
169 | In inline mathematics the scripts are correctly placed to the side in
170 | order to conserve vertical space, as in
171 | \(
172 | 1/(1-x)=\sum_{n=0}^\infty x^n.
173 | \)
174 |
175 |
176 |
177 |
178 |
179 |
180 | \section{Accents}
181 |
182 | Mathematical accents are performed by a short command with one
183 | argument, such as
184 | \[
185 | \tilde f(\omega)=\frac{1}{2\pi}
186 | \int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx\,,
187 | \]
188 | or
189 | \[
190 | \dot{\vec \omega}=\vec r\times\vec I\,.
191 | \]
192 |
193 |
194 |
195 |
196 |
197 | \section{Command definition}
198 |
199 | \newcommand{\Ai}{\operatorname{Ai}}
200 | The Airy function, $\Ai(x)$, may be incorrectly defined as this
201 | integral
202 | \[
203 | \Ai(x)=\int\exp(s^3+isx)\,ds\,.
204 | \]
205 |
206 | \newcommand{\D}[2]{\frac{\partial #2}{\partial #1}}
207 | \newcommand{\DD}[2]{\frac{\partial^2 #2}{\partial #1^2}}
208 | \renewcommand{\vec}[1]{\boldsymbol{#1}}
209 |
210 | This vector identity serves nicely to illustrate two of the new
211 | commands:
212 | \[
213 | \vec\nabla\times\vec q
214 | =\vec i\left(\D yw-\D zv\right)
215 | +\vec j\left(\D zu-\D xw\right)
216 | +\vec k\left(\D xv-\D yu\right).
217 | \]
218 |
219 | Recall that typesetting multi-line mathematics is an art normally too hard for computer recipes. Nonetheless, if you need to be automatically flexible about multi-line mathematics, and you do not mind some rough typesetting, then perhaps invoke \verb|\parbox| to help as follows:
220 | % The \verb|breqn| package is not yet reliable enough for general use.
221 | \newcommand{\parmath}[2][0.8\linewidth]{\parbox[t]{#1}%
222 | {\raggedright\linespread{1.2}\selectfont\(#2\)}}
223 | \[
224 | u_1=\parmath{ -2 \gamma \epsilon^{2} s_{2}+\mu \epsilon^{3} \big( \frac{3}{8} s_{2}+\frac{1}{8} s_{1} i\big)+\epsilon^{3} \big( -\frac{81}{32} s_{4} s_{2}^{2}-\frac{27}{16} s_{4} s_{2} s_{1} i+\frac{9}{32} s_{4} s_{1}^{2}+\frac{27}{32} s_{3} s_{2}^{2} i-\frac{9}{16} s_{3} s_{2} s_{1}-\frac{3}{32} s_{3} s_{1}^{2} i\big) +\int_a^b 1-2x+3x^2-4x^3\,dx }
225 | \]
226 | Also, sometimes use \verb|\parbox| to typeset multiline entries in tables.
227 |
228 |
229 | \section{Theorems et al.}
230 |
231 |
232 | \begin{definition}[right-angled triangles] \label{def:tri}
233 | A \emph{right-angled triangle} is a triangle whose sides of length~\(a\), \(b\) and~\(c\), in some permutation of order, satisfies \(a^2+b^2=c^2\).
234 | \end{definition}
235 |
236 | \begin{lemma}
237 | The triangle with sides of length~\(3\), \(4\) and~\(5\) is right-angled.
238 | \end{lemma}
239 |
240 | This lemma follows from \cref{def:tri} since \(3^2+4^2=9+16=25=5^2\).
241 |
242 | \begin{theorem}[Pythagorean triplets] \label{thm:py}
243 | Triangles with sides of length \(a=p^2-q^2\), \(b=2pq\) and \(c=p^2+q^2\) are right-angled triangles.
244 | \end{theorem}
245 |
246 | Prove this \cref{thm:py} by the algebra \(a^2+b^2 =(p^2-q^2)^2+(2pq)^2
247 | =p^4-2p^2q^2+q^4+4p^2q^2
248 | =p^4+2p^2q^2+q^4
249 | =(p^2+q^2)^2 =c^2\).
250 |
251 |
252 | \end{document}
253 |
--------------------------------------------------------------------------------
/test files/othello.lisp:
--------------------------------------------------------------------------------
1 | ;;;; -*- Mode: Lisp; Syntax: Common-Lisp -*-
2 | ;;;; Code from Paradigms of AI Programming
3 | ;;;; Copyright (c) 1991 Peter Norvig
4 |
5 | ;;;; File othello.lisp: An othello monitor, with all strategies
6 | ;;;; up to and including section 18.8
7 |
8 | ;;; One bug fix by Alberto Segre, segre@cs.cornell.edu, March 1993.
9 |
10 | (defun cross-product (fn xlist ylist)
11 | "Return a list of all (fn x y) values."
12 | (mappend #'(lambda (y)
13 | (mapcar #'(lambda (x) (funcall fn x y))
14 | xlist))
15 | ylist))
16 |
17 | (defconstant all-directions '(-11 -10 -9 -1 1 9 10 11))
18 |
19 | (defconstant empty 0 "An empty square")
20 | (defconstant black 1 "A black piece")
21 | (defconstant white 2 "A white piece")
22 | (defconstant outer 3 "Marks squares outside the 8x8 board")
23 |
24 | (deftype piece () `(integer ,empty ,outer))
25 |
26 | (defun name-of (piece) (char ".@O?" piece))
27 |
28 | (defun opponent (player) (if (eql player black) white black))
29 |
30 | (deftype board () '(simple-array piece (100)))
31 |
32 | (defun bref (board square) (aref board square))
33 | (defsetf bref (board square) (val)
34 | `(setf (aref ,board ,square) ,val))
35 |
36 | (defun copy-board (board)
37 | (copy-seq board))
38 |
39 | (defconstant all-squares
40 | (loop for i from 11 to 88 when (<= 1 (mod i 10) 8) collect i))
41 |
42 | (defun initial-board ()
43 | "Return a board, empty except for four pieces in the middle."
44 | ;; Boards are 100-element vectors, with elements 11-88 used,
45 | ;; and the others marked with the sentinel OUTER. Initially
46 | ;; the 4 center squares are taken, the others empty.
47 | (let ((board (make-array 100 :element-type 'piece
48 | :initial-element outer)))
49 | (dolist (square all-squares)
50 | (setf (bref board square) empty))
51 | (setf (bref board 44) white (bref board 45) black
52 | (bref board 54) black (bref board 55) white)
53 | board))
54 |
55 | (defun count-difference (player board)
56 | "Count player's pieces minus opponent's pieces."
57 | (- (count player board)
58 | (count (opponent player) board)))
59 |
60 | (defun valid-p (move)
61 | "Valid moves are numbers in the range 11-88 that end in 1-8."
62 | (and (integerp move) (<= 11 move 88) (<= 1 (mod move 10) 8)))
63 |
64 | (defun legal-p (move player board)
65 | "A Legal move must be into an empty square, and it must
66 | flip at least one opponent piece."
67 | (and (eql (bref board move) empty)
68 | (some #'(lambda (dir) (would-flip? move player board dir))
69 | all-directions)))
70 |
71 | (defun make-move (move player board)
72 | "Update board to reflect move by player"
73 | ;; First make the move, then make any flips
74 | (setf (bref board move) player)
75 | (dolist (dir all-directions)
76 | (make-flips move player board dir))
77 | board)
78 |
79 | (defun make-flips (move player board dir)
80 | "Make any flips in the given direction."
81 | (let ((bracketer (would-flip? move player board dir)))
82 | (when bracketer
83 | (loop for c from (+ move dir) by dir until (eql c bracketer)
84 | do (setf (bref board c) player)))))
85 |
86 | (defun would-flip? (move player board dir)
87 | "Would this move result in any flips in this direction?
88 | If so, return the square number of the bracketing piece."
89 | ;; A flip occurs if, starting at the adjacent square, c, there
90 | ;; is a string of at least one opponent pieces, bracketed by
91 | ;; one of player's pieces
92 | (let ((c (+ move dir)))
93 | (and (eql (bref board c) (opponent player))
94 | (find-bracketing-piece (+ c dir) player board dir))))
95 |
96 | (defun find-bracketing-piece (square player board dir)
97 | "Return the square number of the bracketing piece."
98 | (cond ((eql (bref board square) player) square)
99 | ((eql (bref board square) (opponent player))
100 | (find-bracketing-piece (+ square dir) player board dir))
101 | (t nil)))
102 |
103 | (defun next-to-play (board previous-player print)
104 | "Compute the player to move next, or NIL if nobody can move."
105 | (let ((opp (opponent previous-player)))
106 | (cond ((any-legal-move? opp board) opp)
107 | ((any-legal-move? previous-player board)
108 | (when print
109 | (format t "~&~c has no moves and must pass."
110 | (name-of opp)))
111 | previous-player)
112 | (t nil))))
113 |
114 | (defun any-legal-move? (player board)
115 | "Does player have any legal moves in this position?"
116 | (some #'(lambda (move) (legal-p move player board))
117 | all-squares))
118 |
119 | (defun random-strategy (player board)
120 | "Make any legal move."
121 | (random-elt (legal-moves player board)))
122 |
123 | (defun legal-moves (player board)
124 | "Returns a list of legal moves for player"
125 | ;;*** fix, segre, 3/30/93. Was remove-if, which can share with all-squares.
126 | (loop for move in all-squares
127 | when (legal-p move player board) collect move))
128 |
129 | (defun maximize-difference (player board)
130 | "A strategy that maximizes the difference in pieces."
131 | (funcall (maximizer #'count-difference) player board))
132 |
133 | (defun maximizer (eval-fn)
134 | "Return a strategy that will consider every legal move,
135 | apply EVAL-FN to each resulting board, and choose
136 | the move for which EVAL-FN returns the best score.
137 | FN takes two arguments: the player-to-move and board"
138 | #'(lambda (player board)
139 | (let* ((moves (legal-moves player board))
140 | (scores (mapcar #'(lambda (move)
141 | (funcall
142 | eval-fn
143 | player
144 | (make-move move player
145 | (copy-board board))))
146 | moves))
147 | (best (apply #'max scores)))
148 | (elt moves (position best scores)))))
149 |
150 | (defparameter *weights*
151 | '#(0 0 0 0 0 0 0 0 0 0
152 | 0 120 -20 20 5 5 20 -20 120 0
153 | 0 -20 -40 -5 -5 -5 -5 -40 -20 0
154 | 0 20 -5 15 3 3 15 -5 20 0
155 | 0 5 -5 3 3 3 3 -5 5 0
156 | 0 5 -5 3 3 3 3 -5 5 0
157 | 0 20 -5 15 3 3 15 -5 20 0
158 | 0 -20 -40 -5 -5 -5 -5 -40 -20 0
159 | 0 120 -20 20 5 5 20 -20 120 0
160 | 0 0 0 0 0 0 0 0 0 0))
161 |
162 | (defun weighted-squares (player board)
163 | "Sum of the weights of player's squares minus opponent's."
164 | (let ((opp (opponent player)))
165 | (loop for i in all-squares
166 | when (eql (bref board i) player)
167 | sum (aref *weights* i)
168 | when (eql (bref board i) opp)
169 | sum (- (aref *weights* i)))))
170 |
171 | (defconstant winning-value most-positive-fixnum)
172 | (defconstant losing-value most-negative-fixnum)
173 |
174 | (defun final-value (player board)
175 | "Is this a win, loss, or draw for player?"
176 | (case (signum (count-difference player board))
177 | (-1 losing-value)
178 | ( 0 0)
179 | (+1 winning-value)))
180 |
181 | (defun minimax (player board ply eval-fn)
182 | "Find the best move, for PLAYER, according to EVAL-FN,
183 | searching PLY levels deep and backing up values."
184 | (if (= ply 0)
185 | (funcall eval-fn player board)
186 | (let ((moves (legal-moves player board)))
187 | (if (null moves)
188 | (if (any-legal-move? (opponent player) board)
189 | (- (minimax (opponent player) board
190 | (- ply 1) eval-fn))
191 | (final-value player board))
192 | (let ((best-move nil)
193 | (best-val nil))
194 | (dolist (move moves)
195 | (let* ((board2 (make-move move player
196 | (copy-board board)))
197 | (val (- (minimax
198 | (opponent player) board2
199 | (- ply 1) eval-fn))))
200 | (when (or (null best-val)
201 | (> val best-val))
202 | (setf best-val val)
203 | (setf best-move move))))
204 | (values best-val best-move))))))
205 |
206 | (defun minimax-searcher (ply eval-fn)
207 | "A strategy that searches PLY levels and then uses EVAL-FN."
208 | #'(lambda (player board)
209 | (multiple-value-bind (value move)
210 | (minimax player board ply eval-fn)
211 | (declare (ignore value))
212 | move)))
213 |
214 | (defun alpha-beta (player board achievable cutoff ply eval-fn)
215 | "Find the best move, for PLAYER, according to EVAL-FN,
216 | searching PLY levels deep and backing up values,
217 | using cutoffs whenever possible."
218 | (if (= ply 0)
219 | (funcall eval-fn player board)
220 | (let ((moves (legal-moves player board)))
221 | (if (null moves)
222 | (if (any-legal-move? (opponent player) board)
223 | (- (alpha-beta (opponent player) board
224 | (- cutoff) (- achievable)
225 | (- ply 1) eval-fn))
226 | (final-value player board))
227 | (let ((best-move (first moves)))
228 | (loop for move in moves do
229 | (let* ((board2 (make-move move player
230 | (copy-board board)))
231 | (val (- (alpha-beta
232 | (opponent player) board2
233 | (- cutoff) (- achievable)
234 | (- ply 1) eval-fn))))
235 | (when (> val achievable)
236 | (setf achievable val)
237 | (setf best-move move)))
238 | until (>= achievable cutoff))
239 | (values achievable best-move))))))
240 |
241 | (defun alpha-beta-searcher (depth eval-fn)
242 | "A strategy that searches to DEPTH and then uses EVAL-FN."
243 | #'(lambda (player board)
244 | (multiple-value-bind (value move)
245 | (alpha-beta player board losing-value winning-value
246 | depth eval-fn)
247 | (declare (ignore value))
248 | move)))
249 |
250 | (defun modified-weighted-squares (player board)
251 | "Like WEIGHTED-SQUARES, but don't take off for moving
252 | near an occupied corner."
253 | (let ((w (weighted-squares player board)))
254 | (dolist (corner '(11 18 81 88))
255 | (when (not (eql (bref board corner) empty))
256 | (dolist (c (neighbors corner))
257 | (when (not (eql (bref board c) empty))
258 | (incf w (* (- 5 (aref *weights* c))
259 | (if (eql (bref board c) player)
260 | +1 -1)))))))
261 | w))
262 |
263 | (let ((neighbor-table (make-array 100 :initial-element nil)))
264 | ;; Initialize the neighbor table
265 | (dolist (square all-squares)
266 | (dolist (dir all-directions)
267 | (if (valid-p (+ square dir))
268 | (push (+ square dir)
269 | (aref neighbor-table square)))))
270 |
271 | (defun neighbors (square)
272 | "Return a list of all squares adjacent to a square."
273 | (aref neighbor-table square)))
274 |
275 | (let ((square-names
276 | (cross-product #'symbol
277 | '(? a b c d e f g h ?)
278 | '(? 1 2 3 4 5 6 7 8 ?))))
279 |
280 | (defun h8->88 (str)
281 | "Convert from alphanumeric to numeric square notation."
282 | (or (position (string str) square-names :test #'string-equal)
283 | str))
284 |
285 | (defun 88->h8 (num)
286 | "Convert from numeric to alphanumeric square notation."
287 | (if (valid-p num)
288 | (elt square-names num)
289 | num)))
290 |
291 | (defun human (player board)
292 | "A human player for the game of Othello"
293 | (format t "~&~c to move ~a: " (name-of player)
294 | (mapcar #'88->h8 (legal-moves player board)))
295 | (h8->88 (read)))
296 |
297 | (defvar *move-number* 1 "The number of the move to be played")
298 |
299 | (defun othello (bl-strategy wh-strategy
300 | &optional (print t) (minutes 30))
301 | "Play a game of othello. Return the score, where a positive
302 | difference means black, the first player, wins."
303 | (let ((board (initial-board))
304 | (clock (make-array (+ 1 (max black white))
305 | :initial-element
306 | (* minutes 60
307 | internal-time-units-per-second))))
308 | (catch 'game-over
309 | (loop for *move-number* from 1
310 | for player = black then (next-to-play board player print)
311 | for strategy = (if (eql player black)
312 | bl-strategy
313 | wh-strategy)
314 | until (null player)
315 | do (get-move strategy player board print clock))
316 | (when print
317 | (format t "~&The game is over. Final result:")
318 | (print-board board clock))
319 | (count-difference black board))))
320 |
321 | (defvar *clock* (make-array 3) "A copy of the game clock")
322 | (defvar *board* (initial-board) "A copy of the game board")
323 |
324 | (defun get-move (strategy player board print clock)
325 | "Call the player's strategy function to get a move.
326 | Keep calling until a legal move is made."
327 | ;; Note we don't pass the strategy function the REAL board.
328 | ;; If we did, it could cheat by changing the pieces on the board.
329 | (when print (print-board board clock))
330 | (replace *clock* clock)
331 | (let* ((t0 (get-internal-real-time))
332 | (move (funcall strategy player (replace *board* board)))
333 | (t1 (get-internal-real-time)))
334 | (decf (elt clock player) (- t1 t0))
335 | (cond
336 | ((< (elt clock player) 0)
337 | (format t "~&~c has no time left and forfeits."
338 | (name-of player))
339 | (THROW 'game-over (if (eql player black) -64 64)))
340 | ((eq move 'resign)
341 | (THROW 'game-over (if (eql player black) -64 64)))
342 | ((and (valid-p move) (legal-p move player board))
343 | (when print
344 | (format t "~&~c moves to ~a."
345 | (name-of player) (88->h8 move)))
346 | (make-move move player board))
347 | (t (warn "Illegal move: ~a" (88->h8 move))
348 | (get-move strategy player board print clock)))))
349 |
350 | (defun print-board (&optional (board *board*) clock)
351 | "Print a board, along with some statistics."
352 | ;; First print the header and the current score
353 | (format t "~2& a b c d e f g h [~c=~2a ~c=~2a (~@d)]"
354 | (name-of black) (count black board)
355 | (name-of white) (count white board)
356 | (count-difference black board))
357 | ;; Print the board itself
358 | (loop for row from 1 to 8 do
359 | (format t "~& ~d " row)
360 | (loop for col from 1 to 8
361 | for piece = (bref board (+ col (* 10 row)))
362 | do (format t "~c " (name-of piece))))
363 | ;; Finally print the time remaining for each player
364 | (when clock
365 | (format t " [~c=~a ~c=~a]~2&"
366 | (name-of black) (time-string (elt clock black))
367 | (name-of white) (time-string (elt clock white)))))
368 |
369 | (defun time-string (time)
370 | "Return a string representing this internal time in min:secs."
371 | (multiple-value-bind (min sec)
372 | (floor (round time internal-time-units-per-second) 60)
373 | (format nil "~2d:~2,'0d" min sec)))
374 |
375 | (defun random-othello-series (strategy1 strategy2
376 | n-pairs &optional (n-random 10))
377 | "Play a series of 2*n games, starting from a random position."
378 | (othello-series
379 | (switch-strategies #'random-strategy n-random strategy1)
380 | (switch-strategies #'random-strategy n-random strategy2)
381 | n-pairs))
382 |
383 | (defun switch-strategies (strategy1 m strategy2)
384 | "Make a new strategy that plays strategy1 for m moves,
385 | then plays according to strategy2."
386 | #'(lambda (player board)
387 | (funcall (if (<= *move-number* m) strategy1 strategy2)
388 | player board)))
389 |
390 | (defun othello-series (strategy1 strategy2 n-pairs)
391 | "Play a series of 2*n-pairs games, swapping sides."
392 | (let ((scores
393 | (loop repeat n-pairs
394 | for random-state = (make-random-state)
395 | collect (othello strategy1 strategy2 nil)
396 | do (setf *random-state* random-state)
397 | collect (- (othello strategy2 strategy1 nil)))))
398 | ;; Return the number of wins (1/2 for a tie),
399 | ;; the total of the point differences, and the
400 | ;; scores themselves, all from strategy1's point of view.
401 | (values (+ (count-if #'plusp scores)
402 | (/ (count-if #'zerop scores) 2))
403 | (apply #'+ scores)
404 | scores)))
405 |
406 | (defun round-robin (strategies n-pairs &optional
407 | (n-random 10) (names strategies))
408 | "Play a tournament among the strategies.
409 | N-PAIRS = games each strategy plays as each color against
410 | each opponent. So with N strategies, a total of
411 | N*(N-1)*N-PAIRS games are played."
412 | (let* ((N (length strategies))
413 | (totals (make-array N :initial-element 0))
414 | (scores (make-array (list N N)
415 | :initial-element 0)))
416 | ;; Play the games
417 | (dotimes (i N)
418 | (loop for j from (+ i 1) to (- N 1) do
419 | (let* ((wins (random-othello-series
420 | (elt strategies i)
421 | (elt strategies j)
422 | n-pairs n-random))
423 | (losses (- (* 2 n-pairs) wins)))
424 | (incf (aref scores i j) wins)
425 | (incf (aref scores j i) losses)
426 | (incf (aref totals i) wins)
427 | (incf (aref totals j) losses))))
428 | ;; Print the results
429 | (dotimes (i N)
430 | (format t "~&~a~20T ~4f: " (elt names i) (elt totals i))
431 | (dotimes (j N)
432 | (format t "~4f " (if (= i j) '---
433 | (aref scores i j)))))))
434 |
435 | (defun mobility (player board)
436 | "The number of moves a player has."
437 | (length (legal-moves player board)))
438 |
--------------------------------------------------------------------------------
/widget settings/Console Input Widget.sublime-settings:
--------------------------------------------------------------------------------
1 | {
2 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme",
3 | }
4 |
--------------------------------------------------------------------------------
/widget settings/Regex Replace Widget.sublime-settings:
--------------------------------------------------------------------------------
1 | {
2 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme",
3 | }
4 |
--------------------------------------------------------------------------------
/widget settings/Regex Widget.sublime-settings:
--------------------------------------------------------------------------------
1 | {
2 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme",
3 | }
4 |
--------------------------------------------------------------------------------
/widget settings/Widget.sublime-settings:
--------------------------------------------------------------------------------
1 | {
2 | "color_scheme": "Packages/Neon Color Scheme/Neon.sublime-color-scheme",
3 | }
4 |
--------------------------------------------------------------------------------